From 2d91b43a7d78e3c6e35a4630d48e8069215b7e44 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 17 Mar 2023 19:03:43 +0000 Subject: [PATCH] Set attributes on the root span Setting them on the context doesn't actually make them show up in jaeger, it's just a way to propagate the info around between different things. --- src/otel/OTelGroupCallMembership.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/otel/OTelGroupCallMembership.ts b/src/otel/OTelGroupCallMembership.ts index 886b4ec..ba06090 100644 --- a/src/otel/OTelGroupCallMembership.ts +++ b/src/otel/OTelGroupCallMembership.ts @@ -84,11 +84,20 @@ export class OTelGroupCallMembership { // Create the main span that tracks the time we intend to be in the call this.callMembershipSpan = tracer.startSpan("otel_groupCallMembershipSpan"); - this.context = opentelemetry.trace - .setSpan(opentelemetry.context.active(), this.callMembershipSpan) - .setValue(Symbol("confId"), this.groupCall.groupCallId) - .setValue(Symbol("matrix.userId"), this.myUserId) - .setValue(Symbol("matrix.displayName"), this.myMember.name); + this.callMembershipSpan.setAttribute( + "matrix.confId", + this.groupCall.groupCallId + ); + this.callMembershipSpan.setAttribute("matrix.userId", this.myUserId); + this.callMembershipSpan.setAttribute( + "matrix.displayName", + this.myMember.name + ); + + this.context = opentelemetry.trace.setSpan( + opentelemetry.context.active(), + this.callMembershipSpan + ); // Here we start a very short span. This is a hack to trigger the posthog exporter. // Only ended spans are processed by the exporter.