Skip to content

Commit

Permalink
test(react-native): test custom attributes on native spans
Browse files Browse the repository at this point in the history
  • Loading branch information
yousif-bugsnag committed Jan 2, 2025
1 parent 5fe86a3 commit f741101
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
Expand Down
30 changes: 21 additions & 9 deletions test/react-native/features/native-integration.feature
Original file line number Diff line number Diff line change
@@ -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 |

0 comments on commit f741101

Please sign in to comment.