Documentation
¶
Overview ¶
Package normalize contains functions for normalizing trace data.
Index ¶
- Constants
- Variables
- func FixDuration(start, duration int64) (fixed int64, invalid bool)
- func FixStartTime(start, duration int64) (fixed int64, invalid bool)
- func NormalizeName(name string) (string, error)
- func NormalizePeerService(svc string) (string, error)
- func NormalizeService(svc string, lang string) (string, error)
- func NormalizeTag(v string) string
- func NormalizeTagValue(v string) string
- func TruncateUTF8(s string, limit int) string
Constants ¶
const ( // DefaultSpanName is the default name we assign a span if it's missing and we have no reasonable fallback DefaultSpanName = "unnamed_operation" // DefaultServiceName is the default name we assign a service if it's missing and we have no reasonable fallback DefaultServiceName = "unnamed-service" )
const ( // MaxNameLen the maximum length a name can have MaxNameLen = 100 // MaxServiceLen the maximum length a service can have MaxServiceLen = 100 // MaxResourceLen the maximum length a resource can have MaxResourceLen = 5000 )
Variables ¶
var ( // ErrEmpty specifies that the passed input was empty. ErrEmpty = errors.New("empty") // ErrTooLong signifies that the input was too long. ErrTooLong = errors.New("too long") // ErrInvalid signifies that the input was invalid. ErrInvalid = errors.New("invalid") )
var Year2000NanosecTS = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC).UnixNano()
Year2000NanosecTS is an arbitrary cutoff to spot weird-looking start timestamps.
Functions ¶
func FixDuration ¶ added in v0.85.0
FixDuration validates a span duration relative to its start time, returning a corrected value and whether the input was invalid. A negative duration, or one that would overflow when added to start, is reset to 0.
func FixStartTime ¶ added in v0.85.0
FixStartTime validates a span start time, returning a corrected value and whether the input was invalid. A start predating Year2000NanosecTS is considered garbage and reset to "now - duration" (clamped to "now").
func NormalizeName ¶
NormalizeName normalizes a span name and returns an error describing the reason (if any) why the name was modified.
func NormalizePeerService ¶
NormalizePeerService normalizes a span's peer.service and returns an error describing the reason (if any) why the name was modified.
func NormalizeService ¶
NormalizeService normalizes a span service and returns an error describing the reason (if any) why the name was modified.
func NormalizeTag ¶
NormalizeTag applies some normalization to ensure the full tag_key:tag_value string matches the backend requirements.
func NormalizeTagValue ¶
NormalizeTagValue applies some normalization to ensure the tag value matches the backend requirements. It should be used for cases where we have just the tag_value as the input (instead of tag_key:tag_value).
func TruncateUTF8 ¶
TruncateUTF8 truncates the given string to make sure it uses less than limit bytes. If the last character is an utf8 character that would be splitten, it removes it entirely to make sure the resulting string is not broken.
Types ¶
This section is empty.