Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(otel): Don't use scope for otel transaction name #602

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions otel/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ func getTraceParentContext(ctx context.Context) sentry.TraceParentContext {
}

func updateTransactionWithOtelData(transaction *sentry.Span, s otelSdkTrace.ReadOnlySpan) {
hub := sentry.GetHubFromContext(transaction.Context())
if hub == nil {
return
}

// TODO(michi) This is crazy inefficient
attributes := map[attribute.Key]string{}
resource := map[attribute.Key]string{}
Expand All @@ -143,8 +138,7 @@ func updateTransactionWithOtelData(transaction *sentry.Span, s otelSdkTrace.Read
transaction.Status = utils.MapOtelStatus(s)
transaction.Op = spanAttributes.Op
transaction.Source = spanAttributes.Source
// TODO(michi) We might need to set this somewhere else than on the scope
hub.Scope().SetTransaction(spanAttributes.Description)
transaction.Description = spanAttributes.Description
}

func updateSpanWithOtelData(span *sentry.Span, s otelSdkTrace.ReadOnlySpan) {
Expand Down
2 changes: 1 addition & 1 deletion otel/span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func TestOnEndWithTransaction(t *testing.T) {
assertEqual(t, sentryTransaction.Status, sentry.SpanStatusOK)
assertEqual(t, sentryTransaction.Source, sentry.TransactionSource("custom"))
assertEqual(t, sentryTransaction.Op, "")
assertEqual(t, sentryTransaction.Description, "")
assertEqual(t, sentryTransaction.Description, "transactionName")

// One events should be captured by transport
sentryTransport := getSentryTransportFromContext(ctx)
Expand Down
7 changes: 6 additions & 1 deletion tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,14 @@ func (s *Span) toEvent() *Event {
}
contexts["trace"] = s.traceContext().Map()

transaction := hub.Scope().Transaction()
if s.Description != "" {
transaction = s.Description
}

return &Event{
Type: transactionType,
Transaction: hub.Scope().Transaction(),
Transaction: transaction,
Contexts: contexts,
Tags: s.Tags,
Extra: s.Data,
Expand Down