opentelemetry-angular-interceptor
opentelemetry-angular-interceptor copied to clipboard
Injecting TraceId and SpanId into Logs
Is it possible to Inject TraceIds and SpanIds into Logs similar to what's available for JavaScript (example in the following link):
Hi @Mehdi203,
You can do it with the CustomSpan interface.
See more information about this here
And you can do it like
add(span: Span, request: HttpRequest<unknown>, response: HttpResponse<unknown> | HttpErrorResponse): Span {
span.setAttribute(this.myKey , request.params + ';' + response.status);
console.log(`Example log trace_id:”${span.spanContext().traceId}” span_id:”${span.spanContext().spanId}” trace_flags:”${span.spanContext().traceFlags}”`);
return span;
}