telemetry

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package telemetry contains code that emits telemetry (logging, metrics, tracing).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithRPCInfo

func ContextWithRPCInfo(ctx context.Context, rpcInfo RPCInfo) context.Context

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

func ParseOTLPEndpoint(endpoint string) (string, bool)

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

func ResolveOTLPSecurity(configSecure, schemeSecure bool) bool

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

func TraceError(span trace.Span, err error)

TraceError marks the span as having an error, except if the error is context.Canceled, in which case it does nothing.

Types

type RPCInfo

type RPCInfo struct {
	Method  string
	Service string
}

func RPCInfoFromContext

func RPCInfoFromContext(ctx context.Context) RPCInfo

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

Jump to

Keyboard shortcuts

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