open-telemetry / open-telemetry/opentelemetry-python-contrib
openai: add behavior tests for span and logs disabled
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
What problem do you want to solve?
As of semantic conventions 1.28, genai events are split from spans into log events. At the moment, there is code conflation about recording of both. For example, in some cases, event_logger.emit is guarded by span.is_recording(). We should probably have a coherent approach to recording prior to adding metrics.
Describe the solution you'd like
I think data accumulated to a span should be guarded on span.is_recording(), but independent from event_logger.emit, as logging could be enabled while tracing is disabled.
So, I would like to see tests of either span or events being disabled as well both enabled and both disabled.
Moreover, we may want to obviate creation of large strings when event_logger is NoOpEventLogger or effectively disabled. I don't see a function for is_recording and unsure if an event logger provider should return NoOpEventLogger when disabled. Whatever the expectations are, could be added to a PR on https://github.com/open-telemetry/opentelemetry-python to change the python code documentation.
Describe alternatives you've considered
If for simplicitly we want to only emit log events when spans are also, that's fine but should be documented and tested.
Additional Context
No response
Would you like to implement a fix?
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the OpenAI instrumentation paths that use span.is_recording() and event_logger.emit, then review how disabled tracing and logging are represented. Define and test the expected behavior for spans and events independently in enabled and disabled combinations, and document the chosen relationship if events depend on spans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100