Skip to content

Commit

Permalink
test(react-native): update native integration e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
yousif-bugsnag committed Dec 20, 2024
1 parent 81fcf07 commit 6f02b1e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,28 @@ export const initialise = async (config) => {
endpoint: config.endpoint
}

config.onSpanEnd = [
async (span) => {
if (span.name === 'JSSpan') {
span.setAttribute('custom.js.attribute', 'JS span attribute')
} else if (span.name === 'NativeSpan') {
span.setAttribute('custom.native.attribute', 'Native span attribute')
}
return true
}
]

await NativeScenarioLauncher.startNativePerformance(nativeConfig)

BugsnagPerformance.attach({ maximumBatchSize: 1, autoInstrumentAppStarts: false, autoInstrumentNetworkRequests: false })
}

export const App = () => {
useEffect(() => {
BugsnagPerformance.startSpan('NativeIntegration').end()
const parentSpan = BugsnagPerformance.startSpan('JSSpan')
const childSpan = BugsnagPerformance.startSpan('NativeSpan', { isFirstClass: true })
childSpan.end()
parentSpan.end()
}, [])

return (
Expand Down
12 changes: 9 additions & 3 deletions test/react-native/features/native-integration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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" has a parent named "JS parent"
And a span named "Native child" 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" contains the attributes:
| attribute | type | value |
| bugsnag.span.category | stringValue | custom |
| custom.native.attribute | stringValue | JS span attribute |

0 comments on commit 6f02b1e

Please sign in to comment.