Skip to content

Commit

Permalink
tracing: Continue trace if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
monstermunchkin committed Dec 2, 2024
1 parent 3030e86 commit 3dd7042
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions maintenance/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,25 @@ func (h *traceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx = sentry.SetHubOnContext(ctx, hub)
}

options := []sentry.SpanOption{
sentry.ContinueFromRequest(r),
sentry.WithOpName("http.server"),
sentry.WithTransactionSource(sentry.SourceURL),
sentry.WithSpanOrigin(sentry.SpanOriginStdLib),
}
var transaction *sentry.Span

transaction = sentry.TransactionFromContext(ctx)
if transaction != nil {
transaction = transaction.StartChild("http.server", sentry.WithDescription(getHTTPSpanName(r)))
} else {
options := []sentry.SpanOption{
sentry.ContinueFromRequest(r),
sentry.WithOpName("http.server"),
sentry.WithTransactionSource(sentry.SourceURL),
sentry.WithSpanOrigin(sentry.SpanOriginStdLib),
}

transaction := sentry.StartTransaction(ctx,
getHTTPSpanName(r),
options...,
)
transaction.SetData("http.request.method", r.Method)
transaction = sentry.StartTransaction(ctx,
getHTTPSpanName(r),
options...,
)
transaction.SetData("http.request.method", r.Method)
}

ww := mutil.WrapWriter(w)

Expand Down

0 comments on commit 3dd7042

Please sign in to comment.