utils

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OTelProtocolGRPC configures OTLP exporters to use gRPC protocol.
	OTelProtocolGRPC = "grpc"
	// OTelProtocolHTTP configures OTLP exporters to use HTTP protocol.
	OTelProtocolHTTP = "http"

	// OTelExporterOTLP configures signals to export via OTLP.
	OTelExporterOTLP = "otlp"
	// OTelExporterNone disables exporting for a signal.
	OTelExporterNone = "none"
)

Variables

This section is empty.

Functions

func SetupOTelSDK

func SetupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error)

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

func SetupOTelSDKWithConfig

func SetupOTelSDKWithConfig(ctx context.Context, cfg OTelConfig) (shutdown func(context.Context) error, err error)

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

Types

type OTelConfig

type OTelConfig struct {
	// ServiceName is the name of the service for resource identification.
	// Env: OTEL_SERVICE_NAME (default: "lfx-v2-access-check")
	ServiceName string
	// ServiceVersion is the version of the service.
	// Env: OTEL_SERVICE_VERSION
	ServiceVersion string
	// Protocol specifies the OTLP protocol to use: "grpc" or "http".
	// Env: OTEL_EXPORTER_OTLP_PROTOCOL (default: "grpc")
	Protocol string
	// Endpoint is the OTLP collector endpoint.
	// For gRPC: typically "localhost:4317"
	// For HTTP: typically "localhost:4318"
	// Env: OTEL_EXPORTER_OTLP_ENDPOINT
	Endpoint string
	// Insecure disables TLS for the connection.
	// Env: OTEL_EXPORTER_OTLP_INSECURE (set to "true" for insecure connections)
	Insecure bool
	// TracesExporter specifies the traces exporter: "otlp" or "none".
	// Env: OTEL_TRACES_EXPORTER (default: "none")
	TracesExporter string
	// TracesSampleRatio specifies the sampling ratio for traces (0.0 to 1.0).
	// A value of 1.0 means all traces are sampled, 0.5 means 50% are sampled.
	// Env: OTEL_TRACES_SAMPLE_RATIO (default: 1.0)
	TracesSampleRatio float64
	// MetricsExporter specifies the metrics exporter: "otlp" or "none".
	// Env: OTEL_METRICS_EXPORTER (default: "none")
	MetricsExporter string
	// LogsExporter specifies the logs exporter: "otlp" or "none".
	// Env: OTEL_LOGS_EXPORTER (default: "none")
	LogsExporter string
	// Propagators specifies the context propagators to use.
	// Comma-separated list: "tracecontext", "baggage", "jaeger".
	// Env: OTEL_PROPAGATORS (default: "tracecontext,baggage")
	Propagators string
}

OTelConfig holds OpenTelemetry configuration options.

func OTelConfigFromEnv

func OTelConfigFromEnv() OTelConfig

OTelConfigFromEnv creates an OTelConfig from environment variables. See OTelConfig struct fields for supported environment variables.

Jump to

Keyboard shortcuts

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