carbon

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(line []byte) (name []byte, timestamp time.Time, value float64, err error)

Parse parses a carbon line into the corresponding parts.

func ParseName

func ParseName(line []byte) (name []byte, rest []byte, err error)

ParseName parses out the name portion of a string and returns the name and the remaining portion of the line.

func ParseRemainder

func ParseRemainder(rest []byte) (timestamp time.Time, value float64, err error)

ParseRemainder parses a line's components (name and remainder) and returns all but the name and returns the timestamp of the metric, its value, the time it was received and any error encountered.

Types

type Metric

type Metric struct {
	Name []byte
	Time time.Time
	Val  float64
}

Metric represents a carbon metric.

func ParseAndAppendPacket

func ParseAndAppendPacket(mets []Metric, packet []byte) ([]Metric, int)

ParseAndAppendPacket does the same thing as parse packet, but it allows the caller to pass in the []Metric to facilitate pooling.

func ParsePacket

func ParsePacket(packet []byte) ([]Metric, int)

ParsePacket parses a carbon packet and returns the metrics and number of malformed lines.

func (*Metric) ToLine

func (m *Metric) ToLine() string

ToLine converts the carbon Metric struct to a line.

type Scanner

type Scanner struct {

	// The number of malformed metrics encountered.
	MalformedCount int
	// contains filtered or unexported fields
}

A Scanner is used to scan carbon lines from an underlying io.Reader.

func NewScanner

func NewScanner(r io.Reader, iOpts instrument.Options) *Scanner

NewScanner creates a new carbon scanner.

func (*Scanner) Err

func (s *Scanner) Err() error

Err returns any errors in the scan.

func (*Scanner) Metric

func (s *Scanner) Metric() ([]byte, time.Time, float64)

Metric returns the path, timestamp, and value of the last parsed metric.

func (*Scanner) Scan

func (s *Scanner) Scan() bool

Scan scans for the next carbon metric. Malformed metrics are skipped but counted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL