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

feat(react-native): support for starting native spans on android #536

Conversation

yousif-bugsnag
Copy link
Contributor

Goal

Add support for starting native spans on Android

Design

Added a new Turbo Module method called startNativeSpan which creates a span in the Android Performance SDK and returns a JS representation of the native Android span to JS.

The Turbo Module method accepts a limited set of span options (startTime and parentContext) as native spans should always be first class and should never become the current context in the native SDK.

Testing

Tested manually as this is not yet being used

Copy link

github-actions bot commented Nov 28, 2024

Browser bundle size

NPM build

Package
Before 210.63 kB
After 210.63 kB
± No change

CDN build

Unminified Minfied Minified + gzipped
Before 107.59 kB 40.60 kB 11.89 kB
After 107.59 kB 40.60 kB 11.89 kB
± No change No change No change

Code coverage

Coverage values did not change👌.

Total:

Lines Branches Functions Statements
90.21%(+0%) 80.68%(+0%) 87.87%(+0%) 88.95%(+0%)

Generated against a9097cf on 2 December 2024 at 14:05:00 UTC

@yousif-bugsnag yousif-bugsnag force-pushed the PLAT-12936/start-native-spans-android branch from 39925f3 to dec156d Compare November 29, 2024 13:20
long nativeSpanId = Long.parseUnsignedLong(spanId, 16);
UUID nativeTraceId = new UUID(Long.parseUnsignedLong(traceId.substring(0, 16), 16), Long.parseUnsignedLong(traceId.substring(16), 16));

SpanContext nativeSpanContext = new SpanContext() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this shouldn't maybe be a named class (like ReactNativeSpanContext) to remove the noise from this jsSpanContextToNativeSpanContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea 👍🏾

@yousif-bugsnag yousif-bugsnag force-pushed the PLAT-12936/start-native-spans-android branch 2 times, most recently from 8d55f2c to 63f5c9b Compare November 29, 2024 16:53
Comment on lines 13 to 20
nativeSpanId = Long.parseUnsignedLong(spanId, 16);
nativeTraceId = new UUID(
Long.parseUnsignedLong(traceId.substring(0, 16), 16),
Long.parseUnsignedLong(traceId.substring(16), 16)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like 16 for the radix should maybe be made into a constant?

private static final int HEX_RADIX = 16;

It might also be worth it to have a TRACE_ID_MIDPOINT = 16 constant

@yousif-bugsnag yousif-bugsnag force-pushed the PLAT-12936/start-native-spans-android branch from 63f5c9b to 42f08bd Compare December 2, 2024 11:49
@yousif-bugsnag yousif-bugsnag force-pushed the PLAT-12936/start-native-spans-android branch from 42f08bd to 1b8f00e Compare December 2, 2024 12:00
@yousif-bugsnag yousif-bugsnag force-pushed the PLAT-12936/start-native-spans-android branch from a2b57b6 to a9097cf Compare December 2, 2024 14:01
@yousif-bugsnag yousif-bugsnag merged commit ab5a293 into integration/rn-native-integration Dec 2, 2024
43 checks passed
@yousif-bugsnag yousif-bugsnag deleted the PLAT-12936/start-native-spans-android branch December 2, 2024 14:56
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