Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Breaking Changes 🛠
New Features ✨
Bug Fixes 🐛
Internal Changes 🔧Deps
Other
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Event processor overwrites entire trace context losing fields
- The event processor now updates
trace_idandspan_idin the existingevent.Contexts["trace"]map (creating it only when absent), preserving SDK-populated trace fields.
- The event processor now updates
Or push these changes by commenting:
@cursor push 38eedc31b4
Preview (38eedc31b4)
diff --git a/otel/internal/common/event_processor.go b/otel/internal/common/event_processor.go
--- a/otel/internal/common/event_processor.go
+++ b/otel/internal/common/event_processor.go
@@ -27,9 +27,12 @@
if event.Contexts == nil {
event.Contexts = make(map[string]map[string]any)
}
- event.Contexts["trace"] = map[string]any{
- "trace_id": otelSpanContext.TraceID().String(),
- "span_id": otelSpanContext.SpanID().String(),
+ traceContext, found := event.Contexts["trace"]
+ if !found || traceContext == nil {
+ traceContext = make(map[string]any)
+ event.Contexts["trace"] = traceContext
}
+ traceContext["trace_id"] = otelSpanContext.TraceID().String()
+ traceContext["span_id"] = otelSpanContext.SpanID().String()
return event
}
diff --git a/otel/internal/common/event_processor_test.go b/otel/internal/common/event_processor_test.go
--- a/otel/internal/common/event_processor_test.go
+++ b/otel/internal/common/event_processor_test.go
@@ -22,7 +22,7 @@
{name: "without existing trace context"},
{
name: "with existing trace context",
- existingTrace: map[string]any{"trace_id": "123", "parent_span_id": "456"},
+ existingTrace: map[string]any{"trace_id": "123", "parent_span_id": "456", "op": "http.server"},
},
}
@@ -43,10 +43,12 @@
}))
got := linkTraceContextToErrorEvent(event, &sentry.EventHint{Context: ctx})
- assert.Equal(t, map[string]any{
- "trace_id": traceID.String(),
- "span_id": spanID.String(),
- }, got.Contexts["trace"])
+ assert.Equal(t, traceID.String(), got.Contexts["trace"]["trace_id"])
+ assert.Equal(t, spanID.String(), got.Contexts["trace"]["span_id"])
+ if tt.existingTrace != nil {
+ assert.Equal(t, "456", got.Contexts["trace"]["parent_span_id"])
+ assert.Equal(t, "http.server", got.Contexts["trace"]["op"])
+ }
})
}
}This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
bumps the grpc version to eliminate GHSA-p77j-4mvh-x3m3
this needs to be exposed to also update the LastEventID, when capturing an event with a hint
this adds the externalTraceResolver. In order to correctly extract trace context information from otel without adding the otel/trace dependency on the root package, we need to register an externalTraceResolver that applies for errors on ApplyToEvent and for logs and metrics on ResolveTrace
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 46af688. Configure here.


Description
This PR adds the OpenTelemetry integration for OTLP, while also separating the error linking from the span exporter. The PR also includes some deviations from the Spec, so that the package follows closely the OTel conventions.
The main changes:
sentryotel.NewOtelIntegration()for OTel users to link traces with other signals.sentryotlppackage where users can create aNewTraceExporterto send to sentry's otlp endpoint using theotlptracehttpexporter.Deviations from the spec:
setup_otlp_traces_exporterflag since users need to manually provide the exporter to theTracerProvidercollector_url. For users that are already using the collector, the only thing they need to set up is theErrorLinkingIntegration. Having aWithCollectorURLoption mixes concerns, since thesentryotlptrace exporter should only forward to sentry. Using the collector with Sentry requires changing the otlp http configuration on the collector and not the integration level.Issues
Changelog Entry Instructions
To add a custom changelog entry, uncomment the section above. Supports:
For more details: custom changelog entries
Reminders
feat:,fix:,ref:,meta:)Changelog Entry
sentryotlp.NewTraceExporterinstead: