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 c756faa
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ 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.boolean.attribute', true)
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
78 changes: 66 additions & 12 deletions test/react-native/features/native-integration.feature
Original file line number Diff line number Diff line change
@@ -1,16 +1,70 @@
@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
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 |
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 |
And I wait to receive 2 sampling requests
And I wait to receive 2 traces

# JS trace
And the trace payload field "resourceSpans.0.resource" string attribute "service.name" equals "com.bugsnag.fixtures.reactnative.performance"
And the trace payload field "resourceSpans.0.resource" string attribute "telemetry.sdk.name" equals "bugsnag.performance.reactnative"
And the trace payload field "resourceSpans.0.resource" string attribute "device.id" matches the regex "^[a-z0-9-]{20,40}$"

And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.name" equals "JS parent span"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double attribute "bugsnag.sampling.p" equals 1
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "bugsnag.span.category" equals "custom"

And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "custom.string.attribute" equals "test"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" integer attribute "custom.int.attribute" equals 12345
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double attribute "custom.double.attribute" equals 123.45
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" boolean attribute "custom.boolean.attribute" is true
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string array attribute "custom.stringarray.attribute" equals the array:
| a |
| b |
| c |
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" integer array attribute "custom.intarray.attribute" equals the array:
| 1 |
| 2 |
| 3 |
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double array attribute "custom.doublearray.attribute" equals the array:
| 1.1 |
| 2.2 |
| 3.3 |

Then the trace payload field "resourceSpans.0.resource" string attribute "device.id" is stored as the value "deviceId"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.spanId" is stored as the value "parentSpanId"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.traceId" is stored as the value "traceId"

# Native trace
Then I discard the oldest trace
And the trace payload field "resourceSpans.0.resource" string attribute "service.name" equals "com.bugsnag.fixtures.reactnative.performance"
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 |

And the trace payload field "resourceSpans.0.resource" string attribute "device.id" equals the stored value "deviceId"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.name" equals "Native child span"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.parentSpanId" equals the stored value "spanId"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.traceId" equals the stored value "traceId"

And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double attribute "bugsnag.sampling.p" equals 1.0
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "bugsnag.span.category" equals "custom"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" boolean attribute "bugsnag.span.first_class" is true

And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "custom.string.attribute" equals "test"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" integer attribute "custom.int.attribute" equals 12345
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double attribute "custom.double.attribute" equals 123.45
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" boolean attribute "custom.boolean.attribute" is true
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string array attribute "custom.stringarray.attribute" equals the array:
| a |
| b |
| c |
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" integer array attribute "custom.intarray.attribute" equals the array:
| 1 |
| 2 |
| 3 |
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double array attribute "custom.doublearray.attribute" equals the array:
| 1.1 |
| 2.2 |
| 3.3 |

0 comments on commit c756faa

Please sign in to comment.