Trying to inject OpenTelemetry trace context into a CXone Studio script that hits our internal database via the DBConnector action. The goal is to correlate the DB lookup latency with the upstream Genesys Cloud interaction span.
We’ve got the DBConnector configured to call a stored procedure that accepts a trace_id parameter. I’m passing the trace ID from the incoming webhook context. The DB call works fine in isolation. The issue pops up when I chain it with an HTTP action to push the result to our OTel collector.
Here’s the snippet logic in the script:
{
"action": "DBConnector",
"params": {
"connectionString": "conn_str_var",
"commandText": "sp_get_customer_data",
"parameters": [
{ "name": "@trace_id", "value": "{context.traceId}" }
]
}
}
The DB returns the data. Then I try to send a JSON payload to our collector:
{
"action": "HTTP",
"method": "POST",
"url": "{env.otel_collector_url}/api/v2/traces",
"body": {
"traceId": "{context.traceId}",
"spanId": "{new_uuid()}",
"parentSpanId": "{context.parentTraceId}",
"db_latency_ms": "{db_connector.result.elapsed_time}"
}
}
The HTTP action returns a 502 Bad Gateway. The payload looks valid. Checked the collector logs, it’s not receiving the request. Suspect the context.traceId variable is getting cleared or malformed after the DB action completes.
Is there a specific way to preserve custom context variables across DBConnector actions? Or does the DB action reset the context scope?
Also noticed the elapsed_time property isn’t documented in the standard DBConnector response schema. Just guessing at the field name based on similar actions. Might be why the JSON is malformed.