Trying to mute an agent’s microphone programmatically using the Genesys Cloud JavaScript SDK (genesys-cloud-platform-client). I need this to trigger a downstream Data Action that logs the mute event to our distributed tracing system.
Here is the code snippet I am using:
const callControlClient = platformClient.calling;
async function muteAgentMic(conversationId, participantId) {
const span = tracer.startSpan('mute-agent-mic', {
kind: SpanKind.CLIENT,
attributes: {
'conversation.id': conversationId,
'participant.id': participantId
}
});
try {
// Attempt to mute
await callControlClient.postCallingsCallControlMute({
conversationId: conversationId,
participantId: participantId,
body: {
muted: true
}
});
span.setStatus({ code: SpanStatusCode.OK });
} catch (error) {
span.recordException(error);
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
throw error;
} finally {
span.end();
}
}
The API call returns 204 No Content successfully. The agent is muted. However, the span ends immediately, and the downstream Data Action (which is supposed to be triggered by the mute event webhook) does not receive the trace context.
I noticed that postCallingsCallControlMute does not seem to accept or inject custom headers for context propagation. When I look at the Jaeger backend, the span for the mute action is there, but it’s an orphan. The Data Action span shows a different trace ID.
Is there a way to inject the OTel context into the SDK call itself? Or do I need to use a different endpoint that allows custom headers? The standard fetch wrapper I tried doesn’t work with the SDK’s internal token management.
Also, the SDK version is ^5.2.0. Any thoughts on how to keep the trace linked? The documentation doesn’t mention header injection for call control methods.
I’m stuck on the propagation part. The mute works, but the tracing breaks. Need a way to pass the traceparent header through the SDK call.