mtrace

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AttributeHTTPMethod       = "http.method"
	AttributeHTTPUrl          = "http.url"
	AttributeHTTPTarget       = "http.target"
	AttributeHTTPHost         = "http.host"
	AttributeHTTPScheme       = "http.scheme"
	AttributeHTTPStatusCode   = "http.status_code"
	AttributeHTTPStatusText   = "http.status_text"
	AttributeHTTPFlavor       = "http.flavor"
	AttributeHTTPUserAgent    = "http.user_agent"
	AttributeHTTPRequestSize  = "http.request_content_length"
	AttributeHTTPResponseSize = "http.response_content_length"
	AttributeHTTPRoute        = "http.route"
	AttributeHTTPClientIP     = "http.client_ip"
)

Semantic conventions for HTTP.

Variables

This section is empty.

Functions

func CheckSetDefaultTextMapPropagator

func CheckSetDefaultTextMapPropagator()

CheckSetDefaultTextMapPropagator checks if the default TextMapPropagator is set.

func GetBaggageMap

func GetBaggageMap(ctx context.Context) map[string]any

GetBaggageMap gets and returns the map of baggage values.

func GetBaggageVar

func GetBaggageVar(ctx context.Context, key string) *mvar.Var

GetBaggageVar gets and returns the value of the specified key from baggage.

func GetDefaultTextMapPropagator

func GetDefaultTextMapPropagator() propagation.TextMapPropagator

GetDefaultTextMapPropagator returns the default TextMapPropagator for context propagation.

func GetSpanID

func GetSpanID(ctx context.Context) string

GetSpanID gets the span id from the context.

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID gets the trace id from the context.

func IsUsingDefaultProvider

func IsUsingDefaultProvider() bool

IsUsingDefaultProvider checks if the default trace provider is used.

func SetBaggageMap

func SetBaggageMap(ctx context.Context, data map[string]any) context.Context

SetBaggageMap is a convenient function for adding multiple key-value pairs to baggage.

func SetBaggageValue

func SetBaggageValue(ctx context.Context, key string, value any) context.Context

SetBaggageValue is a convenient function for adding a key-value pair to baggage.

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) (context.Context, error)

WithTraceID injects a custom trace id into the context.

func WithUUID

func WithUUID(ctx context.Context, uuid string) (context.Context, error)

WithUUID injects a custom UUID as trace id into the context.

Types

type Baggage

type Baggage struct {
	// contains filtered or unexported fields
}

Baggage is a mechanism for propagating key-value data in a distributed system. It allows attaching custom data (such as user ID, request ID, etc.) to traces and propagating them across service calls.

func NewBaggage

func NewBaggage(ctx context.Context) *Baggage

NewBaggage creates a new Baggage instance.

func (*Baggage) GetMap

func (b *Baggage) GetMap() map[string]interface{}

GetMap gets all baggage values.

func (*Baggage) GetVar

func (b *Baggage) GetVar(key string) *mvar.Var

GetVar gets the baggage value for the specified key.

func (*Baggage) SetMap

func (b *Baggage) SetMap(data map[string]interface{}) context.Context

SetMap sets multiple baggage values.

func (*Baggage) SetValue

func (b *Baggage) SetValue(key string, value interface{}) context.Context

SetValue sets a single baggage value.

type Span

type Span struct {
	trace.Span
}

Span wraps trace.Span to provide compatibility and extensions.

func NewSpan

func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, *Span)

NewSpan creates a span using the default tracer.

type Tracer

type Tracer struct {
	trace.Tracer
}

func NewTracer

func NewTracer(name ...string) *Tracer

NewTracer creates and returns a new tracer.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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