Skip to content

feat: migrate notifier from OpenTracing to OTEL trace context#18

Merged
ankurs merged 4 commits intomainfrom
feat/otel-migration
Mar 28, 2026
Merged

feat: migrate notifier from OpenTracing to OTEL trace context#18
ankurs merged 4 commits intomainfrom
feat/otel-migration

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Mar 28, 2026

Summary

Replace OpenTracing span context extraction with native OTEL in the notifier package.

  • opentracing.SpanFromContext() + BaggageItem("trace")trace.SpanFromContext() + SpanContext().TraceID().String()
  • Remove opentracing-go dependency
  • Add go.opentelemetry.io/otel/trace

Depends on

Test plan

  • go test -race ./... — passes
  • make lint — 0 issues

Summary by CodeRabbit

  • Documentation

    • Updated notifier API documentation links and references.
  • Chores

    • Switched project tracing dependency to OpenTelemetry.
  • Bug Fixes / Improvements

    • Notifications now capture and include OpenTelemetry trace identifiers when available, improving trace correlation and reliability.

Replace opentracing.SpanFromContext + BaggageItem("trace") with
OTEL trace.SpanFromContext + SpanContext().TraceID().String().

Remove opentracing-go dependency. Add go.opentelemetry.io/otel/trace.
Copilot AI review requested due to automatic review settings March 28, 2026 01:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b096945-e9e5-4f81-a26b-53af04f5e0d4

📥 Commits

Reviewing files that changed from the base of the PR and between 797b8c6 and d069f67.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

📝 Walkthrough

Walkthrough

Replaced OpenTracing with OpenTelemetry in dependency declarations, updated notifier to extract OTEL span trace IDs (adding otelTraceId while using the app correlation ID as traceId), and incremented README GitHub source-line fragment references for notifier public symbols.

Changes

Cohort / File(s) Summary
Dependency Migration
go.mod
Removed github.com/opentracing/opentracing-go, added go.opentelemetry.io/otel/trace v1.42.0 (with go.opentelemetry.io/otel v1.42.0 now indirect); bumped Google genproto/protobuf indirect versions.
Notifier logic
notifier/notifier.go
Replaced OpenTracing baggage/span extraction with OpenTelemetry span-context extraction: doNotify derives correlation ID from GetTraceId(ctx) and sets otelTraceId when an OTEL span is present; SetTraceId fallback now reads OTEL span trace ID.
Docs link updates
notifier/README.md
Updated GitHub source-line fragment numbers for multiple exported functions/types (e.g., Close, GetTraceId, Notify*, Set*, Tags) without changing signatures or documented behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐇 I hopped from baggage, light and quick,
To OTEL spans that softly tick,
I tuck my trace in correlation,
And leave an otelTrace for inspection,
🥕 observability — hop, click!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: migrate notifier from OpenTracing to OTEL trace context' directly and clearly summarizes the main change: migrating from OpenTracing to OpenTelemetry trace context in the notifier package.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/otel-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the notifier package’s trace correlation from OpenTracing baggage-based extraction to OpenTelemetry (OTEL) span context, removing the OpenTracing dependency as part of the broader tracing migration.

Changes:

  • Replace opentracing.SpanFromContext(...).BaggageItem("trace") with trace.SpanFromContext(...).SpanContext().TraceID().String().
  • Remove github.com/opentracing/opentracing-go dependency; add go.opentelemetry.io/otel/trace.
  • Update generated notifier README links to reflect new line numbers.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
notifier/notifier.go Switch trace ID extraction to OTEL span context and update imports accordingly
notifier/README.md Regenerate/update documentation links after code movement
go.mod Drop OpenTracing dependency and add OTEL trace dependency
go.sum Remove OpenTracing checksums and add OTEL checksums

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
notifier/notifier.go (1)

361-367: ⚠️ Potential issue | 🟠 Major

Preserve GetTraceId precedence in doNotify.

Lines 362-367 now prefer the span trace over the trace already stored by SetTraceId. That makes this path disagree with SetTraceId's own ordering, so a request carrying x-trace-id can log one trace value (trace) while Airbrake/Rollbar emit another (traceId) as soon as a span is present.

Suggested fix
 	for _, d := range list {
 		if c, ok := d.(context.Context); ok {
-			if span := oteltrace.SpanFromContext(c); span.SpanContext().IsValid() {
-				traceID = span.SpanContext().TraceID().String()
-			}
-			if strings.TrimSpace(traceID) == "" {
-				traceID = GetTraceId(c)
-			}
+			traceID = GetTraceId(c)
+			if strings.TrimSpace(traceID) == "" {
+				if span := oteltrace.SpanFromContext(c); span.SpanContext().IsValid() {
+					traceID = span.SpanContext().TraceID().String()
+				}
+			}
 			ctx = c
 			break
 		}
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@notifier/notifier.go` around lines 361 - 367, In doNotify, the current logic
lets oteltrace.SpanFromContext take precedence over a trace previously set by
SetTraceId; change the order so GetTraceId(c) is consulted first and used if
non-empty, and only if it returns an empty string fall back to extracting the
span trace via oteltrace.SpanFromContext(c). Update the traceID assignment in
the block that checks if d is a context.Context to call GetTraceId(c) first,
then only call span.SpanContext().TraceID().String() when GetTraceId returned an
empty/blank value, ensuring trace semantics match SetTraceId/GetTraceId
ordering.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@notifier/notifier.go`:
- Around line 361-367: In doNotify, the current logic lets
oteltrace.SpanFromContext take precedence over a trace previously set by
SetTraceId; change the order so GetTraceId(c) is consulted first and used if
non-empty, and only if it returns an empty string fall back to extracting the
span trace via oteltrace.SpanFromContext(c). Update the traceID assignment in
the block that checks if d is a context.Context to call GetTraceId(c) first,
then only call span.SpanContext().TraceID().String() when GetTraceId returned an
empty/blank value, ensuring trace semantics match SetTraceId/GetTraceId
ordering.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd2d273e-9d57-4050-9ca4-83e61d9ed529

📥 Commits

Reviewing files that changed from the base of the PR and between 3d22b78 and f22b4db.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • notifier/README.md
  • notifier/notifier.go

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ankurs added 2 commits March 28, 2026 15:56
Application-level correlation ID (from SetTraceId/GetTraceId) now takes
precedence over the OTEL distributed trace ID in error notifications.
Both are captured separately:
- traceId: application correlation ID (falls back to OTEL trace ID)
- otelTraceId: OTEL distributed trace ID for linking to tracing backends
@ankurs ankurs merged commit c1f9b08 into main Mar 28, 2026
7 checks passed
@ankurs ankurs deleted the feat/otel-migration branch March 28, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants