Documentation ¶
Index ¶
- Variables
- func EatDots(name string) string
- func IsSpanValid(span uint32) bool
- func Reslice(in []*MetricData, size int) [][]*MetricData
- func SanitizeNameAsTagValue(name string) string
- func ValidateTag(tag string) error
- func ValidateTagKey(key string) bool
- func ValidateTagValue(value string) bool
- func ValidateTags(tags []string) error
- type AMKey
- type Archive
- func (z *Archive) DecodeMsg(dc *msgp.Reader) (err error)
- func (z Archive) EncodeMsg(en *msgp.Writer) (err error)
- func (z Archive) MarshalMsg(b []byte) (o []byte, err error)
- func (a Archive) Method() Method
- func (z Archive) Msgsize() (s int)
- func (a Archive) Span() uint32
- func (a Archive) String() string
- func (z *Archive) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Key
- type MKey
- type Method
- type MetricData
- func (z *MetricData) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *MetricData) EncodeMsg(en *msgp.Writer) (err error)
- func (z *MetricData) MarshalMsg(b []byte) (o []byte, err error)
- func (z *MetricData) Msgsize() (s int)
- func (m *MetricData) PartitionID(method PartitionByMethod, partitions int32) (int32, error)
- func (m *MetricData) SetId()
- func (z *MetricData) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (m *MetricData) Validate() error
- type MetricDataArray
- func (z *MetricDataArray) DecodeMsg(dc *msgp.Reader) (err error)
- func (z MetricDataArray) EncodeMsg(en *msgp.Writer) (err error)
- func (z MetricDataArray) MarshalMsg(b []byte) (o []byte, err error)
- func (z MetricDataArray) Msgsize() (s int)
- func (z *MetricDataArray) UnmarshalMsg(bts []byte) (o []byte, err error)
- type MetricDefinition
- func (m *MetricDefinition) Clone() MetricDefinition
- func (z *MetricDefinition) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *MetricDefinition) EncodeMsg(en *msgp.Writer) (err error)
- func (z *MetricDefinition) MarshalMsg(b []byte) (o []byte, err error)
- func (z *MetricDefinition) Msgsize() (s int)
- func (m *MetricDefinition) NameSanitizedAsTagValue() string
- func (m *MetricDefinition) NameWithTags() string
- func (m *MetricDefinition) PartitionID(method PartitionByMethod, partitions int32) (int32, error)
- func (m *MetricDefinition) SetId()
- func (z *MetricDefinition) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (m *MetricDefinition) Validate() error
- type MetricPoint
- func (m *MetricPoint) Marshal(b []byte) (o []byte, err error)
- func (m *MetricPoint) Marshal32(b []byte) (o []byte, err error)
- func (m *MetricPoint) MarshalWithoutOrg(b []byte) (o []byte, err error)
- func (m *MetricPoint) MarshalWithoutOrg28(b []byte) (o []byte, err error)
- func (m *MetricPoint) Unmarshal(bts []byte) (o []byte, err error)
- func (m *MetricPoint) UnmarshalWithoutOrg(bts []byte) (o []byte, err error)
- func (m *MetricPoint) Valid() bool
- type PartitionByMethod
- type PartitionedMetric
- type Point
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidEmptyName = errors.New("name cannot be empty")
var ErrInvalidFormat = errors.New("invalid format")
var ErrInvalidInput = errors.New("invalid input")
var ErrInvalidIntervalzero = errors.New("interval cannot be 0")
var ErrInvalidMtype = errors.New("invalid mtype")
var ErrInvalidOrgIdzero = errors.New("org-id cannot be 0")
var ErrStringTooShort = errors.New("string too short")
var ErrUnknownPartitionMethod = errors.New("unknown partition method")
Functions ¶
func EatDots ¶
EatDots removes multiple consecutive, leading, and trailing dots from name. If the provided name is only dots, it will return an empty string The vast majority of names will not need to be modified, so we optimize for that case. This function only requires allocations if the name does need to be modified.
func IsSpanValid ¶
func Reslice ¶
func Reslice(in []*MetricData, size int) [][]*MetricData
Reslice reslices a slice into smaller slices of the given max size.
func SanitizeNameAsTagValue ¶
SanitizeNameAsTagValue takes a name and potentially modifies it to ensure it is a valid value that can be used as a tag value. This is important when we index metric names as values of the tag "name"
func ValidateTag ¶
func ValidateTagKey ¶
ValidateTagKey validates tag key requirements as defined in graphite docs
func ValidateTagValue ¶
ValidateTagValue is the same as the above ValidateTagKey, but for the tag value
func ValidateTags ¶
ValidateTags returns whether all tags are in a valid format. a valid format is anything that looks like key=value, the length of key and value must be >0 and both cannot contain the certain prohibited characters
Types ¶
type AMKey ¶
AMKey is a multi-tenant key with archive extension so you can refer to rollup archives
func AMKeyFromString ¶
type Archive ¶
type Archive uint16
Archive represents a metric archive the zero value represents a raw metric any non-zero value represents a certain aggregation method (lower 8 bits) and aggregation span (higher 8 bits)
func ArchiveFromString ¶
func NewArchive ¶
important: caller must make sure to call IsSpanValid first
func (Archive) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Archive) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
type Key ¶
type Key [16]byte
Key identifies a metric
func (*Key) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type MKey ¶
MKey uniquely identifies a metric in a multi-tenant context
func MKeyFromString ¶
KeyFromString parses a string id to an MKey string id must be of form orgid.<hexadecimal 128bit hash>
func (*MKey) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type MetricData ¶
type MetricData struct { Id string `json:"id"` OrgId int `json:"org_id"` Name string `json:"name"` Interval int `json:"interval"` Value float64 `json:"value"` Unit string `json:"unit"` Time int64 `json:"time"` Mtype string `json:"mtype"` Tags []string `json:"tags"` }
MetricData contains all metric metadata (some as fields, some as tags) and a datapoint
func (*MetricData) DecodeMsg ¶
func (z *MetricData) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*MetricData) EncodeMsg ¶
func (z *MetricData) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*MetricData) MarshalMsg ¶
func (z *MetricData) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*MetricData) Msgsize ¶
func (z *MetricData) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*MetricData) PartitionID ¶
func (m *MetricData) PartitionID(method PartitionByMethod, partitions int32) (int32, error)
func (*MetricData) SetId ¶
func (m *MetricData) SetId()
returns a id (hash key) in the format OrgId.md5Sum the md5sum is a hash of the the concatenation of the metric + each tag key:value pair (in metrics2.0 sense, so also fields), sorted alphabetically.
func (*MetricData) UnmarshalMsg ¶
func (z *MetricData) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
func (*MetricData) Validate ¶
func (m *MetricData) Validate() error
type MetricDataArray ¶
type MetricDataArray []*MetricData
can be used by some encoders, such as msgp
func (*MetricDataArray) DecodeMsg ¶
func (z *MetricDataArray) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (MetricDataArray) EncodeMsg ¶
func (z MetricDataArray) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (MetricDataArray) MarshalMsg ¶
func (z MetricDataArray) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (MetricDataArray) Msgsize ¶
func (z MetricDataArray) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*MetricDataArray) UnmarshalMsg ¶
func (z *MetricDataArray) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type MetricDefinition ¶
type MetricDefinition struct { Id MKey `json:"mkey"` OrgId uint32 `json:"org_id"` Name string `json:"name"` Interval int `json:"interval"` Unit string `json:"unit"` Mtype string `json:"mtype"` // some users of MetricDefinition (f.e. MetricTank) might add a "name" tag // to this slice which allows querying by name as a tag. this special tag // should not be stored or transmitted over the network, otherwise it may // just get overwritten by the receiver. Tags []string `json:"tags"` LastUpdate int64 `json:"lastUpdate"` // unix timestamp Partition int32 `json:"partition"` // contains filtered or unexported fields }
func MetricDefinitionFromMetricData ¶
func MetricDefinitionFromMetricData(d *MetricData) *MetricDefinition
MetricDefinitionFromMetricData yields a MetricDefinition that has no references to the original MetricData
func (*MetricDefinition) Clone ¶
func (m *MetricDefinition) Clone() MetricDefinition
Clone() returns a copy of the MetricDefinition. It uses atomic operations to read certain properties that get updated atomically
func (*MetricDefinition) DecodeMsg ¶
func (z *MetricDefinition) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*MetricDefinition) EncodeMsg ¶
func (z *MetricDefinition) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*MetricDefinition) MarshalMsg ¶
func (z *MetricDefinition) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*MetricDefinition) Msgsize ¶
func (z *MetricDefinition) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*MetricDefinition) NameSanitizedAsTagValue ¶
func (m *MetricDefinition) NameSanitizedAsTagValue() string
func (*MetricDefinition) NameWithTags ¶
func (m *MetricDefinition) NameWithTags() string
NameWithTags deduplicates the name and tags strings by storing their content as a single string in .nameWithTags and then makes .Name and the .Tags slices of it. Once this has been done it won't do it a second time, but just reuse the already generated .nameWithTags. It returns the deduplicated name with tags.
func (*MetricDefinition) PartitionID ¶
func (m *MetricDefinition) PartitionID(method PartitionByMethod, partitions int32) (int32, error)
func (*MetricDefinition) SetId ¶
func (m *MetricDefinition) SetId()
func (*MetricDefinition) UnmarshalMsg ¶
func (z *MetricDefinition) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
func (*MetricDefinition) Validate ¶
func (m *MetricDefinition) Validate() error
type MetricPoint ¶
MetricPoint is a simple way to represent a point of a metric it can be serialized/deserialized with and without the Org field of the key.
func (*MetricPoint) Marshal ¶
func (m *MetricPoint) Marshal(b []byte) (o []byte, err error)
Marshal marshals the MetricPoint
func (*MetricPoint) Marshal32 ¶
func (m *MetricPoint) Marshal32(b []byte) (o []byte, err error)
Marshal32 marshals the MetricPoint directly to b. b must have a cap-len difference of at least 32 bytes.
func (*MetricPoint) MarshalWithoutOrg ¶
func (m *MetricPoint) MarshalWithoutOrg(b []byte) (o []byte, err error)
MarshalWithoutOrg marshals in a non-multi-tenancy aware way
func (*MetricPoint) MarshalWithoutOrg28 ¶
func (m *MetricPoint) MarshalWithoutOrg28(b []byte) (o []byte, err error)
MarshalWithoutOrg28 marshals directly to b in a non-multi-tenancy aware way b must have a cap-len difference of at least 28 bytes.
func (*MetricPoint) Unmarshal ¶
func (m *MetricPoint) Unmarshal(bts []byte) (o []byte, err error)
Unmarshal unmarshals the MetricPoint
func (*MetricPoint) UnmarshalWithoutOrg ¶
func (m *MetricPoint) UnmarshalWithoutOrg(bts []byte) (o []byte, err error)
UnmarshalWithoutOrg unmarshals in a non-multi-tenancy aware way
func (*MetricPoint) Valid ¶
func (m *MetricPoint) Valid() bool
type PartitionByMethod ¶
type PartitionByMethod uint8
const ( // partition by organization id only PartitionByOrg PartitionByMethod = iota // partition by the metric name only PartitionBySeries // partition by metric name and tags, with the best distribution // recommended for new deployments. PartitionBySeriesWithTags // partition by metric name and tags, with a sub-optimal distribution when using tags. // compatible with PartitionBySeries if a metric has no tags, // making it possible to adopt tags for existing PartitionBySeries deployments without a migration. PartitionBySeriesWithTagsFnv )
func PartitonMethodFromString ¶
func PartitonMethodFromString(input string) (PartitionByMethod, error)
type PartitionedMetric ¶
type PartitionedMetric interface { Validate() error SetId() // PartitionID returns the partition id that should be used for this metric. PartitionID(method PartitionByMethod, partitions int32) (int32, error) }
type Point ¶
func (Point) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler