Skip to content

Allow failing fast for auto-instrumentation problems #3550

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

Closed
phillipuniverse opened this issue May 28, 2025 · 0 comments · Fixed by #3545
Closed

Allow failing fast for auto-instrumentation problems #3550

phillipuniverse opened this issue May 28, 2025 · 0 comments · Fixed by #3545

Comments

@phillipuniverse
Copy link
Contributor

What problem do you want to solve?

If there's an exception in an auto-instrumentation, we currently log the exception and continue. I would like an option to fail faster and immediately re-raise the exception to the caller.

Here's where we currently swallow any instrumentation exceptions:

def initialize():
"""Setup auto-instrumentation, called by the sitecustomize module"""
# prevents auto-instrumentation of subprocesses if code execs another python process
if "PYTHONPATH" in environ:
environ["PYTHONPATH"] = _python_path_without_directory(
environ["PYTHONPATH"], dirname(abspath(__file__)), pathsep
)
try:
distro = _load_distro()
distro.configure()
_load_configurators()
_load_instrumentors(distro)
except Exception: # pylint: disable=broad-except
_logger.exception("Failed to auto initialize OpenTelemetry")

With this, there's no way to say, fail startup of my service if there's an instrumentation problem.

Describe the solution you'd like

I'd like to be able to re-raise instrumentation exceptions and fail startup if there's a failure in this case:

from opentelemetry import autoinstrumentation

autoinstrumentation.initialize()

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant