File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import client from 'prom-client';
22import { ApolloServerPlugin , GraphQLRequestContext , GraphQLRequestListener } from 'apollo-server-plugin-base' ;
33import { GraphQLError } from 'graphql' ;
44import 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
You can’t perform that action at this time.
0 commit comments