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

[@envelop/plugin-prometheus] Need a way to filter which metrics are recorded #2312

Open
klippx opened this issue Oct 10, 2024 · 0 comments · May be fixed by #2317
Open

[@envelop/plugin-prometheus] Need a way to filter which metrics are recorded #2312

klippx opened this issue Oct 10, 2024 · 0 comments · May be fixed by #2317

Comments

@klippx
Copy link
Contributor

klippx commented Oct 10, 2024

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

In our federated setup we have to be restrictive on histogram metrics, our we will have too much metrics too scrape. To some extent this can be fixed by customizing labels and reducing cardinality, but in some cases we actually want to opt in to the high cardinality metrics for a selection of operations.

Thus, we would like to have e.g. graphql_yoga_http_duration enabled but only if operationName matches certain allow listed values.

Describe the solution you'd like

We would like to be able to have a (mesh) config like this in the end

{
  prometheus: {
    metrics: {
      graphql_yoga_http_duration: createHistogram({
        registry,
        histogram: {
          name: 'graphql_yoga_http_duration',
          help: 'Time spent on HTTP connection',
          labelNames: ['operation_name'],
          buckets: HISTOGRAM_BUCKET_DIMENSIONS,
        },
        fillLabelsFn: ({ operationName }, _rawContext) => ({
          operation_name: operationName,
        }),
        shouldRecordFn: ({ operationName }, _rawContext) =>
          TRACKED_OPERATIONS.includes(operationName),
      })
    }
  }
}

Describe alternatives you've considered

Have to build our own stack of plugins all the way down to envelop (mesh plugin, yoga plugin, envelop plugin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant