open-telemetry / open-telemetry/opentelemetry-python
Allow passing a non-SDK `LoggerProvider` to the SDK `EventLoggerProvider`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
Here:
LoggerProvider is from opentelemetry.sdk._logs, not the API opentelemetry._logs. This is needed for things like this:
I've defined a subclass of the API LoggerProvider. A subclass of the SDK provider class wouldn't make sense in my case. I'd like to pass instances of my subclass to EventLoggerProvider. In addition the logger provider defaults to get_logger_provider() which might not be an SDK provider, so the types are buggy.
Most of the logic isn't tied to the SDK LoggerProvider. Where it is, it could do something like:
if isinstance(self._logger_provider, SDKLoggerProvider):
self._logger_provider.shutdown()
or just:
try:
self._logger_provider.shutdown()
except (AttributeError, TypeError):
pass
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 in opentelemetry-sdk/src/opentelemetry/sdk/_events/init.py at the LoggerProvider import and EventLoggerProvider constructor. Compare the API LoggerProvider contract with the SDK provider assumptions, including shutdown handling. Done means an API LoggerProvider subclass can be passed without SDK-specific type failures, while SDK providers retain their existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100