Skip to content

Commit

Permalink
Remove debugTraces
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Oct 18, 2024
1 parent 508243f commit dbea104
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,10 @@ export function startTrace<T>(
config = {} as traceConfig;
}

let parentSpanId: string | undefined;
if (debugTraces) {
const parentSpan = trace.getActiveSpan();
parentSpanId = parentSpan?.spanContext()!.spanId;
}

return getTracer(config.opts?.tracerProvider).startActiveSpan(
SPAN_NAMESPACE_PREFIX + '.' + spanNameSuffix,
{kind: SpanKind.CLIENT},
span => {
if (debugTraces) {
patchSpanEndForDebugging(span, spanNameSuffix, parentSpanId);
}

span.setAttribute(SEMATTRS_DB_SYSTEM, 'spanner');
span.setAttribute(ATTR_OTEL_SCOPE_NAME, TRACER_NAME);
span.setAttribute(ATTR_OTEL_SCOPE_VERSION, TRACER_VERSION);
Expand Down Expand Up @@ -309,23 +299,3 @@ class noopSpan implements Span {
return this;
}
}

function patchSpanEndForDebugging(
span: Span,
spanNameSuffix: string,
parentSpanId: string | undefined
) {
console.trace(
`\x1b[33m${spanNameSuffix}.start id=${span.spanContext().spanId} with parentSpanId: ${parentSpanId}\x1b[00m`
);
const origSpanEnd = span.end;
const wrapSpanEnd = function (this: Span) {
console.trace(
`\x1b[35m${spanNameSuffix}.end() id=${span.spanContext().spanId} with parentSpanId: ${parentSpanId}\x1b[00m`
);
return origSpanEnd.apply(this);
};
Object.defineProperty(span, 'end', {
value: wrapSpanEnd,
});
}

0 comments on commit dbea104

Please sign in to comment.