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

Enable OpenTelemetry Instrumentation #2036

Open
PatrickDale opened this issue Feb 25, 2025 · 0 comments
Open

Enable OpenTelemetry Instrumentation #2036

PatrickDale opened this issue Feb 25, 2025 · 0 comments

Comments

@PatrickDale
Copy link

Hello, I am using Connexion 3.0 and running my service as a Flask app. Prior to migrating to Connexion, I had my Flask app instrumented via OpenTelemetry Auto-Instrumentation.

While OpenTelemetry Auto-Instrumentation works when running a Connexion app using Flask for any HTTP route / response that the Flask application fully handles, it breaks when relying on any Connexion middleware -- for instance exception handlers.

The impact is that the HTTP metrics show completed requests for HTTP responses handled fully by Flask, but for any response that also uses the Connexion middleware (in this case exceptions handled) the request is shown as still in progress even when it has returned a response to the client. 1

I was able to resolve this metrics reporting issue by handling exceptions within Flask rather than within Connexions as shown in the docs:

flask_app = app.app
flask_app.register_error_handler(FileNotFoundError, not_found)
flask_app.register_error_handler(404, not_found)

But it would be nice to not have to use this anti-pattern and instead be able to rely on Connexions middleware for error handling.

I believe the fix here is to create an instrumentation library for Connexions similar to Flask. Is this something that has been looked into before or discussed? Thanks!

Footnotes

  1. Here is an example output of metrics where you can see that there is still a value of 1 for http.server.active_requests even after that active request has completed. In this case the active request was an error handled by connexions instead of flask which results in the request never showing as completed in our metrics: https://gist.github.com/PatrickDale/2a9475571895899fc5dd6393f830d8db#file-example-connexion-flask-otel-metrics-json-L24-L39.

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