Documentation ¶
Overview ¶
Package traceutil contains functions for extracting and processing traces. It should only import payload and nothing else.
Index ¶
- Constants
- Variables
- func APITrace(t pb.Trace) *pb.APITrace
- func ChildrenMap(t pb.Trace) map[uint64][]*pb.Span
- func ComputeTopLevel(t pb.Trace)
- func GetEnv(t pb.Trace) string
- func GetMeta(s *pb.Span, key string) (string, bool)
- func GetMetaDefault(s *pb.Span, key, fallback string) string
- func GetRoot(t pb.Trace) *pb.Span
- func HasTopLevel(s *pb.Span) bool
- func IsMeasured(s *pb.Span) bool
- func NormalizeName(name string) (string, error)
- func NormalizeService(svc string, lang string) (string, error)
- func NormalizeTag(v string) string
- func SetMeta(s *pb.Span, key, val string)
- func SetMetric(s *pb.Span, key string, val float64)
- func SetTopLevel(s *pb.Span, topLevel bool)
- func TruncateResource(r string) (string, bool)
- func TruncateUTF8(s string, limit int) string
- func UpdateTracerTopLevel(s *pb.Span)
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 )
const ( // MaxMetaKeyLen the maximum length of metadata key MaxMetaKeyLen = 200 // MaxMetaValLen the maximum length of metadata value MaxMetaValLen = 5000 // MaxMetricsKeyLen the maximum length of a metric name key MaxMetricsKeyLen = MaxMetaKeyLen )
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 MaxResourceLen = 5000
MaxResourceLen the maximum length the resource can have
Functions ¶
func APITrace ¶
APITrace returns an APITrace from t, as required by the Datadog API. It also returns an estimated size in bytes.
func ChildrenMap ¶
ChildrenMap returns a map containing for each span id the list of its direct children.
func ComputeTopLevel ¶
ComputeTopLevel updates all the spans top-level attribute.
A span is considered top-level if:
- it's a root span
- its parent is unknown (other part of the code, distributed trace)
- its parent belongs to another service (in that case it's a "local root" being the highest ancestor of other spans belonging to this service and attached to it).
func GetMetaDefault ¶
GetMetaDefault gets the metadata value in the span Meta map and fallbacks to fallback.
func IsMeasured ¶
IsMeasured returns true if a span should be measured (i.e., it should get trace metrics calculated).
func NormalizeName ¶
NormalizeName normalizes a span name 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 tags match the backend requirements.
func SetTopLevel ¶
SetTopLevel sets the top-level attribute of the span.
func TruncateResource ¶
TruncateResource truncates a span's resource to the maximum allowed length. It returns true if the input was below the max size.
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.
func UpdateTracerTopLevel ¶
UpdateTracerTopLevel sets _top_level tag on spans flagged by the tracer
Types ¶
This section is empty.