Documentation
¶
Index ¶
- func ClassifyCtxErr(err error) string
- func EndSpanWithError(span trace.Span, err error)
- func InitOtel(ctx context.Context, opts ...Option) (context.Context, func(context.Context) error, error)
- func IsExpectedError(err error) bool
- func ParentCtxErrLabel(ctx context.Context) (string, bool)
- func StartWithLink(ctx context.Context, tracer trace.Tracer, name string, ...) (context.Context, trace.Span)
- func WithParentCtxErrLabel(ctx context.Context, label string) context.Context
- type Option
- func WithInitialLogFields(ilf map[string]interface{}) Option
- func WithInsecureOtelEndpoint(endpoint string) Option
- func WithLoggingDisabled() Option
- func WithOtelEndpoint(endpoint string, tlsCertPath string, tlsCert string) Option
- func WithServiceName(serviceName string) Option
- func WithTracingDisabled() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyCtxErr ¶ added in v0.10.0
ClassifyCtxErr maps a context error to a low-cardinality enum label suitable for a span attribute: "nil", "canceled", "deadline_exceeded", or "other" for anything that doesn't unwrap to one of the standard context sentinels.
func EndSpanWithError ¶ added in v0.8.22
EndSpanWithError ends a span and records the error if it is non-nil and not an expected error. Expected errors (context cancellation, deadline exceeded) are recorded with an Unset status to avoid polluting error dashboards.
func InitOtel ¶
func InitOtel(ctx context.Context, opts ...Option) (context.Context, func(context.Context) error, error)
InitOtel initializes OpenTelemetry with the given configuration. It returns a function that can be called to shutdown OpenTelemetry.
func IsExpectedError ¶ added in v0.8.22
IsExpectedError returns true for errors that are expected during normal operation and should not be recorded as span errors.
For an errors.Join result, true is returned only when EVERY child is itself expected. Otherwise a real error joined with a context cancel would be silently downgraded to Unset span status and dropped from error dashboards.
func ParentCtxErrLabel ¶ added in v0.10.0
ParentCtxErrLabel returns the label set by WithParentCtxErrLabel, or the empty string and ok=false if no label was propagated.
func StartWithLink ¶ added in v0.9.14
func StartWithLink( ctx context.Context, tracer trace.Tracer, name string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span)
StartWithLink starts a new root span linked to the current span in ctx.
When ctx already carries a valid span context, the new span is started with trace.WithNewRoot() and a trace.Link back to that span. This breaks the causal chain into a new trace while preserving navigability via the link.
Prefer plain tracer.Start for ordinary nested spans. Reach for this only when an outer span would otherwise accumulate hundreds or thousands of children — e.g. a long-running loop that processes each item via a chain of helper spans. Mirrors ctxotel.StartWithLink in the ConductorOne platform repo.
Safe to call with the no-op tracer or with a ctx that has no span: the link is omitted and behavior matches tracer.Start. The returned ctx carries the new span, so descendants attach to the new root.
func WithParentCtxErrLabel ¶ added in v0.10.0
WithParentCtxErrLabel returns a new context that carries label as the parent's classified ctx-error. ParentCtxErrLabel reads it back. Use this immediately after context.WithoutCancel so a downstream finalize span can record what the original caller saw.
Types ¶
type Option ¶ added in v0.2.90
type Option func(*otelConfig)
Option is a function that configures an otelConfig.
func WithInitialLogFields ¶ added in v0.2.90
WithInitialLogFields sets the log fields that will be added to all log messages.
func WithInsecureOtelEndpoint ¶ added in v0.2.90
WithInsecureOtelEndpoint sets the endpoint for both tracing and logging with insecure connection.
func WithLoggingDisabled ¶ added in v0.2.90
func WithLoggingDisabled() Option
WithLoggingDisabled disables logging.
func WithOtelEndpoint ¶ added in v0.2.90
WithOtelEndpoint sets the endpoint and TLS certificate for both tracing and logging.
func WithServiceName ¶ added in v0.2.90
WithServiceName sets the service name for the OpenTelemetry configuration.
func WithTracingDisabled ¶ added in v0.2.90
func WithTracingDisabled() Option
WithTracingDisabled disables tracing.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package uotelzap converts OpenTelemetry span context into zap log fields so log lines can be correlated with traces in the OTel-to-Datadog pipeline.
|
Package uotelzap converts OpenTelemetry span context into zap log fields so log lines can be correlated with traces in the OTel-to-Datadog pipeline. |