@grafana/faro-web-tracing
Version:
Faro web tracing implementation.
50 lines • 1.77 kB
JavaScript
// False positive. Package can be resolved.
// eslint-disable-next-line import/no-unresolved
import { ATTR_SESSION_ID } from '@opentelemetry/semantic-conventions/incubating';
export class FaroMetaAttributesSpanProcessor {
constructor(processor, metas) {
this.processor = processor;
this.metas = metas;
}
forceFlush() {
return this.processor.forceFlush();
}
onStart(span, parentContext) {
var _a;
const session = this.metas.value.session;
if (session === null || session === void 0 ? void 0 : session.id) {
span.attributes[ATTR_SESSION_ID] = session.id;
/**
* @deprecated will be removed in the future and has been replaced by ATTR_SESSION_ID (session.id)
*/
span.attributes['session_id'] = session.id;
}
const user = (_a = this.metas.value.user) !== null && _a !== void 0 ? _a : {};
if (user.email) {
span.attributes['user.email'] = user.email;
}
if (user.id) {
span.attributes['user.id'] = user.id;
}
if (user.username) {
span.attributes['user.name'] = user.username;
}
if (user.fullName) {
span.attributes['user.full_name'] = user.fullName;
}
if (user.roles) {
span.attributes['user.roles'] = user.roles.split(',').map((role) => role.trim());
}
if (user.hash) {
span.attributes['user.hash'] = user.hash;
}
this.processor.onStart(span, parentContext);
}
onEnd(span) {
this.processor.onEnd(span);
}
shutdown() {
return this.processor.shutdown();
}
}
//# sourceMappingURL=faroMetaAttributesSpanProcessor.js.map