Skip to content

Commit 18f14eb

Browse files
committed
fix: lint
1 parent 516c5ea commit 18f14eb

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/metrics/graphql.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import client from 'prom-client';
22
import { ApolloServerPlugin, GraphQLRequestContext, GraphQLRequestListener } from 'apollo-server-plugin-base';
33
import { GraphQLError } from 'graphql';
44
import HawkCatcher from '@hawk.so/nodejs';
5-
65
/**
76
* GraphQL operation duration histogram
87
* Tracks GraphQL operation duration by operation name and type
@@ -81,22 +80,17 @@ export const graphqlMetricsPlugin: ApolloServerPlugin = {
8180

8281
const hasErrors = ctx.errors && ctx.errors.length > 0;
8382

84-
const breadcrumbData: Record<string, string | number> = {
85-
operationName,
86-
operationType,
87-
durationMs,
88-
};
89-
90-
if (hasErrors) {
91-
breadcrumbData.errors = ctx.errors!.map((e: GraphQLError) => e.message).join('; ');
92-
}
93-
9483
HawkCatcher.breadcrumbs.add({
9584
type: 'request',
9685
category: 'gql',
9786
message: `${operationType} ${operationName} ${durationMs}ms${hasErrors ? ` [${ctx.errors!.length} error(s)]` : ''}`,
9887
level: hasErrors ? 'error' : 'debug',
99-
data: breadcrumbData,
88+
data: {
89+
operationName: { value: operationName },
90+
operationType: { value: operationType },
91+
durationMs: { value: durationMs },
92+
...(hasErrors && { errors: { value: ctx.errors!.map((e: GraphQLError) => e.message).join('; ') } }),
93+
},
10094
});
10195

10296
// Track errors if any

0 commit comments

Comments
 (0)