On this page

@graphql-yoga/plugin-prometheus

Changelog for @graphql-yoga/plugin-prometheus: every release with its changes and the pull requests behind them.

7.0.0

Major Changes

  • #4574 79b0e8b Thanks @egoodwinx! - ### Breaking Changes

    • Node: minimum supported version is now Node 22. Node 18 and 20 are no longer supported. Future releases will only support Node >=22.
    • GraphQL: minimum supported version is now GraphQL 16. GraphQL 14 and 15 are no longer supported.
    • Request body parsing: Yoga now limits request bodies to 25,000,000 bytes by default. Enforcing this limit streams the body through a byte counter, making POST body parsing asynchronous even for an in-memory body. As a result, yoga.fetch() can return a Promise where it previously returned a synchronous Response, even when all resolvers and plugins are synchronous.

    Migration

    • If you’re on Node 18/20, upgrade to Node 22 or later before upgrading this package.
    • If you’re on graphql 14/15, upgrade to graphql 16 or 17 first.
    • Await yoga.fetch() and response body parsing instead of relying on synchronous results. Set maxRequestBodySize: false in createYoga to disable the body-size limit and preserve synchronous parsing for in-memory bodies, but only if you enforce an appropriate request-body limit elsewhere.

Patch Changes

6.19.6

Patch Changes

  • Updated dependencies [9294289]:
    • graphql-yoga@5.24.6

6.19.5

Patch Changes

  • Updated dependencies []:
    • graphql-yoga@5.24.5

6.19.4

Patch Changes

  • Updated dependencies [d8b8860]:
    • graphql-yoga@5.24.4

6.19.3

Patch Changes

  • Updated dependencies [c6febdc]:
    • graphql-yoga@5.24.3

6.19.2

Patch Changes

  • Updated dependencies [c08efde]:
    • graphql-yoga@5.24.2

6.19.1

Patch Changes

  • Updated dependencies [c6a9aa4]:
    • graphql-yoga@5.24.1

6.19.0

Patch Changes

6.18.0

Patch Changes

6.17.0

Minor Changes

  • #4545 94ebe5b Thanks @egoodwinx! - Update to support graphql-js 17

    Bump package versions, fix expected typing, and update compatability with subscribe.

Patch Changes

  • Updated dependencies [94ebe5b]:
    • @envelop/prometheus@14.2.0
    • graphql-yoga@5.22.0

6.16.3

Patch Changes

  • Updated dependencies [04014d2]:
    • graphql-yoga@5.21.3

6.16.2

Patch Changes

  • Updated dependencies [39b55ba]:
    • graphql-yoga@5.21.2

6.16.1

Patch Changes

  • Updated dependencies [4b43efd]:
    • graphql-yoga@5.21.1

6.16.0

Patch Changes

  • Updated dependencies [e263f7e]:
    • graphql-yoga@5.21.0

6.15.0

Patch Changes

  • Updated dependencies [93f1dc0]:
    • graphql-yoga@5.20.0

6.14.0

Patch Changes

  • Updated dependencies [7e0aaf6]:
    • graphql-yoga@5.19.0

6.13.1

Patch Changes

6.13.0

Patch Changes

  • Updated dependencies [3eabd17]:
    • graphql-yoga@5.18.0

6.12.1

Patch Changes

  • Updated dependencies [c27f550]:
    • graphql-yoga@5.17.1

6.12.0

Patch Changes

6.11.3

Patch Changes

  • #4296 d39201e Thanks @enisdenjo! - Plugin stops and handles parsing errors

    Previously it would throw an unhandled exception becauase Prometheus was expecting a GraphQL document in onParse hook always, but it can also be an error.

6.11.2

Patch Changes

6.11.1

Patch Changes

6.11.0

Patch Changes

6.10.2

Patch Changes

  • Updated dependencies [e7b8906]:
    • graphql-yoga@5.15.2

6.10.1

Patch Changes

  • Updated dependencies [ecd605b]:
    • graphql-yoga@5.15.1

6.10.0

Patch Changes

6.9.0

Patch Changes

6.8.5

Patch Changes

  • Updated dependencies [8b41a52]:
    • graphql-yoga@5.13.5

6.8.4

Patch Changes

  • Updated dependencies [000c33d]:
    • graphql-yoga@5.13.4

6.8.3

Patch Changes

6.8.2

Patch Changes

6.8.1

Patch Changes

6.8.0

Patch Changes

6.7.2

Patch Changes

  • Updated dependencies [a6b3de9]:
    • graphql-yoga@5.12.2

6.7.1

Patch Changes

  • Updated dependencies [fbf328c]:
    • graphql-yoga@5.12.1

6.7.0

Patch Changes

6.6.0

Patch Changes

6.5.9

Patch Changes

  • Updated dependencies [1c055f5]:
    • graphql-yoga@5.10.11

6.5.8

Patch Changes

  • Updated dependencies []:
    • graphql-yoga@5.10.10

6.5.7

Patch Changes

  • #3651 690294a Thanks @ardatan! - request is missing when GraphQL WS is used as expected, and as we don’t need HTTP/Yoga specific metrics, this should be skipped

6.5.6

Patch Changes

6.5.5

Patch Changes

  • Updated dependencies [ed344ea]:
    • graphql-yoga@5.10.8

6.5.4

Patch Changes

6.5.3

Patch Changes

  • Updated dependencies [121ccba]:
    • graphql-yoga@5.10.6

6.5.2

Patch Changes

6.5.1

Patch Changes

6.5.0

Minor Changes

  • #3489 131dfa3 Thanks @EmrysMyrddin! - Allow to explicitly control which events and timing should be observe.

    Each metric can now be configured to observe events and timings only for certain GraphQL pipeline phases, or depending on the request context.

    Example: trace only execution and subscription errors

    import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
    import { envelop, useEngine } from '@envelop/core'
    import { usePrometheus } from '@envelop/prometheus'
    
    const TRACKED_OPERATION_NAMES = [
      // make a list of operation that you want to monitor
    ]
    
    const getEnveloped = envelop({
      plugins: [
        useEngine({ parse, validate, specifiedRules, execute, subscribe }),
        usePrometheus({
          metrics: {
            // Here, an array of phases can be provided to enable the metric only on certain phases.
            // In this example, only error happening during the execute and subscribe phases will tracked
            graphql_envelop_phase_error: ['execute', 'subscribe']
          }
        })
      ]
    })

    Example: Monitor timing only of a set of operations by name

    import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
    import { envelop, useEngine } from '@envelop/core'
    import { usePrometheus } from '@envelop/prometheus'
    
    const TRACKED_OPERATION_NAMES = [
      // make a list of operation that you want to monitor
    ]
    
    const getEnveloped = envelop({
      plugins: [
        useEngine({ parse, validate, specifiedRules, execute, subscribe }),
        usePrometheus({
          metrics: {
            graphql_yoga_http_duration: createHistogram({
              registry,
              histogram: {
                name: 'graphql_envelop_request_duration',
                help: 'Time spent on HTTP connection',
                labelNames: ['operationName']
              },
              fillLabelsFn: ({ operationName }, _rawContext) => ({ operationName }),
              phases: ['execute', 'subscribe'],
    
              // Here `shouldObserve` control if the request timing should be observed, based on context
              shouldObserve: ({ operationName }) => TRACKED_OPERATIONS.includes(operationName)
            })
          }
        })
      ]
    })

    Default Behavior Change

    A metric is enabled using true value in metrics options will observe in every phases available.

    Previously, which phase was observe was depending on which other metric were enabled. For example, this config would only trace validation error:

    usePrometheus({
      metrics: {
        graphql_envelop_phase_error: true,
        graphql_envelop_phase_validate: true
      }
    })

    This is no longer the case. If you were relying on this behavior, please use an array of string to restrict observed phases.

    usePrometheus({
      metrics: {
        graphql_envelop_phase_error: ['validate']
      }
    })

    Deprecation

    The fillLabelFn function was provided the response and request through the context argument.

    This is now deprecated, request and response are now available in the first params argument. This change allows to provide better typing, since context is not typed.

Patch Changes

6.4.3

Patch Changes

6.4.2

Patch Changes

6.4.1

Patch Changes

  • Updated dependencies [20cd9b6]:
    • graphql-yoga@5.10.1

6.4.0

Patch Changes

  • Updated dependencies [f81501c]:
    • graphql-yoga@5.10.0

6.3.0

Patch Changes

6.2.0

Patch Changes

6.1.0

Patch Changes

6.0.0

Major Changes

  • #3391 0788d8a Thanks @EmrysMyrddin! - Breaking Change: Rename all metrics options to their actual metric name to avoid confusion.

    All metric options have been moved under a mandatory metrics key, and the name of each options have been renamed to match the default metric name.

    The plugin option argument is also now mandatory.

    export const serveConfig = defineConfig({
      plugins: pluginCtx => [
        usePrometheus({
          ...pluginCtx,
    
          // Enable all available metrics
    -     http: true
    -     requestSummary: true,
    -     parse: true,
    -     validate: true,
    -     contextBuilding: true,
    -     execute: true,
    -     subscribe: true,
    -     errors: true,
    -     deprecatedFields: true,
    -     requestTotalDuration: true,
    -     schemaChangeCount: true,
    
          // Warning: enabling resolvers level metrics will introduce significant overhead
    -     resolvers: true,
    +     metrics: {
    +       graphql_yoga_http_duration: true,
    +       graphql_envelop_request_time_summary: true,
    +       graphql_envelop_phase_parse: true,
    +       graphql_envelop_phase_validate: true,
    +       graphql_envelop_phase_context: true,
    +       graphql_envelop_phase_execute: true,
    +       graphql_envelop_phase_subscribe: true,
    +       graphql_envelop_error_result: true,
    +       graphql_envelop_deprecated_field: true,
    +       graphql_envelop_request_duration: true,
    +       graphql_envelop_schema_change: true,
    
            // Warning: enabling resolvers level metrics will introduce significant overhead
    +       graphql_envelop_execute_resolver: true,
    +     }
        })
      ]
    })
  • #3408 88393b3 Thanks @dotansimha! - By default, the following metrics are now enabled:

    • graphql_envelop_deprecated_field
    • graphql_envelop_request
    • graphql_envelop_request_duration
    • graphql_envelop_request_time_summary
    • graphql_envelop_phase_parse
    • graphql_envelop_phase_validate
    • graphql_envelop_phase_context
    • graphql_envelop_error_result
    • graphql_envelop_phase_execute
    • graphql_envelop_phase_subscribe
    • graphql_envelop_schema_change
    • graphql_yoga_http_duration

Minor Changes

  • #3391 0788d8a Thanks @EmrysMyrddin! - Add missing labels path and phase of graphql_envelop_error_result metric to the configuration.

    Add missing labels method and statusCode of graphql_yoga_http_duration metric to the configuration.

Patch Changes

5.3.3

Patch Changes

  • Updated dependencies [0866c1b]:
    • graphql-yoga@5.6.3

5.3.2

Patch Changes

5.3.1

Patch Changes

  • Updated dependencies [4252e3d]:
    • graphql-yoga@5.6.1

5.3.0

Patch Changes

  • Updated dependencies [9f3f945]:
    • graphql-yoga@5.6.0

5.2.0

Patch Changes

  • Updated dependencies [0208024]:
    • graphql-yoga@5.5.0

5.1.0

Patch Changes

5.0.0

Major Changes

  • #3251 a8ddac54 Thanks @EmrysMyrddin! - Adds a cache for metrics definition (Summary, Histogram and Counter).

    Fixes an issue preventing this plugin to be initialized multiple times, leading to metrics duplication error (https://github.com/ardatan/graphql-mesh/issues/6545).

    Behavior Breaking Change:

    Due to Prometheus client API limitations, a metric is only defined once for a given registry. This means that if the configuration of the metrics, it will be silently ignored on plugin re-initialization.

    This is to avoid potential loss of metrics data produced between the plugin re-initialization and the last pull by the prometheus agent.

    If you need to be sure metrics configuration is up to date after a plugin re-initialization, you can either:

    • restart the whole node process instead of just recreating a graphql server at runtime
    • clear the registry using registry.clear() before plugin re-initialization:
      function usePrometheusWithReset() {
        registry.clear()
        return usePrometheus({ ... })
      }
    • use a new registry for each plugin instance:
      function usePrometheusWithRegistry() {
        const registry = new Registry()
        return usePrometheus({
          registry,
          ...
        })
      }

    Keep in mind that this implies potential data loss in pull mode.

    API Breaking Change:

    To ensure metrics from being registered multiple times on the same registry, the signature of createHistogram, createSummary and createCounter have been changed to now include the registry as a mandatory parameter.

    If you were customizing metrics parameters, you will need to update the metric definitions

    usePrometheus({
      execute: createHistogram({
    +   registry: registry
        histogram: new Histogram({
          name: 'my_custom_name',
          help: 'HELP ME',
          labelNames: ['opText'] as const,
    -     registers: [registry],
        }),
        fillLabelsFn: () => {}
      }),
      requestCount: createCounter({
    +   registry: registry
        histogram: new Histogram({
          name: 'my_custom_name',
          help: 'HELP ME',
          labelNames: ['opText'] as const,
    -     registers: [registry],
        }),
        fillLabelsFn: () => {}
      }),
      requestSummary: createSummary({
    +   registry: registry
        histogram: new Histogram({
          name: 'my_custom_name',
          help: 'HELP ME',
          labelNames: ['opText'] as const,
    -     registers: [registry],
        }),
        fillLabelsFn: () => {}
      }),
    })

Patch Changes

4.2.0

Patch Changes

4.1.0

Minor Changes

  • 9047d76d Thanks @ardatan! - Ability to rename the metrics without creating a new histogram

Patch Changes

4.0.0

Major Changes

3.1.2

Patch Changes

3.1.1

Patch Changes

  • Updated dependencies [3ef877a7]:
    • graphql-yoga@5.1.1

3.1.0

Patch Changes

  • Updated dependencies [b1f0e3a2]:
    • graphql-yoga@5.1.0

3.0.2

Patch Changes

  • Updated dependencies [77d107fe]:
    • graphql-yoga@5.0.2

3.0.1

Patch Changes

  • Updated dependencies [3fea19f2]:
    • graphql-yoga@5.0.1

3.0.0

Major Changes

Patch Changes

2.0.6

Patch Changes

2.0.5

Patch Changes

2.0.4

Patch Changes

  • Updated dependencies [5f182006]:
    • graphql-yoga@4.0.4

2.0.3

Patch Changes

  • Updated dependencies [5efb8250]:
    • graphql-yoga@4.0.3

2.0.2

Patch Changes

  • Updated dependencies [ce6d2465]:
    • graphql-yoga@4.0.2

2.0.1

Patch Changes

2.0.0

Major Changes

Patch Changes

1.9.1

Patch Changes

1.9.0

Patch Changes

  • Updated dependencies [aff69200]:
    • graphql-yoga@3.9.0

1.8.1

Patch Changes

1.8.0

Patch Changes

1.7.3

Patch Changes

  • Updated dependencies [46e75917]:
    • graphql-yoga@3.7.3

1.7.2

Patch Changes

  • Updated dependencies [7ad50529]:
    • graphql-yoga@3.7.2

1.7.1

Patch Changes

1.7.0

Patch Changes

1.6.1

Patch Changes

  • Updated dependencies [3c8c8434]:
    • graphql-yoga@3.6.1

1.6.0

Patch Changes

1.5.1

Patch Changes

  • Updated dependencies [3a8446df]:
    • graphql-yoga@3.5.1

1.5.0

Patch Changes

  • Updated dependencies [03597a5a]:
    • graphql-yoga@3.5.0

1.4.1

Patch Changes

1.4.0

Patch Changes

1.3.1

Patch Changes

  • Updated dependencies [d4dab446]:
    • graphql-yoga@3.3.1

1.3.0

Patch Changes

1.2.1

Patch Changes

  • Updated dependencies [5528d312]:
    • graphql-yoga@3.2.1

1.2.0

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

  • Updated dependencies [534780c9]:
    • graphql-yoga@3.1.1

1.1.0

Patch Changes

1.0.3

Patch Changes

1.0.2

Patch Changes

1.0.1

Patch Changes

  • Updated dependencies [d63fe841]:
    • graphql-yoga@3.0.1

1.0.0

Major Changes

Patch Changes

1.0.0-next.6

Patch Changes

  • Updated dependencies [73e56068]:
    • graphql-yoga@3.0.0-next.12

1.0.0-next.5

Patch Changes

1.0.0-next.4

Patch Changes

1.0.0-next.3

Patch Changes

1.0.0-next.2

Patch Changes

  • Updated dependencies [6e250209]:
    • graphql-yoga@3.0.0-next.8

1.0.0-next.1

Patch Changes

1.0.0-next.0

Major Changes

Patch Changes

  • Updated dependencies [dc45a7b5]:
    • graphql-yoga@3.0.0-next.6