Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[usePrometheus] Add resolver success and error metrics #2161

Open
RMHonor opened this issue Mar 1, 2024 · 3 comments
Open

[usePrometheus] Add resolver success and error metrics #2161

RMHonor opened this issue Mar 1, 2024 · 3 comments
Labels
kind/enhancement New feature or request

Comments

@RMHonor
Copy link

RMHonor commented Mar 1, 2024

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.

@EmrysMyrddin EmrysMyrddin added the kind/enhancement New feature or request label Mar 1, 2024
@EmrysMyrddin
Copy link
Collaborator

Hey! Thank you for the proposition. It seems a good idea, perhaps we just should have options enable/disable this metrics to allow users to avoid having too much data. Perhaps even an allow/disallow list of type and fields ?

We will probably not have the bandwidth to implement this in a short term, but PR are welcome and we are here if someone have questions about how to do it :-)

@RMHonor
Copy link
Author

RMHonor commented Mar 1, 2024

Hey! Thank you for the proposition. It seems a good idea, perhaps we just should have options enable/disable this metrics to allow users to avoid having too much data. Perhaps even an allow/disallow list of type and fields ?

We will probably not have the bandwidth to implement this in a short term, but PR are welcome and we are here if someone have questions about how to do it :-)

Happy to PR!

There already is an option to enable/disable the existing resolver field, maybe it could be turned into an object to be more granular? There's also resolverWhitelist options which only traces those specified, could just piggyback off that existing option.

@EmrysMyrddin
Copy link
Collaborator

Oh, yeah, keep it simple for now, it was just an idea :-) Let's wait to see if this is something actually needed by some users :-)

You can go with the just the existing option for a first version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants