File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
packages/plugins/opentelemetry Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -151,9 +151,12 @@ export class HiveTracingSpanProcessor implements SpanProcessor {
151
151
return ;
152
152
}
153
153
154
- if ( span . name === 'graphql.execute' ) {
154
+ if ( SPANS_WITH_ERRORS . includes ( span . name ) ) {
155
155
copyAttribute ( span , operationSpan , SEMATTRS_HIVE_GRAPHQL_ERROR_CODES ) ;
156
156
copyAttribute ( span , operationSpan , SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT ) ;
157
+ }
158
+
159
+ if ( span . name === 'graphql.execute' ) {
157
160
copyAttribute (
158
161
span ,
159
162
operationSpan ,
@@ -196,3 +199,9 @@ function copyAttribute(
196
199
) {
197
200
target . attributes [ targetAttrName ] = source . attributes [ sourceAttrName ] ;
198
201
}
202
+
203
+ const SPANS_WITH_ERRORS = [
204
+ 'graphql.parse' ,
205
+ 'graphql.validate' ,
206
+ 'graphql.execute' ,
207
+ ] ;
Original file line number Diff line number Diff line change @@ -770,9 +770,8 @@ describe('useOpenTelemetry', () => {
770
770
} ) ;
771
771
} ) ;
772
772
773
- it ( 'should handle validation error with hive processor' , async ( ) => {
773
+ it . only ( 'should handle validation error with hive processor' , async ( ) => {
774
774
disableAll ( ) ;
775
- const spanExporter = new MockSpanExporter ( ) ;
776
775
const traceProvider = new BasicTracerProvider ( {
777
776
spanProcessors : [
778
777
new HiveTracingSpanProcessor ( {
@@ -798,9 +797,15 @@ describe('useOpenTelemetry', () => {
798
797
} ) ;
799
798
800
799
const operationSpan = spanExporter . assertRoot ( 'graphql.operation test' ) ;
801
- operationSpan . span . attributes [ 'graphql.operation.name' ] === 'test' ;
802
- operationSpan . span . attributes [ 'graphql.operation.type' ] === 'query' ;
803
- operationSpan . span . attributes [ 'hive.graphql.error.count' ] === 1 ;
800
+ expect ( operationSpan . span . attributes [ 'graphql.operation.name' ] ) . toBe (
801
+ 'test' ,
802
+ ) ;
803
+ expect ( operationSpan . span . attributes [ 'graphql.operation.type' ] ) . toBe (
804
+ 'query' ,
805
+ ) ;
806
+ expect (
807
+ operationSpan . span . attributes [ SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT ] ,
808
+ ) . toBe ( 1 ) ;
804
809
} ) ;
805
810
} ) ;
806
811
You can’t perform that action at this time.
0 commit comments