-
Notifications
You must be signed in to change notification settings - Fork 10
Added BugsnagPerformanceNamedSpans
module and plugin
#457
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
Conversation
Generated by 🚫 Danger |
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpanQuery.m
Show resolved
Hide resolved
|
||
#pragma mark BugsnagPerformancePlugin | ||
|
||
#pragma clang diagnostic ignored "-Wdirect-ivar-access" |
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.
Can we refer to spanTimeoutTimers
property instead of accessing ivar directly?
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.
Actually, I think we can just ditch the timers all together by utilizing dispatch_after.
We can also introduce another callback that will be called whenever a span ceases to exist. As of now, we only update SpanStackingHandler
when a span is deallocated without getting closed in some way. Perhaps we can expand this?
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.
Adding a new callback will require more work but it will save us the overhead of dispatching an operation every time a span is created
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'm going to raise a separate task to implement these optimizations at a later date
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Outdated
Show resolved
Hide resolved
Sources/BugsnagPerformanceNamedSpans/Private/BugsnagPerformanceNamedSpansPlugin+Private.h
Outdated
Show resolved
Hide resolved
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Outdated
Show resolved
Hide resolved
|
||
#pragma clang diagnostic ignored "-Wdirect-ivar-access" | ||
- (void)installWithContext:(BugsnagPerformancePluginContext *)context { | ||
self.spansByName = [NSMutableDictionary new]; |
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.
- This results in the
spansByName
being cleared every time the plugin gets installed. It shouldn't matter as the plugin will presumably be installed once. It's an unnecessary side effect though NSMutableDictionary
proved to be not efficient enough for our purposes in the past. As this will be heavily used, I think we should opt for anstd::map
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.
- Given that the keys to this
NSMutableDictionary
are strings, changing it to a C++ map will either carry an encode/decode overhead (to go fromNSString
(UTF-16) <->std::string
(UTF-8) or will require that we implement a customstd::hash
andstd::equal_to
so that we can directly store theNSString*
s in the C++ map.
I think we should keep the existing NSMutableDictionary
implementation until we have a chance to benchmark the performance differences between the implementations.
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Outdated
Show resolved
Hide resolved
|
||
#pragma mark BugsnagPerformancePlugin | ||
|
||
#pragma clang diagnostic ignored "-Wdirect-ivar-access" |
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.
Adding a new callback will require more work but it will save us the overhead of dispatching an operation every time a span is created
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Outdated
Show resolved
Hide resolved
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Outdated
Show resolved
Hide resolved
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Outdated
Show resolved
Hide resolved
Sources/BugsnagPerformanceNamedSpans/Public/BugsnagPerformanceNamedSpansPlugin.mm
Show resolved
Hide resolved
Co-authored-by: Jason <lemnik@users.noreply.github.com>
Co-authored-by: Robert Bartoszewski <126675445+robert-smartbear@users.noreply.github.com>
078a3c3
to
14c7618
Compare
Co-authored-by: Robert Bartoszewski <126675445+robert-smartbear@users.noreply.github.com>
Goal
Added a new
BugsnagPerformanceNamedSpans
module which exposes aBugsnagPerformanceNamedSpansPlugin
hat can be used to track spans by name. This allows for easier access to open spans without needing to keep references.Design
The new plugin allows spans to be queried by name (using a
BugsnagPerformanceNamedSpanQuery
). If the span exists, aBugsnagPerformanceSpan
instance is returned fromBugsnagPerformance.getSpanControlsWithQuery
.Only the latest span for a given span name is tracked, and spans older than 10 minutes are removed from tracked memory to allow them to be deallocated.
Changeset
BugsnagPerformanceNamedSpansPlugin
implementationTesting
Added new unit tests and a new E2E test scenario