otelutil

package
v0.32.13 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: Unlicense Imports: 17 Imported by: 0

Documentation

Overview

Package otelutil contains common utilities for working with OpenTelemetry.

Index

Constants

View Source
const (
	ExporterProtoGRPC         = "grpc"
	ExporterProtoHTTPProtobuf = "http/protobuf"
	ExporterProtoStdout       = "stdout"
)

Supported OpenTelemetry exporter protocols that are expected to be present in the environment under EnvExporterProto.

View Source
const EnvExporterProto = "OTEL_EXPORTER_OTLP_PROTOCOL"

EnvExporterProto is the name of the environment variable holding the OpenTelemetry exporter protocol.

See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/.

Variables

This section is empty.

Functions

func EndSpan

func EndSpan(span trace.Span, err error)

EndSpan is a deferred helper that records the error sets the status of the span before ending it.

func Init

func Init(ctx context.Context, c *Config) (svc service.Interface, err error)

Init initializes the global OpenTelemetry infrastructure. svc is the service that should be shut down on exit. c must be valid.

TODO(a.garipov): See if there are ways to not use globals.

func StartSpanf

func StartSpanf(
	parent context.Context,
	tracer trace.Tracer,
	spanNameFmt string,
	args ...any,
) (ctx context.Context, span trace.Span)

StartSpanf is a helper for formatted span names.

Types

type Config

type Config struct {
	// ServiceName is the name to use for exporting traces.  It must not be
	// empty.
	ServiceName string
}

Config is the configuration structure for the OpenTelemetry infrastructure.

func (*Config) Validate

func (c *Config) Validate() (err error)

Validate implements the validate.Interface for *Config. c may be nil.

Jump to

Keyboard shortcuts

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