traceutil

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Overview

Package traceutil contains functions for extracting and processing traces. It should only import payload and nothing else.

Index

Constants

View Source
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"
)
View Source
const (
	// MaxNameLen the maximum length a name can have
	MaxNameLen = 100
	// MaxServiceLen the maximum length a service can have
	MaxServiceLen = 100
)
View Source
const (
	// MaxMetaKeyLen the maximum length of metadata key
	MaxMetaKeyLen = 200
	// MaxMetaValLen the maximum length of metadata value
	MaxMetaValLen = 25000
	// MaxMetricsKeyLen the maximum length of a metric name key
	MaxMetricsKeyLen = MaxMetaKeyLen
)

Variables

View Source
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")
)
View Source
var MaxResourceLen = 5000

MaxResourceLen the maximum length the resource can have

Functions

func ChildrenMap

func ChildrenMap(t pb.Trace) map[uint64][]*pb.Span

ChildrenMap returns a map containing for each span id the list of its direct children.

func ComputeTopLevel

func ComputeTopLevel(t pb.Trace)

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 GetAppVersion

func GetAppVersion(root *pb.Span, t *pb.TraceChunk) string

GetAppVersion returns the first "version" tag found in trace t. Search starts by root

func GetEnv

func GetEnv(root *pb.Span, t *pb.TraceChunk) string

GetEnv returns the first "env" tag found in trace t. Search starts by root

func GetMeta

func GetMeta(s *pb.Span, key string) (string, bool)

GetMeta gets the metadata value in the span Meta map.

func GetMetaDefault

func GetMetaDefault(s *pb.Span, key, fallback string) string

GetMetaDefault gets the metadata value in the span Meta map and fallbacks to fallback.

func GetMetaStruct

func GetMetaStruct(s *pb.Span, key string) (interface{}, bool)

GetMetaStruct gets the structured metadata value in the span MetaStruct map.

func GetRoot

func GetRoot(t pb.Trace) *pb.Span

GetRoot extracts the root span from a trace

func HasTopLevel

func HasTopLevel(s *pb.Span) bool

HasTopLevel returns true if span is top-level.

func IsMeasured

func IsMeasured(s *pb.Span) bool

IsMeasured returns true if a span should be measured (i.e., it should get trace metrics calculated).

func IsPartialSnapshot

func IsPartialSnapshot(s *pb.Span) bool

IsPartialSnapshot returns true if the span is a partial snapshot. This kind of spans are partial images of long-running spans. When incomplete, a partial snapshot has a metric _dd.partial_version which is a positive integer. The metric usually increases each time a new version of the same span is sent by the tracer

func NormalizeName

func NormalizeName(name string) (string, error)

NormalizeName normalizes a span name and returns an error describing the reason (if any) why the name was modified.

func NormalizeService

func NormalizeService(svc string, lang string) (string, error)

NormalizeService normalizes a span service and returns an error describing the reason (if any) why the name was modified.

func NormalizeTag

func NormalizeTag(v string) string

NormalizeTag applies some normalization to ensure the tags match the backend requirements.

func SetMeta

func SetMeta(s *pb.Span, key, val string)

SetMeta sets the metadata at key to the val on the span s.

func SetMetaStruct

func SetMetaStruct(s *pb.Span, key string, val interface{}) error

SetMetaStruct sets the structured metadata at key to the val on the span s.

func SetMetric

func SetMetric(s *pb.Span, key string, val float64)

SetMetric sets the metric at key to the val on the span s.

func SetTopLevel

func SetTopLevel(s *pb.Span, topLevel bool)

SetTopLevel sets the top-level attribute of the span.

func TruncateResource

func TruncateResource(r string) (string, bool)

TruncateResource truncates a span's resource to the maximum allowed length. It returns true if the input was below the max size.

func TruncateUTF8

func TruncateUTF8(s string, limit int) string

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

func UpdateTracerTopLevel(s *pb.Span)

UpdateTracerTopLevel sets _top_level tag on spans flagged by the tracer

Types

type ProcessedTrace

type ProcessedTrace struct {
	TraceChunk             *pb.TraceChunk
	Root                   *pb.Span
	TracerEnv              string
	AppVersion             string
	TracerHostname         string
	ClientDroppedP0sWeight float64
}

ProcessedTrace represents a trace being processed in the agent.

Jump to

Keyboard shortcuts

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