Skip to content

Rewrite FastAPI instrumentor middleware stack to be failsafe #3664

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

outergod
Copy link
Contributor

@outergod outergod commented Jul 30, 2025

Description

Change the way the FastAPI instrumentor deals with the FastAPI middleware stack so that exception handling code doesn't get executed twice, but still has a valid OTEL context available. At the same time, make sure instrumentor hooks failures cannot crash the service itself.

Fixes #3642 #3637

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Using the MRE in the linked issue, and added unit tests.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@outergod outergod changed the title Fix/gh 3642 fastapi exceptions Rewrite FastAPI instrumentor middleware stack to be failsafe Jul 30, 2025
@outergod outergod requested a review from a team as a code owner July 30, 2025 11:00
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

Successfully merging this pull request may close these issues.

FastAPI instrumentation: errors in hooks not handled properly
1 participant