Skip to content

Commit

Permalink
Don't add nil stacktraces to spans
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellzy committed May 27, 2024
1 parent 20078e1 commit 7c9f1fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/appsec/emitter/httpsec/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ func WrapHandler(handler http.Handler, span ddtrace.Span, pathParams map[string]

var bypassHandler http.Handler
var blocking bool
var stackTrace stacktrace.Event
var stackTrace *stacktrace.Event
args := MakeHandlerOperationArgs(r, clientIP, pathParams)
ctx, op := StartOperation(r.Context(), args, func(op *types.Operation) {
dyngo.OnData(op, func(a *sharedsec.HTTPAction) {
blocking = true
bypassHandler = a.Handler
})
dyngo.OnData(op, func(a *sharedsec.StackTraceAction) {
stackTrace = a.Event
stackTrace = &a.Event
})
})
r = r.WithContext(ctx)
Expand All @@ -104,7 +104,9 @@ func WrapHandler(handler http.Handler, span ddtrace.Span, pathParams map[string]
}

// Add stacktraces to the span, if any
stacktrace.AddToSpan(span, &stackTrace)
if stackTrace != nil {
stacktrace.AddToSpan(span, stackTrace)
}

if bypassHandler != nil {
bypassHandler.ServeHTTP(w, r)
Expand Down

0 comments on commit 7c9f1fb

Please sign in to comment.