UNPKG

@envelop/prometheus

Version:

This plugin tracks the complete execution flow, and reports metrics using Prometheus tracing (based on `prom-client`).

35 lines (34 loc) 1.9 kB
import { GraphQLError, DocumentNode, OperationDefinitionNode, GraphQLResolveInfo, TypeInfo, ASTNode } from 'graphql'; import { AfterParseEventPayload } from '@envelop/core'; import { PrometheusTracingPluginConfig } from './config.js'; import { Counter, Histogram, Summary } from 'prom-client'; export declare type DeprecatedFieldInfo = { fieldName: string; typeName: string; }; export declare type FillLabelsFnParams = { document?: DocumentNode; operationName?: string; operationType?: OperationDefinitionNode['operation']; info?: GraphQLResolveInfo; errorPhase?: string; error?: GraphQLError; deprecationInfo?: DeprecatedFieldInfo; }; export declare function shouldTraceFieldResolver(info: GraphQLResolveInfo, whitelist: string[] | undefined): boolean; export declare function createInternalContext(parseResult: AfterParseEventPayload<any>['result']): FillLabelsFnParams | null; export declare type FillLabelsFn<LabelNames extends string> = (params: FillLabelsFnParams, rawContext: any) => Record<LabelNames, string>; export declare function createHistogram<LabelNames extends string>(options: { histogram: Histogram<LabelNames>; fillLabelsFn: FillLabelsFn<LabelNames>; }): typeof options; export declare function createSummary<LabelNames extends string>(options: { summary: Summary<LabelNames>; fillLabelsFn: FillLabelsFn<LabelNames>; }): typeof options; export declare function createCounter<LabelNames extends string>(options: { counter: Counter<LabelNames>; fillLabelsFn: FillLabelsFn<LabelNames>; }): typeof options; export declare function getHistogramFromConfig(config: PrometheusTracingPluginConfig, phase: keyof PrometheusTracingPluginConfig, name: string, help: string): ReturnType<typeof createHistogram> | undefined; export declare function extractDeprecatedFields(node: ASTNode, typeInfo: TypeInfo): DeprecatedFieldInfo[];