From f741101b8a2fea0b3312331832508ceafae6c61a Mon Sep 17 00:00:00 2001 From: Yousif Ahmed Date: Thu, 2 Jan 2025 10:27:40 +0000 Subject: [PATCH] test(react-native): test custom attributes on native spans --- .../scenarios/NativeIntegrationScenario.js | 11 +++---- .../features/native-integration.feature | 30 +++++++++++++------ 2 files changed, 27 insertions(+), 14 deletions(-) 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 9cfc9975c..38d524611 100644 --- a/test/react-native/features/fixtures/scenario-launcher/scenarios/NativeIntegrationScenario.js +++ b/test/react-native/features/fixtures/scenario-launcher/scenarios/NativeIntegrationScenario.js @@ -13,11 +13,12 @@ export const initialise = async (config) => { const 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') - } + span.setAttribute('custom.string.attribute', 'test') + span.setAttribute('custom.int.attribute', 12345) + span.setAttribute('custom.double.attribute', 123.45) + span.setAttribute('custom.stringarray.attribute', ['a', 'b', 'c']) + span.setAttribute('custom.intarray.attribute', [1, 2, 3]) + span.setAttribute('custom.doublearray.attribute', [1.1, 2.2, 3.3]) return true } ] diff --git a/test/react-native/features/native-integration.feature b/test/react-native/features/native-integration.feature index ea78f672e..30db34da8 100644 --- a/test/react-native/features/native-integration.feature +++ b/test/react-native/features/native-integration.feature @@ -1,16 +1,28 @@ @native_integration Feature: Native Integration - Scenario: Native Integration + Scenario: First class custom spans are delegated to the native SDK When I run 'NativeIntegrationScenario' - And I wait to receive 2 spans + And I wait to receive 2 traces Then a span named "Native child span" has a parent named "JS parent span" 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 | + | attribute | type | value | + | bugsnag.span.category | stringValue | custom | + | bugsnag.span.first_class | boolValue | true | + | custom.string.attribute | stringValue | test | + | custom.int.attribute | intValue | 12345 | + | custom.double.attribute | doubleValue | 123.45 | + | custom.stringarray.attribute | arrayValue | [{ stringValue: 'a' }, { stringValue: 'b' }, { stringValue: 'b' }] | + | custom.intarray.attribute | arrayValue | [{ intValue: 1 }, { intValue: 2 }, { intValue: 3 }] | + | custom.doublearray.attribute | arrayValue | [{ doubleValue: 1.1 }, { doubleValue: 2.2 }, { doubleValue: 3.3 }] | + And a span named "JS parent span" contains the attributes: - | attribute | type | value | - | bugsnag.span.category | stringValue | custom | - | custom.js.attribute | stringValue | JS span attribute | + | attribute | type | value | + | bugsnag.span.category | stringValue | custom | + | custom.js.attribute | stringValue | JS span attribute | + + And the trace payload field "resourceSpans.0.resource" string attribute "telemetry.sdk.name" equals "bugsnag.performance.reactnative" + Then I discard the oldest trace + And the trace payload field "resourceSpans.0.resource" string attribute "telemetry.sdk.name" equals the platform-dependent string: + | ios | bugsnag.performance.cocoa | + | android | bugsnag.performance.android |