Skip to content

Commit 675c2e6

Browse files
committed
add attribute for console to identify operation root span
1 parent 35741e4 commit 675c2e6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-hive/plugin-opentelemetry': patch
3+
---
4+
5+
Fix missing attributes when a graphql operation parsing or validation fails.

packages/plugins/opentelemetry/src/hive-span-processor.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export class HiveTracingSpanProcessor implements SpanProcessor {
7878
return;
7979
}
8080

81-
if (span.name.startsWith('graphql.operation')) {
81+
if (isOperationSpan(span)) {
82+
span.setAttribute('hive.graphql', true)
8283
traceState?.operationRoots.set(spanId, span as SpanImpl);
8384
return;
8485
}
@@ -200,6 +201,14 @@ function copyAttribute(
200201
target.attributes[targetAttrName] = source.attributes[sourceAttrName];
201202
}
202203

204+
function isOperationSpan(span: Span): boolean {
205+
if (!span.name.startsWith('graphql.operation')) {
206+
return false;
207+
}
208+
const followingChar = span.name.at(17);
209+
return !followingChar || followingChar === ' ';
210+
}
211+
203212
const SPANS_WITH_ERRORS = [
204213
'graphql.parse',
205214
'graphql.validate',

0 commit comments

Comments
 (0)