- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.7k
 
          feat!: Remove spanId from propagation context
          #14733
        
          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 4 commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    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
        
          
          
            1 change: 0 additions & 1 deletion
          
          1 
        
  ...ration-tests/suites/public-api/startSpan/parallel-root-spans-with-parentSpanId/subject.js
  
  
      
      
   
        
      
      
    
  
    
      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
    
  
  
    
              
        
          
          
            12 changes: 12 additions & 0 deletions
          
          12 
        
  ...rowser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/init.js
  
  
      
      
   
        
      
      
    
  
    
      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,12 @@ | ||
| import * as Sentry from '@sentry/browser'; | ||
| 
     | 
||
| window.Sentry = Sentry; | ||
| 
     | 
||
| Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
| integrations: integrations => { | ||
| integrations.push(Sentry.browserTracingIntegration()); | ||
| return integrations.filter(i => i.name !== 'BrowserSession'); | ||
| }, | ||
| tracesSampleRate: 0, | ||
| }); | 
        
          
          
            2 changes: 2 additions & 0 deletions
          
          2 
        
  ...ser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/subject.js
  
  
      
      
   
        
      
      
    
  
    
      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,2 @@ | ||
| Sentry.captureException(new Error('test error')); | ||
| Sentry.captureException(new Error('test error 2')); | 
        
          
          
            11 changes: 11 additions & 0 deletions
          
          11 
        
  ...-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/template.html
  
  
      
      
   
        
      
      
    
  
    
      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,11 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012" /> | ||
| <meta | ||
| name="baggage" | ||
| content="sentry-release=2.1.12,sentry-public_key=public,sentry-trace_id=123" | ||
| /> | ||
| </head> | ||
| </html> | 
        
          
          
            35 changes: 35 additions & 0 deletions
          
          35 
        
  ...rowser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/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,35 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import type { Event } from '@sentry/browser'; | ||
| import { sentryTest } from '../../../../utils/fixtures'; | ||
| import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
| 
     | 
||
| sentryTest('errors in TwP mode have same trace ID & span IDs', async ({ getLocalTestUrl, page }) => { | ||
| if (shouldSkipTracingTest()) { | ||
| sentryTest.skip(); | ||
| } | ||
| 
     | 
||
| const traceId = '12312012123120121231201212312012'; | ||
| const spanId = '1121201211212012'; | ||
| 
     | 
||
| const url = await getLocalTestUrl({ testDir: __dirname }); | ||
| const [event1, event2] = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url }); | ||
| 
     | 
||
| // Ensure these are the actual errors we care about | ||
| expect(event1.exception?.values?.[0].value).toContain('test error'); | ||
| expect(event2.exception?.values?.[0].value).toContain('test error'); | ||
| 
     | 
||
| const contexts1 = event1.contexts; | ||
| const { trace_id: traceId1, span_id: spanId1 } = contexts1?.trace || {}; | ||
| expect(traceId1).toEqual(traceId); | ||
| 
     | 
||
| // Span ID is a virtual span, not the propagated one | ||
| expect(spanId1).not.toEqual(spanId); | ||
| expect(spanId1).toMatch(/^[a-f0-9]{16}$/); | ||
| 
     | 
||
| const contexts2 = event2.contexts; | ||
| const { trace_id: traceId2, span_id: spanId2 } = contexts2?.trace || {}; | ||
| expect(traceId2).toEqual(traceId); | ||
| expect(spanId2).toMatch(/^[a-f0-9]{16}$/); | ||
| 
     | 
||
| expect(spanId2).toEqual(spanId1); | ||
| }); | 
        
          
          
            12 changes: 12 additions & 0 deletions
          
          12 
        
  ...ges/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/init.js
  
  
      
      
   
        
      
      
    
  
    
      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,12 @@ | ||
| import * as Sentry from '@sentry/browser'; | ||
| 
     | 
||
| window.Sentry = Sentry; | ||
| 
     | 
||
| Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
| integrations: integrations => { | ||
| integrations.push(Sentry.browserTracingIntegration()); | ||
| return integrations.filter(i => i.name !== 'BrowserSession'); | ||
| }, | ||
| tracesSampleRate: 0, | ||
| }); | 
        
          
          
            2 changes: 2 additions & 0 deletions
          
          2 
        
  .../browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/subject.js
  
  
      
      
   
        
      
      
    
  
    
      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,2 @@ | ||
| Sentry.captureException(new Error('test error')); | ||
| Sentry.captureException(new Error('test error 2')); | 
        
          
          
            30 changes: 30 additions & 0 deletions
          
          30 
        
  ...ges/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/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,30 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import type { Event } from '@sentry/browser'; | ||
| import { sentryTest } from '../../../../utils/fixtures'; | ||
| import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
| 
     | 
||
| sentryTest('errors in TwP mode have same trace ID & span IDs', async ({ getLocalTestUrl, page }) => { | ||
| if (shouldSkipTracingTest()) { | ||
| sentryTest.skip(); | ||
| } | ||
| 
     | 
||
| const url = await getLocalTestUrl({ testDir: __dirname }); | ||
| const [event1, event2] = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url }); | ||
| 
     | 
||
| // Ensure these are the actual errors we care about | ||
| expect(event1.exception?.values?.[0].value).toContain('test error'); | ||
| expect(event2.exception?.values?.[0].value).toContain('test error'); | ||
| 
     | 
||
| const contexts1 = event1.contexts; | ||
| const { trace_id: traceId1, span_id: spanId1 } = contexts1?.trace || {}; | ||
| expect(traceId1).toMatch(/^[a-f0-9]{32}$/); | ||
| expect(spanId1).toMatch(/^[a-f0-9]{16}$/); | ||
| 
     | 
||
| const contexts2 = event2.contexts; | ||
| const { trace_id: traceId2, span_id: spanId2 } = contexts2?.trace || {}; | ||
| expect(traceId2).toMatch(/^[a-f0-9]{32}$/); | ||
| expect(spanId2).toMatch(/^[a-f0-9]{16}$/); | ||
| 
     | 
||
| expect(traceId2).toEqual(traceId1); | ||
| expect(spanId2).toEqual(spanId1); | ||
| }); | 
  
    
      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
    
  
  
    
              
  
    
      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.
        
    
  
      
      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.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm so I'm a bit concerned about this. IIUC previously, the spanIds in this test were equal because we stored it on the PC. Now, consecutive calls to APIs like
getTraceData()orgetTraceMetaTags()like in this test deliver diverging span ids.This also implies the following scenario for a TwP-configured SDK:
sentry-traceheader with spanId123event.context.traceholds a different spanId456I thought about the implications of this and while I'm still worried, I couldn't really come up with a concrete use case where this is actually problematic. I was especially worried if we'd send different spanIds within one error or transaction event but I think we only send this in
event.context.trace. Thetraceenvelope header does not contain thespanIdat all, so it shouldn't be a problem.However, we should ensure that the same
traceIdis still used in both places. Which I hope we have tests for but it's better to double-check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, so the traceId is tested here (see line 53).
I totally get what you mean, it was the same for me - thinking, hmm, this is different, but then, is it actually a problem?