Skip to content

Implement Sampler protocol for SessionBasedSampler #156

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 5 commits into from
Aug 25, 2023

Conversation

mattxw
Copy link
Contributor

@mattxw mattxw commented Aug 12, 2023

We are having some crashes that are being tracked on Crashlytics. Based on the stack trace, it appears that Splunk is attempting to change the sampler during session changes. I suspect that there are spans that are referencing the old sampler while Splunk is replacing them.

This pull request eliminates the constant need to replace samplers, as everything is now handled within the SessionBasedSampler class.

Crash stack trace:

Crashed: scheduler-thread
0  libsystem_kernel.dylib         0x7578 __pthread_kill + 8
1  libsystem_pthread.dylib        0x7118 pthread_kill + 268
2  libsystem_c.dylib              0x1d178 abort + 180
3  libswiftCore.dylib             0x3b8b98 swift::fatalError(unsigned int, char const*, ...) + 134
4  libswiftCore.dylib             0x3b8bb8 swift::warningv(unsigned int, char const*, char*) + 30
5  libswiftCore.dylib             0x3bd7c8 swift_deallocPartialClassInstance + 190
6  libswiftCore.dylib             0x3bd618 _swift_release_dealloc + 56
7  libswiftCore.dylib             0x3be43c bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 132
8  ******                      0x14ee5b4 specialized static SessionBasedSampler.sessionShouldSample() + 75 (TracerSharedState.swift:75)
9  ******                      0x14ea8e0 getRumSessionId(forceNewSessionId:) + 64 (Session.swift:64)
10 ******                      0x152c3bc GlobalAttributesProcessor.onStart(parentContext:span:) + 68 (InstrumentationUtils.swift:68)
11 ******                      0x152c2e8 protocol witness for SpanProcessor.onStart(parentContext:span:) in conformance GlobalAttributesProcessor + 15150240 (<compiler-generated>:15150240)
12 ******                      0x1500ee8 MultiSpanProcessor.onStart(parentContext:span:) + 37 (MultiSpanProcessor.swift:37)
13 ******                      0x15229a8 specialized static RecordEventsReadableSpan.startSpan(context:name:instrumentationScopeInfo:kind:parentContext:hasRemoteParent:spanLimits:spanProcessor:clock:resource:attributes:links:totalRecordedLinks:startTime:) + 189 (RecordEventsReadableSpan.swift:189)
14 ******                      0x1521e54 SpanBuilderSdk.startSpan() + 152 (SpanBuilderSdk.swift:152)
15 ******                      0x26e4508 startHttpSpan(request:) + 91 (NetworkInstrumentation.swift:91)
16 ******                      0x26e3754 NSURLSessionTask.splunk_swizzled_resume() + 156 (NetworkInstrumentation.swift:156)
17 ******                      0x26e3528 @objc NSURLSessionTask.splunk_swizzled_resume() + 33726176 (<compiler-generated>:33726176)
// ... private API call
29 libdispatch.dylib              0x2320 _dispatch_call_block_and_release + 32
30 libdispatch.dylib              0x3eac _dispatch_client_callout + 20
31 libdispatch.dylib              0xb534 _dispatch_lane_serial_drain + 668
32 libdispatch.dylib              0xc0a4 _dispatch_lane_invoke + 384
33 libdispatch.dylib              0x16cdc _dispatch_workloop_worker_thread + 648
34 libsystem_pthread.dylib        0xddc _pthread_wqthread + 288
35 libsystem_pthread.dylib        0xb7c start_wqthread + 8

@mattxw mattxw force-pushed the bugfix/sampler-crash branch from 6570e6f to 300b651 Compare August 12, 2023 17:47
@mattxw mattxw marked this pull request as ready for review August 12, 2023 17:48
@mattxw mattxw force-pushed the bugfix/sampler-crash branch 2 times, most recently from bcb730b to ddc565a Compare August 14, 2023 22:39
Copy link
Contributor

@johnbley johnbley left a comment

Choose a reason for hiding this comment

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

Thanks so much for this! It looks really good and cleaner than the original. @seemk are there special rules to follow for this outside contribution?

@seemk
Copy link
Contributor

seemk commented Aug 18, 2023

Thanks so much for this! It looks really good and cleaner than the original. @seemk are there special rules to follow for this outside contribution?

I think there's only https://www.splunk.com/en_us/form/contributions.html linked in our CONTRIBUTING.md

@mattxw
Copy link
Contributor Author

mattxw commented Aug 18, 2023

Thanks so much for this! It looks really good and cleaner than the original. @seemk are there special rules to follow for this outside contribution?

I think there's only https://www.splunk.com/en_us/form/contributions.html linked in our CONTRIBUTING.md

Thanks for the information, I just submitted the form for the Contributions to Splunk. Please kindly recheck again later.

@mattxw mattxw requested a review from johnbley August 24, 2023 09:16
@mattxw mattxw force-pushed the bugfix/sampler-crash branch from ddc565a to 90293ef Compare August 24, 2023 14:24
@mattxw mattxw requested a review from a team as a code owner August 24, 2023 14:24
@mattxw mattxw force-pushed the bugfix/sampler-crash branch from 90293ef to 5f49107 Compare August 24, 2023 14:29
@seemk seemk merged commit d57e48a into signalfx:main Aug 25, 2023
@mattxw mattxw deleted the bugfix/sampler-crash branch September 4, 2023 02:41
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.

3 participants