open-telemetry / open-telemetry/opentelemetry-python-contrib
Provide a way for Logs SDK to sample based on span context
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
The OpenAI instrumentation currently only records events if the span is recording:
This makes sense, since event recording can be quite expensive and we can piggyback on the sampling decision. However it feels like the Logging API should be more integrated and instrumentation shouldn't need to do these checks. Most logging libraries also have an API to check if recording like Logger.isEnabledFor() and/or support lazy evaluation of log fields. So two questions are
- Should GenAI events be recorded only when a span is recording?
- Should the instrumentation be in charge of this or should the Logging SDK provide its own API to check for recording or lazily evaluate log entry fields.
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 with instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py at lines 59-63, then review the referenced Python logging APIs and the Logging SDK behavior. Define whether sampling belongs in instrumentation or the SDK, and consider what tests would demonstrate the chosen recording and lazy-evaluation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100