From 2124dc03db15d4fdca20f9556ec95fc6447ecf2e Mon Sep 17 00:00:00 2001 From: Paulo inca Date: Thu, 2 Mar 2023 09:37:43 -0300 Subject: [PATCH] Filter root span attributes --- src/main.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main.js b/src/main.js index f45285c..b3e7252 100644 --- a/src/main.js +++ b/src/main.js @@ -59,19 +59,6 @@ function formatParams(params, module, funcCallerParam) { const result = []; const metadata = {}; - if (tracer && tracer.currentRootSpan && tracer.currentRootSpan.traceId) { - metadata.traceId = tracer.currentRootSpan.traceId; - if (span_info) { - const allDescendants = tracer.currentRootSpan.allDescendants().map((span) => span.id) - metadata.rootSpan = { - parentSpanId: tracer.currentRootSpan.parentSpanId ? tracer.currentRootSpan.parentSpanId : null, - spanId: tracer.currentRootSpan.id, - descendants: allDescendants, - attributes: tracer.currentRootSpan.attributes - } - } - } - if (typeof params[0] === 'string') { result[0] = params[0]; } else if (params[0] instanceof Error) { @@ -107,6 +94,23 @@ function formatParams(params, module, funcCallerParam) { } } + if (tracer && tracer.currentRootSpan && tracer.currentRootSpan.traceId) { + metadata.traceId = tracer.currentRootSpan.traceId; + if (span_info) { + const notificationContextId = tracer.currentRootSpan.attributes['notificationContextId']; + const droneBuild = tracer.currentRootSpan.attributes['data.drone.build'] + const attributes = { + ...(notificationContextId) && { notificationContextId }, + ...(droneBuild) && { droneBuild } + } + metadata.rootSpan = { + parentSpanId: tracer.currentRootSpan.parentSpanId ? tracer.currentRootSpan.parentSpanId : null, + spanId: tracer.currentRootSpan.id, + attributes + } + } + } + if (metadata.error && metadata.error.team) { metadata.team = metadata.error.team }