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

fix: Linking ongoing trace to crash event #4393

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

philipphofmann
Copy link
Member

📜 Description

Fix linking a crash event to an ongoing trace by skipping setting the trace context in Scope.applyToEvent for crash events.

💡 Motivation and Context

Fixes GH-4375

💚 How did you test it?

I could reproduce the problem in the SwiftUI sample app with the following code in the SwiftUIApp.swift file:

init() {
    SentrySDK.start { options in
        options.dsn = "https://[email protected]/5428557"
        options.debug = true
        options.tracesSampleRate = 1.0
        options.enableAutoPerformanceTracing = false
        options.initialScope = { scope in
            let user = User()
            user.email = "[email protected]"
            scope.setUser(user)
            return scope
        }
    }
    
    let t = SentrySDK.startTransaction(name: "after-crash", operation: "crash", bindToScope: true)
    let child = t.startChild(operation: "hello")

    DispatchQueue.global().asyncAfter(deadline: .now() + 1.0) {
        child.finish()
        t.finish()
    }
}

Event in Sentry before the fix:
CleanShot 2024-10-03 at 10 32 34@2x

Event in Sentry after the fix:

CleanShot 2024-10-03 at 10 35 45@2x

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Fix linking a crash event to an ongoing trace by skipping setting the
trace context in Scope.applyToEvent for crash events.

Fixes GH-4375
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.447%. Comparing base (4eea4d1) to head (b8f816e).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #4393       +/-   ##
=============================================
+ Coverage   91.424%   91.447%   +0.022%     
=============================================
  Files          628       629        +1     
  Lines        50530     50630      +100     
  Branches     18255     18343       +88     
=============================================
+ Hits         46197     46300      +103     
+ Misses        4240      4237        -3     
  Partials        93        93               
Files with missing lines Coverage Δ
Sources/Sentry/SentryScope.m 96.734% <100.000%> (+0.040%) ⬆️
Tests/SentryTests/SentryScopeSwiftTests.swift 98.971% <100.000%> (+0.017%) ⬆️

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4eea4d1...b8f816e. Read the comment docs.

Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philipphofmann philipphofmann merged commit a353899 into main Oct 3, 2024
62 of 65 checks passed
@philipphofmann philipphofmann deleted the fix/link-trace-to-crash branch October 3, 2024 11:46
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.

Error is associated with incorrect transaction after crash
2 participants