Skip to content

Commit

Permalink
Filter root span attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
pginca committed Mar 2, 2023
1 parent aa20420 commit 2124dc0
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2124dc0

Please sign in to comment.