trace

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const IDKey traceIDKey = 0

IDKey is the key that references the trace ID inside context.

View Source
const SpanIDKey spanIDKey = 0

SpanIDKey is the key that references the span ID inside context.

Variables

View Source
var DefaultGenerator = defaultIDGenerator()

DefaultGenerator is the default trace ID and span ID generator.

Functions

func Context

func Context(ctx context.Context, traceID ID, spanID SpanID) context.Context

Context adds a trace ID and span ID to the current context.

Types

type ID

type ID [16]byte

ID is the unique identifier for an entire trace.

func ParseID

func ParseID(value string) (ID, error)

ParseID returns a trace ID from a hexadecimal string if it meets the W3C specification. See more at: https://www.w3.org/TR/trace-context/#trace-id

func TryGetID

func TryGetID(ctx context.Context) (ID, bool)

TryGetID tries to get a previously saved trace ID.

func (ID) IsValid

func (id ID) IsValid() bool

IsValid checks if the trace ID does not consist of zeros only.

func (ID) String

func (id ID) String() string

String returns the hex string representation of the ID.

type IDGenerator

type IDGenerator interface {
	NewTraceIDs() (ID, SpanID)
	NewSpanID() SpanID
}

IDGenerator allows custom generators for TraceID and SpanID.

type SpanID

type SpanID [8]byte

SpanID is the unique identifier for a span of a trace.

func ParseGoogleCloudSpanID

func ParseGoogleCloudSpanID(value string) (SpanID, error)

ParseGoogleCloudSpanID returns a span ID from a string holding an unsigned int64 value.

func ParseOpenTelemetrySpanID

func ParseOpenTelemetrySpanID(value string) (SpanID, error)

ParseOpenTelemetrySpanID returns a span ID from a hexadecimal string if it meets the W3C specification. See more at: https://www.w3.org/TR/trace-context/#parent-id

func TryGetSpanID

func TryGetSpanID(ctx context.Context) (SpanID, bool)

TryGetSpanID tries to get a previously saved span ID.

func (SpanID) Decimal

func (id SpanID) Decimal() uint64

Decimal returns the decimal representation of the ID.

func (SpanID) IsValid

func (id SpanID) IsValid() bool

IsValid checks if the span ID does not consist of zeros only.

func (SpanID) String

func (id SpanID) String() string

String returns the hex string representation of the ID.

Jump to

Keyboard shortcuts

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