otel_util

package
v0.0.0-...-5f0dc1b Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: CC0-1.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OTEL_HOSTNAME            = "OTEL_HOSTNAME"
	OTEL_PROTOCOL            = "OTEL_PROTOCOL"
	OTEL_PORT                = "OTEL_PORT"
	OTEL_ENABLED             = "OTEL_ENABLED"
	OTEL_SERVICE_NAME        = "OTEL_SERVICE_NAME"
	OTEL_TRACE_SAMPLING_RATE = "OTEL_TRACE_SAMPLING_RATE"
)

Variables

This section is empty.

Functions

func AddSpanEvent

func AddSpanEvent(span trace.Span, event string)

func AddSpanEventWithOption

func AddSpanEventWithOption(span trace.Span, event string, options trace.SpanStartEventOption)

func IsOTelEnabled

func IsOTelEnabled() bool

func ParseFullMethod

func ParseFullMethod(fullMethod string) (string, []attribute.KeyValue)

ParseFullMethod returns a span name following the OpenTelemetry semantic conventions as well as all applicable span attribute.KeyValue attributes based on a gRPC's FullMethod.

Parsing is consistent with grpc-go implementation: https://github.com/grpc/grpc-go/blob/v1.57.0/internal/grpcutil/method.go#L26-L39

func PeerAttr

func PeerAttr(addr string) []attribute.KeyValue

peerAttr returns attributes about the peer address.

func PeerFromCtx

func PeerFromCtx(ctx context.Context) string

peerFromCtx returns a peer address from a context, if one exists.

func SetSpanStatus

func SetSpanStatus(span trace.Span, code codes2.Code, statusMessage string)

func SetupOTelSDK

func SetupOTelSDK(ctx context.Context, serviceName, serviceVersion string) (shutdown func(context.Context) error, err error, meterProvider *metric.MeterProvider, tracerProvider *trace.TracerProvider)

setupOTelSDK bootstraps the OpenTelemetry pipeline. If it does not return an error, make sure to call shutdown for proper cleanup.

func StartClientSpan

func StartClientSpan(ctx context.Context, tracer trace.Tracer, serviceName string, connectionTarget string) (context.Context, trace.Span)

func StartServerSpanFromClientContext

func StartServerSpanFromClientContext(ctx context.Context, tracer trace.Tracer, serviceNames string, spanKind trace.SpanKind) (trace.SpanContext, context.Context, trace.Span)

func TelemetryAttributes

func TelemetryAttributes(fullMethod, peerAddress string) (string, []attribute.KeyValue, []attribute.KeyValue)

telemetryAttributes returns a span name and span and metric attributes from the gRPC method and peer address.

Types

type OTELConfig

type OTELConfig struct {
	// contains filtered or unexported fields
}

func NewOTELConfig

func NewOTELConfig() *OTELConfig

func (*OTELConfig) GetOTELEndpoint

func (o *OTELConfig) GetOTELEndpoint() string

Jump to

Keyboard shortcuts

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