-
-
Notifications
You must be signed in to change notification settings - Fork 284
feat(flutter): Synchronize traceId to native SDKs
#3507
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
Changes from all commits
27ba53d
d5d5d97
4c00ced
41528cd
83d7796
378e8d1
d417ff6
5844f3a
6145db6
2f718fc
57a11f4
0181ca9
ffda3f3
cd57dcb
b1666e6
1a99f49
6024593
f65be25
18234b8
206ef8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // ignore_for_file: invalid_use_of_internal_member | ||
|
|
||
| import 'dart:async'; | ||
|
|
||
| import 'package:meta/meta.dart'; | ||
|
|
||
| import '../../sentry_flutter.dart'; | ||
| import '../native/sentry_native_binding.dart'; | ||
| import '../utils/internal_logger.dart'; | ||
|
|
||
| @internal | ||
| class NativeTraceSyncIntegration implements Integration<SentryFlutterOptions> { | ||
| static const integrationName = 'NativeTraceSync'; | ||
| final SentryNativeBinding _native; | ||
| SentryOptions? _options; | ||
|
|
||
| NativeTraceSyncIntegration(this._native); | ||
|
|
||
| @override | ||
| void call(Hub hub, SentryFlutterOptions options) { | ||
| if (!options.enableNativeTraceSync) { | ||
| internalLogger.info('$integrationName: disabled, skipping setup'); | ||
| return; | ||
| } | ||
|
|
||
| _options = options; | ||
| options.lifecycleRegistry | ||
| .registerCallback<OnGenerateNewTrace>(_syncTraceToNative); | ||
| options.sdk.addIntegration(integrationName); | ||
|
|
||
| final traceId = hub.scope.propagationContext.traceId; | ||
| final spanId = hub.getSpan()?.context.spanId ?? SpanId.newId(); | ||
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Sync the initial PropagationContext created at Hub construction. | ||
| _syncTraceToNative(OnGenerateNewTrace(traceId, spanId)); | ||
| } | ||
|
|
||
| @override | ||
| void close() { | ||
| _options?.lifecycleRegistry | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do other integrations nil options here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, would you set it as late instead?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no preference really, just to be consistent in cleanup like we do elsewhere |
||
| .removeCallback<OnGenerateNewTrace>(_syncTraceToNative); | ||
| } | ||
|
|
||
| FutureOr<void> _syncTraceToNative(OnGenerateNewTrace event) => | ||
| _native.setTrace(event.traceId, event.spanId); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.