Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var OtelEnabled = false
OtelEnabled tells if OpenTelemetry tracing was activated. If OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is set, then tracing is activated automatically. You may set OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG to set the sampling type and fraction. You may fine-tune batch exporting parameters with OTEL_BSP_* environment variables. See also
Functions ¶
func GetOTel ¶
func GetOTel() bool
GetOTel returns if Open Telemetry is enabled. It may be enabled automatically if OTEL_ environment variables are set.
func SetOTel ¶
func SetOTel(enabled bool, tp *sdktrace.TracerProvider)
SetOTel enables/disables Open Telemetry. Tracer provider can be set with an exporter and collector endpoint you need.
func SetOTelGrpc ¶ added in v1.7.3
SetOTelGrpc enables Open Telemetry. Activates trace export to the OTLP gRPC collector target address defined. Port is 4317, unless defined otherwise in provided target string. E.g. "http://localhost:4317".
Fraction tells the fraction of spans to report, unless the parent is sampled.
- Zero means no sampling.
- Greater or equal 1 means sampling all the messages.
- Else the sampling fraction, e.g. 0.01 for 1%.
Types ¶
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is a HTTP trace handler of various kinds.
func NewFromRequest ¶
NewFromRequest creates new tracer object from request. Returns nil if not found.
func NewFromRequestOrRandom ¶
NewFromRequestOrRandom creates new tracer object. If no trace data, then create random. Never returns nil.
Warning: Does not return trace from request context.
func NewFromRequestWithContext ¶ added in v1.9.0
NewFromRequestWithContext creates new tracer object from request derived from parentCtx if otel. Returns nil if not found.
func (*Tracer) IsReceived ¶
IsReceived tells whether trace data was received (parsed from a request) or a random one.
func (*Tracer) SetHeader ¶
SetHeader sets request headers according to the trace data. Input headers object must not be nil.
func (*Tracer) Span ¶
Span spans the existing trace data and puts that into the request. Returns the updated request and a trace string for logging. Does not change the input trace data.