Skip to content

Commit 21313c3

Browse files
committed
fix opentelemetry e2e
1 parent 914d5a2 commit 21313c3

File tree

1 file changed

+79
-3
lines changed

1 file changed

+79
-3
lines changed

e2e/opentelemetry/opentelemetry.e2e.ts

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,17 @@ type JaegerTraceResource = {
5555
tags: JaegerTraceTag[];
5656
};
5757

58+
type JaegerTraceLog = {
59+
timestamp: number;
60+
fields: JaegerTraceTag[];
61+
};
62+
5863
type JaegerTraceSpan = {
5964
traceID: string;
6065
spanID: string;
6166
operationName: string;
6267
tags: Array<JaegerTraceTag>;
68+
logs: Array<JaegerTraceLog>;
6369
references: Array<{ refType: string; spanID: string; traceID: string }>;
6470
};
6571

@@ -402,6 +408,30 @@ describe('OpenTelemetry', () => {
402408
expect(relevantTrace?.spans).toContainEqual(
403409
expect.objectContaining({ operationName: 'POST /graphql' }),
404410
);
411+
412+
const operationSpan = relevantTrace!.spans.find(
413+
(span) => span.operationName === 'graphql.operation',
414+
);
415+
416+
expect(operationSpan?.logs).toContainEqual(
417+
expect.objectContaining({
418+
fields: expect.arrayContaining([
419+
expect.objectContaining({
420+
key: 'event',
421+
value: 'graphql.error',
422+
}),
423+
expect.objectContaining({
424+
key: 'hive.graphql.error.locations',
425+
value: '["1:13"]',
426+
}),
427+
expect.objectContaining({
428+
key: 'hive.graphql.error.message',
429+
value: 'Syntax Error: Expected Name, found <EOF>.',
430+
}),
431+
]),
432+
}),
433+
);
434+
405435
expect(relevantTrace?.spans).toContainEqual(
406436
expect.objectContaining({
407437
operationName: 'graphql.parse',
@@ -416,7 +446,7 @@ describe('OpenTelemetry', () => {
416446
}),
417447
expect.objectContaining({
418448
key: 'otel.status_description',
419-
value: 'Syntax Error: Expected Name, found <EOF>.',
449+
value: 'GraphQL Parse Error',
420450
}),
421451
expect.objectContaining({
422452
key: 'hive.graphql.error.count',
@@ -477,6 +507,53 @@ describe('OpenTelemetry', () => {
477507
expect(relevantTrace?.spans).toContainEqual(
478508
expect.objectContaining({ operationName: 'POST /graphql' }),
479509
);
510+
expect(relevantTrace?.spans).toContainEqual(
511+
expect.objectContaining({
512+
operationName: 'graphql.operation',
513+
tags: expect.arrayContaining([
514+
expect.objectContaining({
515+
key: 'otel.status_code',
516+
value: 'ERROR',
517+
}),
518+
expect.objectContaining({
519+
key: 'error',
520+
value: true,
521+
}),
522+
expect.objectContaining({
523+
key: 'otel.status_description',
524+
value: 'GraphQL Validation Error',
525+
}),
526+
expect.objectContaining({
527+
key: 'hive.graphql.error.count',
528+
value: 1,
529+
}),
530+
]),
531+
}),
532+
);
533+
const operationSpan = relevantTrace!.spans.find(
534+
(span) => span.operationName === 'graphql.operation',
535+
);
536+
537+
expect(operationSpan?.logs).toContainEqual(
538+
expect.objectContaining({
539+
fields: expect.arrayContaining([
540+
expect.objectContaining({
541+
key: 'event',
542+
value: 'graphql.error',
543+
}),
544+
expect.objectContaining({
545+
key: 'hive.graphql.error.locations',
546+
value: '["1:9"]',
547+
}),
548+
expect.objectContaining({
549+
key: 'hive.graphql.error.message',
550+
value:
551+
'Cannot query field "nonExistentField" on type "Query".',
552+
}),
553+
]),
554+
}),
555+
);
556+
480557
expect(relevantTrace?.spans).toContainEqual(
481558
expect.objectContaining({ operationName: 'graphql.parse' }),
482559
);
@@ -494,8 +571,7 @@ describe('OpenTelemetry', () => {
494571
}),
495572
expect.objectContaining({
496573
key: 'otel.status_description',
497-
value:
498-
'Cannot query field "nonExistentField" on type "Query".',
574+
value: 'GraphQL Validation Error',
499575
}),
500576
expect.objectContaining({
501577
key: 'hive.graphql.error.count',

0 commit comments

Comments
 (0)