Skip to content

Commit 40fe24d

Browse files
committed
fix coordinate not available in router runtime
1 parent 9bf86b1 commit 40fe24d

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

packages/plugins/opentelemetry/tests/useOpenTelemetry.spec.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from '@graphql-hive/plugin-opentelemetry/setup';
2424
import { assertSingleExecutionValue } from '@internal/testing';
2525
import {
26+
Attributes,
2627
ROOT_CONTEXT,
2728
SpanStatusCode,
2829
TextMapPropagator,
@@ -836,11 +837,20 @@ describe('useOpenTelemetry', () => {
836837
code: SpanStatusCode.ERROR,
837838
message: 'GraphQL Execution Error',
838839
});
839-
expect(operationSpan.span.attributes).toMatchObject({
840+
const operationExpectedAttributes: Attributes = {
840841
'hive.graphql.error.count': 1,
841842
'hive.graphql.error.codes': ['TEST_ERROR'],
842-
'hive.graphql.error.coordinates': ['Query.hello'],
843-
});
843+
};
844+
845+
if (!usingHiveRouterRuntime()) {
846+
operationExpectedAttributes['hive.graphql.error.coordinates'] = [
847+
'Query.hello',
848+
];
849+
}
850+
851+
expect(operationSpan.span.attributes).toMatchObject(
852+
operationExpectedAttributes,
853+
);
844854

845855
const executionSpan = operationSpan.expectChild('graphql.execute');
846856
expect(executionSpan.span.status).toMatchObject({
@@ -855,12 +865,20 @@ describe('useOpenTelemetry', () => {
855865
(event) => event.name === 'graphql.error',
856866
);
857867

858-
expect(errorEvent?.attributes).toMatchObject({
868+
const errorExepectedAttributes: Attributes = {
859869
'hive.graphql.error.path': ['hello'],
860870
'hive.graphql.error.message': 'Test Error',
861871
'hive.graphql.error.code': 'TEST_ERROR',
862-
'hive.graphql.error.coordinate': 'Query.hello',
863-
});
872+
};
873+
874+
if (!usingHiveRouterRuntime()) {
875+
errorExepectedAttributes['hive.graphql.error.coordinate'] =
876+
'Query.hello';
877+
}
878+
879+
expect(errorEvent?.attributes).toMatchObject(
880+
errorExepectedAttributes,
881+
);
864882
});
865883

866884
it('should report validation errors on operation span', async () => {

0 commit comments

Comments
 (0)