UNPKG

@graphql-mesh/plugin-prometheus

Version:
59 lines (58 loc) 2.63 kB
import { type Plugin as YogaPlugin } from 'graphql-yoga'; import type { Registry } from 'prom-client'; import type { MeshServePlugin } from '@graphql-mesh/serve-runtime'; import type { TransportEntry } from '@graphql-mesh/transport-common'; import type { ImportFn, Logger, MeshFetchRequestInit, MeshPlugin, 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 { createCounter, createHistogram, createSummary }; export type { CounterAndLabels, FillLabelsFnParams, HistogramAndLabels, SummaryAndLabels }; type MeshMetricsConfig = { /** * @deprecated Graph delegation is no longer a concept in Mesh v1, use `subgraphExecute` instead */ delegation?: boolean | string | HistogramAndLabels<string, Omit<OnDelegateHookPayload<unknown>, 'context'> | undefined>; /** * @deprecated Graph delegation is no longer a concept in Mesh v1 */ delegationArgs?: boolean; /** * @deprecated Graph delegation is no longer a concept in Mesh v1 */ 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; }>; /** * @deprecated Use `labels.fetchRequestHeaders` instead */ fetchRequestHeaders?: boolean; /** * @deprecated Use `labels.fetchResponseHeaders` instead */ fetchResponseHeaders?: boolean; labels?: { 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;