Skip to content

Conditionally escape yoga http duration histogram #3443

Open
@klippx

Description

@klippx

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

We are using hive-gateway and the prometheus plugin. We want to conditionally use graphql_yoga_http_duration for certain operations only, but it can only always be used or never be used.

Describe the solution you'd like

    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,
        }),
        // A hook to decide when recording should be made
        shouldRecordFn: ({ operationName }, _rawContext) =>
          TRACKED_OPERATIONS.includes(operationName),
      }),
    },

Describe alternatives you've considered

Build our own middleware stack mostly duplicating everything

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions