Skip to content

SSE Streaming

Subscribe to real-time span events via Server-Sent Events (SSE).

GET /api/v1/project/{project_id}/otel/sse

Optional query params:

  • trace_id — stream only a single trace
  • span_id — stream only a single span
  • session_id — stream only a single session

Events are sent with the event name span and a JSON payload:

event: span
data: {"trace_id":"...","span_id":"...","session_id":"...","user_id":"..."}

Example payload:

{
"trace_id": "abc123",
"span_id": "span-001",
"session_id": "session-789",
"user_id": "user-123"
}
const eventSource = new EventSource(
'http://localhost:5388/api/v1/project/default/otel/sse'
);
eventSource.addEventListener('span', (event) => {
const payload = JSON.parse(event.data);
console.log('Span event:', payload);
});
eventSource.onerror = (error) => {
console.error('SSE error:', error);
eventSource.close();
};
import json
import requests
url = 'http://localhost:5388/api/v1/project/default/otel/sse'
with requests.get(url, stream=True) as response:
for line in response.iter_lines():
if line and line.startswith(b'data: '):
payload = json.loads(line.decode('utf-8').replace('data: ', ''))
print('Span event:', payload)

When auth is enabled, include the token. Standard EventSource does not support custom headers—use a Node.js client or fetch with streaming instead.