graphql-hive / graphql-hive/envelop

[usePrometheus] Add resolver success and error metrics

Open
#2,161 3 comments 0 reactions 0 assignees View on GitHub
kind/enhancement
Dominant language
No language data
Stars
827
Forks
132
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

We'd like to capture success and failure prometheus metrics for specific resolvers to build SLOs against. At the moment, the only data captured for resolvers is the duration.

**Describe the solution you'd like**

Two new counter metrics, `graphql_envelop_resolver_success_total` and `graphql_envelop_resolver_error_total` which capture the total number of successful and unsuccessful resolver executions. They would follow the same labelling at the existing resolver execution time (i.e. `resolver="{Type}.{field}`).

**Describe alternatives you've considered**

It would be possible to handle this using the operation metrics, and capture success/failure of the whole operation by `operationName`, but this has some issues:
* Infinite cardinality - particularly in the case of a public graph, there could be 1000s of different operation names
* Naming collisions - there may be multiple operations which contain the same name, which would skew metrics
* We may only care about a nested resolver - if multiple individuals contribute to the same document, different individuals may care about different portions of the operation and want to track specific paths.

**Additional context**

Using the `useOnResolve` plugin, it should be relatively straightforward to add this counter in by checking if the `result` is an instance of an `Error`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.