UNPKG

@graphql-mesh/plugin-prometheus

Version:
39 lines (38 loc) 2.07 kB
import { type Plugin as YogaPlugin } from 'graphql-yoga'; import { Registry } from 'prom-client'; import { MeshServePlugin } from '@graphql-mesh/serve-runtime'; import type { TransportEntry } from '@graphql-mesh/transport-common'; import { Logger, MeshPlugin, type ImportFn, type MeshFetchRequestInit, type OnDelegateHookPayload } from '@graphql-mesh/types'; import type { ExecutionRequest } from '@graphql-tools/utils'; import type { CounterAndLabels, FillLabelsFnParams, HistogramAndLabels, PrometheusTracingPluginConfig, SummaryAndLabels } from '@graphql-yoga/plugin-prometheus'; import { createCounter, createHistogram, createSummary } from '@graphql-yoga/plugin-prometheus'; export { CounterAndLabels, FillLabelsFnParams, HistogramAndLabels, SummaryAndLabels, createCounter, createHistogram, createSummary, }; type MeshMetricsConfig = { delegation?: boolean | string | HistogramAndLabels<string, Omit<OnDelegateHookPayload<unknown>, 'context'> | undefined>; delegationArgs?: boolean; delegationKey?: boolean; subgraphExecute?: boolean | string | HistogramAndLabels<'subgraphName' | 'operationType', SubgraphMetricsLabelParams>; subgraphExecuteErrors?: boolean | string | CounterAndLabels<'subgraphName' | 'operationType', SubgraphMetricsLabelParams>; fetchMetrics?: boolean | string | HistogramAndLabels<string, { url: string; options: MeshFetchRequestInit; response: Response; }>; fetchRequestHeaders?: boolean; fetchResponseHeaders?: boolean; }; type PrometheusPluginOptions = Omit<PrometheusTracingPluginConfig, 'registry'> & YamlConfig & // Remove this after Mesh v1 is released; MeshMetricsConfig & { logger?: Logger; }; type YamlConfig = { baseDir?: string; importFn?: ImportFn; registry?: Registry | string; }; type SubgraphMetricsLabelParams = { subgraphName: string; transportEntry?: TransportEntry; executionRequest: ExecutionRequest; }; export default function useMeshPrometheus(pluginOptions: PrometheusPluginOptions): MeshPlugin<any> & YogaPlugin & MeshServePlugin;