Skip whole block if no otel instance

This commit is contained in:
David Baker 2023-04-05 15:11:51 +01:00
parent 5e4aa53997
commit fec299ab20

View file

@ -176,21 +176,23 @@ export class OTelGroupCallMembership {
for (const [userId, userCalls] of calls.entries()) { for (const [userId, userCalls] of calls.entries()) {
for (const [deviceId, call] of userCalls.entries()) { for (const [deviceId, call] of userCalls.entries()) {
if (!this.callsByCallId.has(call.callId)) { if (!this.callsByCallId.has(call.callId)) {
const span = ElementCallOpenTelemetry.instance?.tracer.startSpan( if (ElementCallOpenTelemetry.instance) {
`matrix.call`, const span = ElementCallOpenTelemetry.instance.tracer.startSpan(
undefined, `matrix.call`,
this.groupCallContext undefined,
); this.groupCallContext
// XXX: anonymity );
span.setAttribute("matrix.call.target.userId", userId); // XXX: anonymity
span.setAttribute("matrix.call.target.deviceId", deviceId); span.setAttribute("matrix.call.target.userId", userId);
const displayName = span.setAttribute("matrix.call.target.deviceId", deviceId);
this.groupCall.room.getMember(userId)?.name ?? "unknown"; const displayName =
span.setAttribute("matrix.call.target.displayName", displayName); this.groupCall.room.getMember(userId)?.name ?? "unknown";
this.callsByCallId.set( span.setAttribute("matrix.call.target.displayName", displayName);
call.callId, this.callsByCallId.set(
new OTelCall(userId, deviceId, call, span) call.callId,
); new OTelCall(userId, deviceId, call, span)
);
}
} }
} }
} }