[Bug]: Request and usage payloads are used as OpenTelemetry span event names
Issue Origin
Observed in exported telemetry and reproducible from the public instrumentation code path.
Bug Description
The OpenAI-compatible VLM instrumentation passes serialized request data and response usage text to tracer.info(). The tracer implementation forwards the complete string to Span.add_event() as the event name.
This produces dynamic, high-cardinality OpenTelemetry event names such as:
messages={"model":"example-model","messages":[{"role":"user","content":"synthetic test"}]}
response.usage=CompletionUsage(...)
Telemetry backends may index and display these values as event names. Request payloads can contain prompts, tool definitions, and other application data, so this also creates an avoidable data exposure risk.
Steps to Reproduce
- Enable OpenTelemetry tracing with any supported exporter.
- Invoke the asynchronous OpenAI-compatible VLM completion path using synthetic input.
- Inspect the events attached to the
openai.vlm.callspan. - Observe that the serialized request and usage representation are stored in each event's
namefield.
The behavior follows directly from these public source locations:
- Request recording:
openai_vlm.py - Usage recording:
openai_vlm.py - Event creation:
tracer.py
Expected Behavior
- Event names remain stable and low-cardinality.
- Request metadata and token usage are recorded as structured attributes.
- Message content capture is opt-in, redacted, and size-limited.
- Token counts use typed attributes such as
gen_ai.usage.input_tokensandgen_ai.usage.output_tokens. - GenAI request details use a stable event name such as
gen_ai.client.inference.operation.detailswhen adopting the OpenTelemetry GenAI semantic conventions.
Actual Behavior
- The complete formatted request dictionary becomes the event name.
- The response usage object's string representation becomes another event name.
- Image data URLs are redacted, while text messages and other request fields remain in the serialized event name.
- Dynamic content prevents reliable event-name aggregation and can significantly increase telemetry payload size.
Suggested Direction
- Add an event API that accepts a stable name and structured attributes, for example
tracer.add_event(name, attributes). - Record model, provider, operation, and token counts using typed
gen_ai.*attributes. - Gate input and output content capture behind an explicit configuration option.
- Apply redaction and length limits before exporting any captured content.
- Add tests asserting that event names do not contain request or response payloads.
OpenTelemetry recommends general, low-cardinality operation names and represents event details through attributes:
- Tracing API: span names and cardinality
- Tracing API: event name and attributes
- GenAI event semantic conventions
OpenViking Version
main at 88f338f78f9825a428fced1ecdc85dd3848d2c91
Python Version
Any supported version; this is an instrumentation behavior in the shared code path.
Operating System
Any.
Model Backend
OpenAI-compatible backend.
@qin-ctx
The producer-to-export path is still present on current main: the async OpenAI VLM backend passes serialized request kwargs and response.usage to tracer.info(), which uses the full string as the Span.add_event() name.
I can take a narrow first pass that keeps the change reviewable:
- add a tracer event API with a stable name and typed attributes;
- migrate the OpenAI VLM request-details and usage events identified here;
- omit message content by default rather than introducing a content-capture setting in the same PR;
- add regression tests asserting stable event names, typed usage attributes, and no request payload in exported events.
I would leave the other dynamic tracer.info() call sites and any opt-in content capture policy for follow-up work, since those need a broader telemetry contract. If this first-phase scope matches the intended direction, could you assign #3952 to me?
The producer-to-export path is still present on current
main: the async OpenAI VLM backend passes serialized request kwargs andresponse.usagetotracer.info(), which uses the full string as theSpan.add_event()name.I can take a narrow first pass that keeps the change reviewable:
- add a tracer event API with a stable name and typed attributes;
- migrate the OpenAI VLM request-details and usage events identified here;
- omit message content by default rather than introducing a content-capture setting in the same PR;
- add regression tests asserting stable event names, typed usage attributes, and no request payload in exported events.
I would leave the other dynamic
tracer.info()call sites and any opt-in content capture policy for follow-up work, since those need a broader telemetry contract. If this first-phase scope matches the intended direction, could you assign #3952 to me?
@ranxi2001 Please help with the revisions. There are many parts in tracer.info that need to be modified. Please take every care not to lose the existing event information.
Thanks for the direction. I opened #3996 with the tracer.info() scope revised around
a central contract, so existing callers no longer create dynamic event names:
- diagnostics use the stable
openviking.logevent name, with source location retained as attributes; - message text and decorator arguments/results are omitted by default, while explicit
capture_contentenables bounded content with best-effort redaction; - OpenAI-compatible response metadata and usage are recorded as typed
gen_ai.*attributes ongen_ai.client.inference.operation.details, replacing the redundant stringifiedresponse.usageevent.
This keeps the session, memory, and training call sites unchanged and leaves global tracer-provider lifecycle changes outside the PR. The 107 focused tests and all executed CI checks pass. Please let me know whether this safe-default contract matches the intended direction.