Documentation ¶
Overview ¶
Package gtrace provides convenience wrapping functionality for tracing feature using OpenTelemetry.
Index ¶
- func CheckSetDefaultTextMapPropagator()
- func CommonLabels() []attribute.KeyValue
- func GetBaggageMap(ctx context.Context) *gmap.StrAnyMap
- func GetBaggageVar(ctx context.Context, key string) *gvar.Var
- func GetDefaultTextMapPropagator() propagation.TextMapPropagator
- func GetSpanID(ctx context.Context) string
- func GetTraceID(ctx context.Context) string
- func IsTracingInternal() bool
- func IsUsingDefaultProvider() bool
- func MaxContentLogSize() int
- func SafeContent(data []byte) string
- func SafeContentForHttp(data []byte, header http.Header) (string, error)
- func SetBaggageMap(ctx context.Context, data map[string]interface{}) context.Context
- func SetBaggageValue(ctx context.Context, key string, value interface{}) context.Context
- func WithTraceID(ctx context.Context, traceID string) (context.Context, error)
- func WithUUID(ctx context.Context, uuid string) (context.Context, error)
- type Baggage
- type Carrier
- type Span
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSetDefaultTextMapPropagator ¶
func CheckSetDefaultTextMapPropagator()
CheckSetDefaultTextMapPropagator sets the default TextMapPropagator if it is not set previously.
func CommonLabels ¶
CommonLabels returns common used attribute labels: ip.intranet, hostname.
func GetBaggageMap ¶
GetBaggageMap retrieves and returns the baggage values as map.
func GetBaggageVar ¶
GetBaggageVar retrieves value and returns a *gvar.Var for specified key from baggage.
func GetDefaultTextMapPropagator ¶
func GetDefaultTextMapPropagator() propagation.TextMapPropagator
GetDefaultTextMapPropagator returns the default propagator for context propagation between peers.
func GetSpanID ¶
GetSpanID retrieves and returns SpanId from context. It returns an empty string is tracing feature is not activated.
func GetTraceID ¶
GetTraceID retrieves and returns TraceId from context. It returns an empty string is tracing feature is not activated.
func IsTracingInternal ¶
func IsTracingInternal() bool
IsTracingInternal returns whether tracing spans of internal components.
func IsUsingDefaultProvider ¶
func IsUsingDefaultProvider() bool
IsUsingDefaultProvider checks and return if currently using default trace provider.
func MaxContentLogSize ¶
func MaxContentLogSize() int
MaxContentLogSize returns the max log size for request and response body, especially for HTTP/RPC request.
func SafeContent ¶
SafeContent cuts and returns given content by `MaxContentLogSize`. It appends string `...` to the tail of the result if the content size is greater than `MaxContentLogSize`.
func SafeContentForHttp ¶
SafeContentForHttp cuts and returns given content by `MaxContentLogSize`. It appends string `...` to the tail of the result if the content size is greater than `MaxContentLogSize`.
func SetBaggageMap ¶
SetBaggageMap is a convenient function for adding map key-value pairs to baggage. Note that it uses attribute.Any to set the key-value pair.
func SetBaggageValue ¶
SetBaggageValue is a convenient function for adding one key-value pair to baggage. Note that it uses attribute.Any to set the key-value pair.
func WithTraceID ¶
WithTraceID injects custom trace id into context to propagate.
Types ¶
type Baggage ¶
type Baggage struct {
// contains filtered or unexported fields
}
Baggage holds the data through all tracing spans.
func NewBaggage ¶
NewBaggage creates and returns a new Baggage object from given tracing context.
func (*Baggage) GetVar ¶
GetVar retrieves value and returns a *gvar.Var for specified key from baggage.
type Carrier ¶
type Carrier map[string]interface{}
Carrier is the storage medium used by a TextMapPropagator.
func NewCarrier ¶
NewCarrier creates and returns a Carrier.
func (Carrier) MustMarshal ¶
MustMarshal .returns the JSON encoding of c
func (Carrier) UnmarshalJSON ¶
UnmarshalJSON implements interface UnmarshalJSON for package json.