@envelop/prometheus 6.4.1 → 6.4.3-alpha-62b6e087.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/typings/config.d.cts +17 -0
- package/typings/index.d.cts +11 -0
- package/typings/utils.d.cts +34 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/prometheus",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.3-alpha-62b6e087.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "
|
|
6
|
+
"@envelop/core": "2.4.3-alpha-62b6e087.0",
|
|
7
7
|
"prom-client": "^13 || ^14.0.0",
|
|
8
8
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
9
9
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
26
|
"require": {
|
|
27
|
-
"types": "./typings/index.d.
|
|
27
|
+
"types": "./typings/index.d.cts",
|
|
28
28
|
"default": "./cjs/index.js"
|
|
29
29
|
},
|
|
30
30
|
"import": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"./*": {
|
|
40
40
|
"require": {
|
|
41
|
-
"types": "./typings/*.d.
|
|
41
|
+
"types": "./typings/*.d.cts",
|
|
42
42
|
"default": "./cjs/*.js"
|
|
43
43
|
},
|
|
44
44
|
"import": {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createCounter, createHistogram, createSummary } from './utils.cjs';
|
|
2
|
+
import { Registry } from 'prom-client';
|
|
3
|
+
export declare type PrometheusTracingPluginConfig = {
|
|
4
|
+
requestCount?: boolean | ReturnType<typeof createCounter>;
|
|
5
|
+
requestTotalDuration?: boolean | ReturnType<typeof createHistogram>;
|
|
6
|
+
requestSummary?: boolean | ReturnType<typeof createSummary>;
|
|
7
|
+
parse?: boolean | ReturnType<typeof createHistogram>;
|
|
8
|
+
validate?: boolean | ReturnType<typeof createHistogram>;
|
|
9
|
+
contextBuilding?: boolean | ReturnType<typeof createHistogram>;
|
|
10
|
+
execute?: boolean | ReturnType<typeof createHistogram>;
|
|
11
|
+
errors?: boolean | ReturnType<typeof createCounter>;
|
|
12
|
+
resolvers?: boolean | ReturnType<typeof createHistogram>;
|
|
13
|
+
resolversWhitelist?: string[];
|
|
14
|
+
deprecatedFields?: boolean | ReturnType<typeof createCounter>;
|
|
15
|
+
registry?: Registry;
|
|
16
|
+
skipIntrospection?: boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from '@envelop/core';
|
|
2
|
+
import { createHistogram, createCounter, FillLabelsFnParams, createSummary } from './utils.cjs';
|
|
3
|
+
import { PrometheusTracingPluginConfig } from './config.cjs';
|
|
4
|
+
export { PrometheusTracingPluginConfig, createCounter, createHistogram, createSummary, FillLabelsFnParams };
|
|
5
|
+
declare const promPluginContext: unique symbol;
|
|
6
|
+
declare const promPluginExecutionStartTimeSymbol: unique symbol;
|
|
7
|
+
declare type PluginInternalContext = {
|
|
8
|
+
[promPluginContext]: FillLabelsFnParams;
|
|
9
|
+
[promPluginExecutionStartTimeSymbol]: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const usePrometheus: (config?: PrometheusTracingPluginConfig) => Plugin<PluginInternalContext>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { GraphQLError, DocumentNode, OperationDefinitionNode, GraphQLResolveInfo, TypeInfo, ASTNode } from 'graphql';
|
|
2
|
+
import { AfterParseEventPayload } from '@envelop/core';
|
|
3
|
+
import { PrometheusTracingPluginConfig } from './config.cjs';
|
|
4
|
+
import { Counter, Histogram, Summary } from 'prom-client';
|
|
5
|
+
export declare type DeprecatedFieldInfo = {
|
|
6
|
+
fieldName: string;
|
|
7
|
+
typeName: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type FillLabelsFnParams = {
|
|
10
|
+
document?: DocumentNode;
|
|
11
|
+
operationName?: string;
|
|
12
|
+
operationType?: OperationDefinitionNode['operation'];
|
|
13
|
+
info?: GraphQLResolveInfo;
|
|
14
|
+
errorPhase?: string;
|
|
15
|
+
error?: GraphQLError;
|
|
16
|
+
deprecationInfo?: DeprecatedFieldInfo;
|
|
17
|
+
};
|
|
18
|
+
export declare function shouldTraceFieldResolver(info: GraphQLResolveInfo, whitelist: string[] | undefined): boolean;
|
|
19
|
+
export declare function createInternalContext(parseResult: AfterParseEventPayload<any>['result']): FillLabelsFnParams | null;
|
|
20
|
+
export declare type FillLabelsFn<LabelNames extends string> = (params: FillLabelsFnParams, rawContext: any) => Record<LabelNames, string>;
|
|
21
|
+
export declare function createHistogram<LabelNames extends string>(options: {
|
|
22
|
+
histogram: Histogram<LabelNames>;
|
|
23
|
+
fillLabelsFn: FillLabelsFn<LabelNames>;
|
|
24
|
+
}): typeof options;
|
|
25
|
+
export declare function createSummary<LabelNames extends string>(options: {
|
|
26
|
+
summary: Summary<LabelNames>;
|
|
27
|
+
fillLabelsFn: FillLabelsFn<LabelNames>;
|
|
28
|
+
}): typeof options;
|
|
29
|
+
export declare function createCounter<LabelNames extends string>(options: {
|
|
30
|
+
counter: Counter<LabelNames>;
|
|
31
|
+
fillLabelsFn: FillLabelsFn<LabelNames>;
|
|
32
|
+
}): typeof options;
|
|
33
|
+
export declare function getHistogramFromConfig(config: PrometheusTracingPluginConfig, phase: keyof PrometheusTracingPluginConfig, name: string, help: string): ReturnType<typeof createHistogram> | undefined;
|
|
34
|
+
export declare function extractDeprecatedFields(node: ASTNode, typeInfo: TypeInfo): DeprecatedFieldInfo[];
|