Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var OtelEnabled = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") != "" || os.Getenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") != ""
OtelEnabled tells if OpenTelemetry tracing was activated. You may set that directly or use OTEL_ environment variables for settings. See https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/ If OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is set, then tracing is activated automatically.
Functions ¶
func SetOTel ¶
func SetOTel(enabled bool, tp *sdktrace.TracerProvider)
SetOTel enables/disables Open Telemetry. By default it is disabled. 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.
Fraction tells the fraction of spans to report, unless parent is sampled.
- Less or equal 0 means no sampling, unless parent is sampled.
- Greater or equal 1 means always sampled.
- 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.