From a65c4840336aaeb61d309ef6ed8dc8c4ba7798b7 Mon Sep 17 00:00:00 2001 From: Yousif Ahmed Date: Fri, 20 Dec 2024 16:51:13 +0000 Subject: [PATCH] test(react-native): update native integration e2e test --- .../scenariolauncher/ScenarioLauncherImpl.java | 1 + .../scenario-launcher/ios/ScenarioLauncher.mm | 1 + .../scenarios/NativeIntegrationScenario.js | 16 +++++++++++++++- .../features/native-integration.feature | 12 +++++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/test/react-native/features/fixtures/scenario-launcher/android/src/main/java/com/bugsnag/reactnative/scenariolauncher/ScenarioLauncherImpl.java b/test/react-native/features/fixtures/scenario-launcher/android/src/main/java/com/bugsnag/reactnative/scenariolauncher/ScenarioLauncherImpl.java index 5cec31a5b..b871ede5e 100644 --- a/test/react-native/features/fixtures/scenario-launcher/android/src/main/java/com/bugsnag/reactnative/scenariolauncher/ScenarioLauncherImpl.java +++ b/test/react-native/features/fixtures/scenario-launcher/android/src/main/java/com/bugsnag/reactnative/scenariolauncher/ScenarioLauncherImpl.java @@ -162,6 +162,7 @@ public void startNativePerformance(ReadableMap configuration, Promise promise) { config.setEndpoint(configuration.getString("endpoint")); config.setAutoInstrumentAppStarts(false); config.setAutoInstrumentActivities(AutoInstrument.OFF); + config.setAutoInstrumentRendering(true); BugsnagPerformance.start(config); Log.d(MODULE_NAME, "Started Android performance"); diff --git a/test/react-native/features/fixtures/scenario-launcher/ios/ScenarioLauncher.mm b/test/react-native/features/fixtures/scenario-launcher/ios/ScenarioLauncher.mm index dd246e420..277f6c74a 100644 --- a/test/react-native/features/fixtures/scenario-launcher/ios/ScenarioLauncher.mm +++ b/test/react-native/features/fixtures/scenario-launcher/ios/ScenarioLauncher.mm @@ -123,6 +123,7 @@ @implementation ScenarioLauncher config.autoInstrumentAppStarts = NO; config.autoInstrumentViewControllers = NO; config.autoInstrumentNetworkRequests = NO; + config.autoInstrumentRendering = YES; config.internal.autoTriggerExportOnBatchSize = 1; [BugsnagPerformance startWithConfiguration:config]; diff --git a/test/react-native/features/fixtures/scenario-launcher/scenarios/NativeIntegrationScenario.js b/test/react-native/features/fixtures/scenario-launcher/scenarios/NativeIntegrationScenario.js index 573f94177..cfbd9d915 100644 --- a/test/react-native/features/fixtures/scenario-launcher/scenarios/NativeIntegrationScenario.js +++ b/test/react-native/features/fixtures/scenario-launcher/scenarios/NativeIntegrationScenario.js @@ -11,6 +11,17 @@ export const initialise = async (config) => { endpoint: config.endpoint } + config.onSpanEnd = [ + async (span) => { + if (span.name === 'JS parent span') { + span.setAttribute('custom.js.attribute', 'JS span attribute') + } else if (span.name === 'Native child span') { + span.setAttribute('custom.native.attribute', 'Native span attribute') + } + return true + } + ] + await NativeScenarioLauncher.startNativePerformance(nativeConfig) BugsnagPerformance.attach({ maximumBatchSize: 1, autoInstrumentAppStarts: false, autoInstrumentNetworkRequests: false }) @@ -18,7 +29,10 @@ export const initialise = async (config) => { export const App = () => { useEffect(() => { - BugsnagPerformance.startSpan('NativeIntegration').end() + const parentSpan = BugsnagPerformance.startSpan('JS parent span') + const childSpan = BugsnagPerformance.startSpan('Native child span', { isFirstClass: true }) + childSpan.end() + parentSpan.end() }, []) return ( diff --git a/test/react-native/features/native-integration.feature b/test/react-native/features/native-integration.feature index 8bd1ed2f0..6fcb078ab 100644 --- a/test/react-native/features/native-integration.feature +++ b/test/react-native/features/native-integration.feature @@ -3,8 +3,14 @@ Feature: Native Integration Scenario: Native Integration When I run 'NativeIntegrationScenario' - And I wait to receive 1 span - Then a span named "NativeIntegration" contains the attributes: + And I wait to receive 2 spans + Then a span named "Native child span" has a parent named "JS parent" + And a span named "Native child span" contains the attributes: | attribute | type | value | | bugsnag.span.category | stringValue | custom | - + | bugsnag.span.first_class | boolValue | true | + | custom.native.attribute | stringValue | Native span attribute | + And a span named "JS parent span" contains the attributes: + | attribute | type | value | + | bugsnag.span.category | stringValue | custom | + | custom.native.attribute | stringValue | JS span attribute |