Exports OTEL initialization function and adds extensive documentation across packages for improved clarity.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Package otel provides OpenTelemetry initialization and configuration for tracing and metrics.
|
||||
package otel
|
||||
|
||||
import (
|
||||
@@ -39,6 +40,7 @@ var (
|
||||
|
||||
const defMetricInterval = 15 * time.Second
|
||||
|
||||
// Init prepares otel, loading a tracer and meter stored in appp context.
|
||||
// Context must carry config.AppConfig
|
||||
func Init(ctx context.Context) (context.Context, func(context.Context) error) {
|
||||
cfg := config.MustFromCtx(ctx)
|
||||
@@ -232,7 +234,7 @@ func (s *settings) newMeterProvider(ctx context.Context) (*metric.MeterProvider,
|
||||
return meterProvider, nil
|
||||
}
|
||||
|
||||
// Creates a new tracer from the global opentelemetry provider
|
||||
// NewTracer creates a new tracer from the global opentelemetry provider
|
||||
func NewTracer(options ...trace.TracerOption) trace.Tracer {
|
||||
return opentelemetry.GetTracerProvider().Tracer(
|
||||
os.Getenv("OTEL_SERVICE_NAME"),
|
||||
|
Reference in New Issue
Block a user