Documentation
¶
Overview ¶
Package telemetry contains code that emits telemetry (logging, metrics, tracing).
Index ¶
- func ContextWithRPCInfo(ctx context.Context, rpcInfo RPCInfo) context.Context
- func MustNewTracerProvider(opts ...TracerOption) *sdktrace.TracerProvider
- func ParseOTLPEndpoint(endpoint string) (string, bool)
- func ResolveOTLPSecurity(configSecure, schemeSecure bool) bool
- func TraceError(span trace.Span, err error)
- type RPCInfo
- type TracerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithRPCInfo ¶
ContextWithRPCInfo will save the rpc method and service information in context.
func MustNewTracerProvider ¶
func MustNewTracerProvider(opts ...TracerOption) *sdktrace.TracerProvider
func ParseOTLPEndpoint ¶ added in v1.12.1
ParseOTLPEndpoint strips the scheme from an endpoint string that may contain a URI (e.g. "http://host:4317"). The OTEL_EXPORTER_OTLP_ENDPOINT env var uses full URIs per the OpenTelemetry spec, but the gRPC exporter's WithEndpoint expects a bare authority (host or host:port).
For http/https URIs the authority (u.Host) is returned, which may or may not include a port. For non-http(s) schemes or bare host:port inputs the string is returned unchanged.
The second return value indicates whether the scheme specifies TLS (true for https://, false otherwise). Use ResolveOTLPSecurity to combine this with the configured TLS flag.
func ResolveOTLPSecurity ¶ added in v1.12.1
ResolveOTLPSecurity returns true if TLS should be used for the OTLP connection. TLS is enabled if either the configuration flag or the URI scheme (https://) indicates it.
func TraceError ¶
TraceError marks the span as having an error, except if the error is context.Canceled, in which case it does nothing.
Types ¶
type RPCInfo ¶
func RPCInfoFromContext ¶
RPCInfoFromContext returns method and service stored in context.
type TracerOption ¶
type TracerOption func(d *customTracer)
func WithAttributes ¶
func WithAttributes(attrs ...attribute.KeyValue) TracerOption
func WithOTLPEndpoint ¶
func WithOTLPEndpoint(endpoint string) TracerOption
func WithOTLPInsecure ¶
func WithOTLPInsecure() TracerOption
func WithSamplingRatio ¶
func WithSamplingRatio(samplingRatio float64) TracerOption