0xPlaygrounds / 0xPlaygrounds/rig

telemetry: investigate legacy chat_streaming operation naming

Abierto
#2,117 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
8.6k
Forks
959
Merge medio
4 h 32 min
PR fusionados (30 d)
117

Descripción

## Summary

Investigate whether Rig should continue treating streaming chat as a distinct GenAI operation (`chat_streaming`) or migrate to the standard `chat` operation with streaming represented separately.

This surfaced while reviewing #2115. `CompletionOperation` currently couples the span name and `gen_ai.operation.name`:

- `Chat` -> span `chat`, operation `chat`
- `ChatStreaming` -> span `chat_streaming`, operation `chat_streaming`

Provider behavior is not uniform: OpenAI-compatible Chat Completions streaming deliberately uses `Chat` to preserve its existing telemetry contract, while most other streaming providers use `ChatStreaming`. The agent streaming path already separates these concepts: its span is named `chat_streaming`, but its initial operation is `chat`.

## Why investigate

OpenTelemetry's GenAI semantic conventions define `chat` as the well-known operation. Streaming is transport/request behavior and can be represented by `gen_ai.request.stream`; `chat_streaming` does not appear to be a standard operation value.

References:

- https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/
- https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-metrics.md
- https://github.com/open-telemetry/semantic-conventions-genai

Changing existing span names or operation values may break dashboards, filters, sampling rules, or stored-query assumptions, so this should not be changed incidentally in #2115.

## Questions to answer

1. Is `chat_streaming` intentionally part of Rig's public telemetry compatibility contract?
2. Do any supported observability integrations depend on the span name, operation value, or both?
3. Should operation and delivery mode be modeled separately, for example:

```rust
CompletionSpanBuilder::new(provider, model, CompletionOperation::Chat)
.streaming(true)
```

4. If span-name compatibility matters, can Rig retain `chat_streaming` as the span name while emitting:

```text
gen_ai.operation.name = "chat"
gen_ai.request.stream = true
```

5. Does migration require a deprecation window, compatibility option, or release note?

## Acceptance criteria

- Document the intended semantic and compatibility contract for streaming completion spans.
- Audit provider and agent call sites for current span names and operation values.
- Compare the chosen representation against current OpenTelemetry GenAI conventions.
- If migration is appropriate, make operation values consistent across providers and agent/direct surfaces.
- Add coverage for span name, `gen_ai.operation.name`, and streaming indication.
- Document any compatibility impact and migration guidance.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.