- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
feat(tracing): Add empty baggage header propagation to outgoing requests #5133
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
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            21 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      13c9cc1
              
                feat(tracing): Add empty baggage header propagation
              
              
                Lms24 c0cdd2a
              
                add missing baggage.ts module
              
              
                Lms24 c374f1a
              
                fix linter errors
              
              
                Lms24 babafa1
              
                merge incoming baggage header with possibly modified 3rd party headers
              
              
                Lms24 384b3bd
              
                add obtaining baggage from html meta tags (BrowserTracing)
              
              
                Lms24 be70865
              
                add outgoing request baggage propagation to node Http integration
              
              
                Lms24 6923463
              
                add node http integration unit tests
              
              
                Lms24 3643fab
              
                add node handler unit tests
              
              
                Lms24 b8011e2
              
                fix mergeAndSerializeBaggage bug
              
              
                Lms24 ea67e5c
              
                add node integration tests
              
              
                Lms24 8cf755b
              
                add (currently skipped) meta tag integration test
              
              
                Lms24 85663be
              
                add browsertracing unit tests
              
              
                Lms24 a4b2d59
              
                Add migration instructions (draft) for CORS adjustments
              
              
                Lms24 ae7ca0b
              
                fix migration doc typo
              
              
                Lms24 aedb242
              
                fix linter errors (tracing)
              
              
                Lms24 81f7fa6
              
                add unit tests for serverless aws and gcp
              
              
                Lms24 da32878
              
                add unit tests for mergeAndSerializeBaggage
              
              
                Lms24 c95af98
              
                Apply suggestions from code review
              
              
                Lms24 f4c8acf
              
                don't return empty trace data from meta tags but undefined
              
              
                Lms24 8d502ed
              
                fix meta tag extraction return value and unit tests after rebase
              
              
                Lms24 bca837e
              
                fix missing type export
              
              
                Lms24 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
    
  
  
    
              
  
    
      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
    
  
  
    
              
        
          
          
            52 changes: 52 additions & 0 deletions
          
          52 
        
  packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts
  
  
      
      
   
        
      
      
    
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import * as path from 'path'; | ||
|  | ||
| import { getAPIResponse, runServer } from '../../../../utils/index'; | ||
| import { TestAPIResponse } from '../server'; | ||
|  | ||
| test('Should assign `baggage` header which contains 3rd party trace baggage data of an outgoing request.', async () => { | ||
| const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | ||
|  | ||
| const response = (await getAPIResponse(new URL(`${url}/express`), { | ||
| baggage: 'foo=bar,bar=baz', | ||
| })) as TestAPIResponse; | ||
|  | ||
| expect(response).toBeDefined(); | ||
| expect(response).toMatchObject({ | ||
| test_data: { | ||
| host: 'somewhere.not.sentry', | ||
| baggage: expect.stringContaining('foo=bar,bar=baz'), | ||
| }, | ||
| }); | ||
| }); | ||
|  | ||
| test('Should assign `baggage` header which contains sentry trace baggage data of an outgoing request.', async () => { | ||
| const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | ||
|  | ||
| const response = (await getAPIResponse(new URL(`${url}/express`), { | ||
| baggage: 'sentry-version=1.0.0,sentry-environment=production', | ||
| })) as TestAPIResponse; | ||
|  | ||
| expect(response).toBeDefined(); | ||
| expect(response).toMatchObject({ | ||
| test_data: { | ||
| host: 'somewhere.not.sentry', | ||
| baggage: expect.stringContaining('sentry-version=1.0.0,sentry-environment=production'), | ||
| }, | ||
| }); | ||
| }); | ||
|  | ||
| test('Should assign `baggage` header which contains sentry and 3rd party trace baggage data of an outgoing request.', async () => { | ||
| const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | ||
|  | ||
| const response = (await getAPIResponse(new URL(`${url}/express`), { | ||
| baggage: 'sentry-version=1.0.0,sentry-environment=production,dogs=great', | ||
| })) as TestAPIResponse; | ||
|  | ||
| expect(response).toBeDefined(); | ||
| expect(response).toMatchObject({ | ||
| test_data: { | ||
| host: 'somewhere.not.sentry', | ||
| baggage: expect.stringContaining('dogs=great,sentry-version=1.0.0,sentry-environment=production'), | ||
| }, | ||
| }); | ||
| }); | 
        
          
          
            19 changes: 19 additions & 0 deletions
          
          19 
        
  packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts
  
  
      
      
   
        
      
      
    
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import * as path from 'path'; | ||
|  | ||
| import { getAPIResponse, runServer } from '../../../../utils/index'; | ||
| import { TestAPIResponse } from '../server'; | ||
|  | ||
| test('should attach a `baggage` header to an outgoing request.', async () => { | ||
| const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | ||
|  | ||
| const response = (await getAPIResponse(new URL(`${url}/express`))) as TestAPIResponse; | ||
|  | ||
| expect(response).toBeDefined(); | ||
| expect(response).toMatchObject({ | ||
| test_data: { | ||
| host: 'somewhere.not.sentry', | ||
| // TODO this is currently still empty but eventually it should contain sentry data | ||
| baggage: expect.stringMatching(''), | ||
| }, | ||
| }); | ||
| }); | 
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -6,7 +6,7 @@ import http from 'http'; | |
|  | ||
| const app = express(); | ||
|  | ||
| export type TestAPIResponse = { test_data: { host: string; 'sentry-trace': string } }; | ||
| export type TestAPIResponse = { test_data: { host: string; 'sentry-trace': string; baggage: string } }; | ||
|  | ||
| Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
|  | ||
  
    
      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
    
  
  
    
              
  
    
      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.