Documentation
¶
Overview ¶
Package telemetry is the framework's OpenTelemetry integration.
The framework instruments execution boundaries, not business code: HTTP requests, scheduled jobs, queue attempts, and event handlers. Business code can use Start or Run for any function and gets the same provider, propagator, resource, error recording, and shutdown behavior.
Exporters remain pluggable. Services may provide any OpenTelemetry SDK exporter through Config, or supply their own providers when they need more advanced sampling, views, or multiple pipelines.
Index ¶
- Constants
- func Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
- func Inject(ctx context.Context, carrier propagation.TextMapCarrier)
- func RecordError(span trace.Span, err error)
- func Run(ctx context.Context, name string, fn func(context.Context) error, ...) error
- func Start(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- type Config
- type OTLPConfig
- type Telemetry
Constants ¶
const InstrumentationName = "github.com/IncepTools/go"
InstrumentationName is the stable scope used by framework spans and meters.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
func Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
Extract reads a propagated span context from an inbound carrier.
func Inject ¶
func Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject writes the current span context into an outbound carrier. Use it for HTTP, messaging, or any other transport that supports a text map.
func RecordError ¶
RecordError applies the OpenTelemetry error convention. Cancellation during a normal shutdown is not marked as an application failure.
Types ¶
type Config ¶
type Config struct {
ServiceName string
ServiceVersion string
// OTLP enables the standard OTLP/HTTP exporters when an endpoint is
// configured explicitly or through OTEL_EXPORTER_OTLP_* environment
// variables. It is deliberately opt-in by endpoint: New never attempts to
// connect to localhost just because telemetry was enabled.
OTLP OTLPConfig
SpanExporter sdktrace.SpanExporter
MetricReader sdkmetric.Reader
TracerProvider trace.TracerProvider
MeterProvider metric.MeterProvider
Propagator propagation.TextMapPropagator
}
Config configures the built-in providers. SpanExporter and MetricReader are optional SDK hooks; custom providers take precedence when supplied.
type OTLPConfig ¶
type OTLPConfig struct {
Endpoint string
TracesEndpoint string
MetricsEndpoint string
Headers map[string]string
Insecure bool
Timeout time.Duration
}
OTLPConfig is the small, vendor-neutral configuration surface shared by SigNoz, an OpenTelemetry Collector, Elastic APM, Jaeger, Grafana, Honeycomb, and other OTLP-compatible backends. Signal-specific endpoints override the common endpoint. Standard OTEL_* environment variables are also honored by the exporters.
type Telemetry ¶
type Telemetry struct {
// contains filtered or unexported fields
}
Telemetry owns providers created by New and flushes them during shutdown.
func New ¶
New creates providers, installs them as the process globals, and returns a lifecycle-ready telemetry component. The default SDK providers are active even without exporters; instrumentation call sites never change when an exporter or backend is added.
func (*Telemetry) Middleware ¶
Middleware creates automatic HTTP spans, context extraction, and standard request metrics. It is safe to install alongside the framework request-ID middleware; request IDs remain available to logs while OTel owns trace IDs.