Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing a non-SDK LoggerProvider to the SDK EventLoggerProvider #4439

Open
alexmojaki opened this issue Feb 18, 2025 · 0 comments
Open

Comments

@alexmojaki
Copy link

Here:

class EventLoggerProvider(APIEventLoggerProvider):
def __init__(self, logger_provider: Optional[LoggerProvider] = None):
self._logger_provider = logger_provider or get_logger_provider()

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

def shutdown(self):
self._logger_provider.shutdown()

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant