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 SetSyncIdentityAttrs(ctx context.Context, span trace.Span)
- func StartWithLink(ctx context.Context, tracer trace.Tracer, name string, ...) (context.Context, trace.Span)
- func WithParentCtxErrLabel(ctx context.Context, label string) context.Context
- func WithSyncIdentity(ctx context.Context, id SyncIdentity) 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
- type SyncIdentity
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 SetSyncIdentityAttrs ¶ added in v0.12.5
SetSyncIdentityAttrs stamps the connector identity carried in ctx onto span. No-op when ctx carries no identity, so it is safe to call on every span.
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.
func WithSyncIdentity ¶ added in v0.12.5
func WithSyncIdentity(ctx context.Context, id SyncIdentity) context.Context
WithSyncIdentity returns a child of ctx carrying id. It only stores the identity; spans are stamped where SetSyncIdentityAttrs(ctx, span) is called, not here.
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.
type SyncIdentity ¶ added in v0.12.5
type SyncIdentity struct {
TenantID string
AppID string
ConnectorID string
CatalogID string
CatalogName string
}
SyncIdentity carries the platform identifiers for a connector sync. It is propagated through the context so spans deep in the sync and dotc1z call trees can be filtered to a single connector in APM. The attribute keys match the pprof.Do labels set by the platform sync activity, so spans and CPU profiles line up on the same dimensions.
func SyncIdentityFromContext ¶ added in v0.12.5
func SyncIdentityFromContext(ctx context.Context) (SyncIdentity, bool)
SyncIdentityFromContext returns the identity set by WithSyncIdentity.
func (SyncIdentity) Attrs ¶ added in v0.12.5
func (id SyncIdentity) Attrs() []attribute.KeyValue
Attrs returns the non-empty identity fields as span attributes.
func (SyncIdentity) IsZero ¶ added in v0.12.5
func (id SyncIdentity) IsZero() bool
IsZero reports whether id has no fields set.
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. |