open-telemetry / open-telemetry/opentelemetry-python

Allow passing a non-SDK `LoggerProvider` to the SDK `EventLoggerProvider`

Open
#4,439 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Here:

https://github.com/open-telemetry/opentelemetry-python/blob/a7fe4f8bac7fa36291c6acf86982bbb356e3ae6d/opentelemetry-sdk/src/opentelemetry/sdk/_events/__init__.py#L68-L70

LoggerProvider is from opentelemetry.sdk._logs, not the API opentelemetry._logs. This is needed for things like this:

https://github.com/open-telemetry/opentelemetry-python/blob/a7fe4f8bac7fa36291c6acf86982bbb356e3ae6d/opentelemetry-sdk/src/opentelemetry/sdk/_events/__init__.py#L85-L86

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.