Skip to content

Commit

Permalink
add url to labels to filter non graphql requests from metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
EmrysMyrddin committed Aug 2, 2024
1 parent 7e26e11 commit 65bfde9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/plugins/prometheus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export type PrometheusTracingPluginConfig = EnvelopPrometheusTracingPluginConfig
* The status code of the response
*/
statusCode?: boolean;
/**
* The url of the HTTP request
*/
url?: boolean;
};

/**
Expand All @@ -71,13 +75,14 @@ export function usePrometheus(options: PrometheusTracingPluginConfig): Plugin {
'graphql_yoga_http_duration',
{
help: 'Time spent on HTTP connection',
labelNames: ['operationName', 'operationType', 'method', 'statusCode'],
labelNames: ['operationName', 'operationType', 'method', 'statusCode', 'url'],
},
(params, { request, response }) => ({
method: request.method,
statusCode: response.status,
operationType: params.operationType || 'unknown',
operationName: params.operationName || 'Anonymous',
url: request.url,
}),
);

Expand Down

0 comments on commit 65bfde9

Please sign in to comment.