Polling /api/v2/analytics/queues/realtime for OTel span context injection

How do I correctly poll the real-time queue statistics endpoint to inject waiting call counts into my OpenTelemetry spans?

We’re instrumenting our Genesys Cloud Data Actions to trace the entire lifecycle of a queue interaction. The goal is to attach the current waiting count and agentsAvailable to the span attributes at the moment the interaction enters the queue. This helps us correlate latency spikes with queue depth in Jaeger.

I’m hitting GET /api/v2/analytics/queues/realtime with the interval parameter set to 5m. The response comes back as a list of entities. Here’s the Python snippet I’m using to fetch the data:

from genesyscloud import analytics_api

analytics = analytics_api.AnalyticsApi(api_client)

response = analytics.get_analytics_queues_realtime(
 interval='5m',
 entities_queue_id='my-queue-id',
 view='default'
)

print(response.entities[0].summary)

The issue is that the summary object doesn’t always seem to reflect the current state. It looks like it’s aggregating over the last 5 minutes. If I change the interval to 1m, I get more frequent updates, but the latency on the API call starts to impact our Data Action execution time. We don’t want to block the thread waiting for a response that’s already stale.

Also, the agentsAvailable count sometimes shows as 0 even though we know agents are logged in. Is this because of a delay in the statistics engine processing login events? Or am I querying the wrong view?

We’ve tried using view='default' and view='expanded', but the data structure is slightly different. I need the raw numbers, not the aggregated trends. Can someone point me to the correct interval or view parameter that gives me the closest to real-time snapshot? Or is there a webhook I can subscribe to instead of polling?