-
Hi, is there any extensions for tracing import Tracer from '@opentelemetry/api';
import semanticConventions from '@opentelemetry/semantic-conventions'
const { SemanticAttributes } = semanticConventions
export function traceUser(req, _res, next) {
const span = Tracer.trace.getActiveSpan();
if (req.headers.authorization) {
const [, payload] = req.headers.authorization.split('.');
const { user_id } = JSON.parse(Buffer.from(payload, 'base64').toString());
console.log(SemanticAttributes.ENDUSER_ID)
span.setAttribute(SemanticAttributes.ENDUSER_ID, user_id)
}
next()
} |
Beta Was this translation helpful? Give feedback.
Answered by
Flarna
Jul 14, 2023
Replies: 1 comment 1 reply
-
I'm not aware of such a thing. But via your sample you implemented most of it already. Either create a child span showing the details you want or add an attribute to the current span if it fits better. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sytdas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not aware of such a thing. But via your sample you implemented most of it already. Either create a child span showing the details you want or add an attribute to the current span if it fits better.