SSE Streaming
Subscribe to real-time span events via Server-Sent Events (SSE).
Connect to Stream
Section titled “Connect to Stream”GET /api/v1/project/{project_id}/otel/sseOptional query params:
trace_id— stream only a single tracespan_id— stream only a single spansession_id— stream only a single session
Event Format
Section titled “Event Format”Events are sent with the event name span and a JSON payload:
event: spandata: {"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"}JavaScript Example
Section titled “JavaScript Example”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();};Python Example
Section titled “Python Example”import jsonimport 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)With Authentication
Section titled “With Authentication”When auth is enabled, include the token. Standard EventSource does not support custom headers—use a Node.js client or fetch with streaming instead.
Next Steps
Section titled “Next Steps”- Traces API — query runs
- Spans API — query individual steps
- Sessions API — group related runs