- 
                Notifications
    You must be signed in to change notification settings 
- Fork 803
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
          
     Merged
      
      
            xrmx
  merged 39 commits into
  open-telemetry:main
from
outergod:fix/GH-3642-fastapi-exceptions
  
      
      
   
  Aug 28, 2025 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            39 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      50120ce
              
                rewrite FastAPIInstrumentor:build_middleware_stack to become failsafe
              
              
                outergod 8a1a39e
              
                add test cases for FastAPI failsafe handling
              
              
                outergod 2150e5c
              
                add CHANGELOG entry
              
              
                outergod 2faf005
              
                remove unused import
              
              
                outergod 5665a0a
              
                [lint] don't return from failsafe wrapper
              
              
                outergod 425a7f3
              
                [lint] allow broad exceptions
              
              
                outergod 6c48703
              
                [lint] more allowing
              
              
                outergod 55e9c43
              
                record FastAPI hook exceptions in active span
              
              
                outergod a7a4949
              
                remove comment
              
              
                outergod 5632d1b
              
                properly deal with hooks not being set
              
              
                outergod 0203e4b
              
                add custom FastAPI exception recording
              
              
                outergod 4c17f00
              
                move failsafe hook handling down to OpenTelemetryMiddleware
              
              
                outergod 56139a3
              
                shut up pylint
              
              
                outergod 843d8c7
              
                optimize failsafe to check for `None` only once
              
              
                outergod c2c326e
              
                remove confusing comment and simplify wrapper logic
              
              
                outergod 3a19941
              
                add clarifying comment
              
              
                outergod 4e29a76
              
                test proper exception / status code recording
              
              
                outergod 1902548
              
                add HTTP status code check
              
              
                outergod fce5164
              
                test HTTP status on the exception recording span
              
              
                outergod 3cc31d0
              
                improve test by removing TypeError
              
              
                outergod 217763b
              
                rectify comment/explanation on inner middleware for exception handling
              
              
                outergod b4cdc0e
              
                minor typo
              
              
                outergod 8fe25f3
              
                Merge remote-tracking branch 'upstream/main' into fix/GH-3642-fastapi…
              
              
                outergod 2739fbb
              
                move ExceptionHandlingMiddleware as the outermost inner middleware
              
              
                outergod 3007304
              
                use distinct status code in test
              
              
                outergod 4493759
              
                improve comemnt
              
              
                outergod 2bc27d1
              
                narrow down exception handling
              
              
                outergod b81343a
              
                narrow down FastAPI exception tests to relevant spans
              
              
                outergod 3d4afe6
              
                collapse tests, more narrow exceptions
              
              
                outergod 6dece9b
              
                move failsafe hook tests to ASGI test suite
              
              
                outergod 762aa30
              
                update CHANGELOG
              
              
                outergod ff00dde
              
                satisfy linter
              
              
                outergod b9a2530
              
                don't record exception if span is not recording
              
              
                outergod 5946f92
              
                add test for unhappy instrumentation codepath
              
              
                outergod de9c77c
              
                Merge remote-tracking branch 'upstream/main' into fix/GH-3642-fastapi…
              
              
                outergod f6bcc9b
              
                make inject fixtures private
              
              
                outergod 33ad22f
              
                give up and shut up pylint
              
              
                outergod fccb7c1
              
                improve instrumentation failure error message and add test
              
              
                outergod 290554d
              
                Merge branch 'main' into fix/GH-3642-fastapi-exceptions
              
              
                xrmx File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.