Skip to content

Add test: verify coldbrew.trace_id OTEL span attribute in SetTraceId #23

@ankurs

Description

@ankurs

Context

PR #22 added coldbrew.trace_id as an OTEL span attribute in SetTraceId() (notifier/notifier.go). This links the ColdBrew correlation ID to distributed traces for cross-system debugging.

The attribute is set in two paths:

  1. Early return — when trace ID already exists, sets attribute before returning
  2. Normal path — after resolving trace ID from metadata/OTEL/UUID, sets attribute on the span

What's needed

Add a unit test using the OTEL SDK test tracer (go.opentelemetry.io/otel/sdk/trace/tracetest) to verify:

  • coldbrew.trace_id attribute is set on the span when SetTraceId is called with an active OTEL span
  • Metadata-supplied trace ID takes priority over OTEL-generated trace ID
  • When trace ID already exists (early return path), the attribute is still set
  • When no span is in context, no panic occurs

Files

  • errors/notifier/notifier.goSetTraceId() function (lines 536-573)
  • errors/notifier/notifier_test.go — add tests here

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions