diff --git a/packages/dd-trace/src/appsec/sdk/utils.js b/packages/dd-trace/src/appsec/sdk/utils.js index be440029342..b59bf08d22a 100644 --- a/packages/dd-trace/src/appsec/sdk/utils.js +++ b/packages/dd-trace/src/appsec/sdk/utils.js @@ -12,14 +12,12 @@ function getRootSpan (tracer) { const parent = started.find(s => s.context()._spanId === parentId) const pContext = parent?.context() - if (pContext) { - parentId = pContext._parentId - - if (!pContext._tags?._inferred_span) { - span = parent - } - } else { - break + if (!pContext) break + + parentId = pContext._parentId + + if (!pContext._tags?._inferred_span) { + span = parent } }