-
-
Notifications
You must be signed in to change notification settings - Fork 329
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
feat: Add thread id and name to span data #3359
Conversation
Add current thread name and thread id to every span when the SDK initializes the span. Fixes GH-3355
|
Codecov Report
@@ Coverage Diff @@
## main #3359 +/- ##
=============================================
+ Coverage 89.243% 89.252% +0.008%
=============================================
Files 500 500
Lines 54592 54644 +52
Branches 19592 19610 +18
=============================================
+ Hits 48720 48771 +51
+ Misses 5005 5004 -1
- Partials 867 869 +2
... and 17 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
6f4d20c | 1228.67 ms | 1238.88 ms | 10.21 ms |
dc0db9e | 1246.06 ms | 1260.46 ms | 14.40 ms |
1db04d8 | 1250.20 ms | 1258.12 ms | 7.92 ms |
4053ee9 | 1248.04 ms | 1250.82 ms | 2.78 ms |
b2f82fa | 1236.94 ms | 1262.86 ms | 25.92 ms |
ea73af6 | 1230.96 ms | 1244.98 ms | 14.02 ms |
326b7eb | 1204.76 ms | 1234.96 ms | 30.20 ms |
596ccc1 | 1214.98 ms | 1239.36 ms | 24.38 ms |
98a8c16 | 1243.33 ms | 1257.86 ms | 14.53 ms |
7cd187e | 1239.02 ms | 1261.42 ms | 22.40 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
6f4d20c | 20.76 KiB | 431.71 KiB | 410.95 KiB |
dc0db9e | 20.76 KiB | 419.62 KiB | 398.86 KiB |
1db04d8 | 20.76 KiB | 435.50 KiB | 414.74 KiB |
4053ee9 | 20.76 KiB | 435.22 KiB | 414.46 KiB |
b2f82fa | 20.76 KiB | 419.62 KiB | 398.86 KiB |
ea73af6 | 20.76 KiB | 425.75 KiB | 404.99 KiB |
326b7eb | 20.76 KiB | 432.31 KiB | 411.55 KiB |
596ccc1 | 22.84 KiB | 401.44 KiB | 378.60 KiB |
98a8c16 | 20.76 KiB | 431.00 KiB | 410.24 KiB |
7cd187e | 20.76 KiB | 401.65 KiB | 380.89 KiB |
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.
Looks good, one question on architecture but nothing blocking!
SentryCrashThread currentThread = sentrycrashthread_self(); | ||
_data[SPAN_DATA_THREAD_ID] = @(currentThread); | ||
|
||
if ([NSThread isMainThread]) { | ||
_data[SPAN_DATA_THREAD_NAME] = @"main"; | ||
} else { | ||
NSString *threadName = [SentryDependencyContainer.sharedInstance.threadInspector | ||
getThreadName:currentThread]; | ||
if (threadName.length > 0) { | ||
_data[SPAN_DATA_THREAD_NAME] = threadName; | ||
} | ||
} |
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.
Any reason we couldn't put this block of logic into SentryThreadInspector, so that the code here would just read as
_data[SPAN_DATA_THREAD_NAME] = SentryDependencyContainer.sharedInstance.threadInspector.threadName;
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.
ThreadInspector threadName returns an empty string when the thread name is nil
, see
sentry-cocoa/Sources/Sentry/SentryThreadInspector.m
Lines 211 to 215 in ae9c51b
NSString *threadName = [NSString stringWithCString:pBuffer encoding:NSUTF8StringEncoding]; | |
if (nil == threadName) { | |
threadName = @""; | |
} | |
return threadName; |
I will fix that in another PR.
Good catch, thanks @armcknight 👍
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.
I opened a PR #3361
📜 Description
Add current thread name and thread id to every span when the SDK initializes the span.
💡 Motivation and Context
Fixes GH-3355
💚 How did you test it?
Unit tests and with the sample app.
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.🔮 Next steps