@envelop/prometheus 5.0.0-alpha-15b486f.0 → 5.0.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/index.d.ts +1 -1
- package/index.js +3 -15
- package/index.mjs +2 -14
- package/package.json +5 -4
- package/utils.d.ts +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '@envelop/
|
|
1
|
+
import { Plugin } from '@envelop/core';
|
|
2
2
|
import { createHistogram, createCounter, FillLabelsFnParams, createSummary } from './utils';
|
|
3
3
|
import { PrometheusTracingPluginConfig } from './config';
|
|
4
4
|
export { PrometheusTracingPluginConfig, createCounter, createHistogram, createSummary, FillLabelsFnParams };
|
package/index.js
CHANGED
|
@@ -2,21 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const promClient = require('prom-client');
|
|
6
|
-
const graphql = require('graphql');
|
|
7
5
|
const core = require('@envelop/core');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Returns true if the provided object implements the AsyncIterator protocol via
|
|
11
|
-
* implementing a `Symbol.asyncIterator` method.
|
|
12
|
-
*
|
|
13
|
-
* Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
|
|
14
|
-
*/
|
|
15
|
-
function isAsyncIterable(maybeAsyncIterable) {
|
|
16
|
-
return (maybeAsyncIterable != null &&
|
|
17
|
-
typeof maybeAsyncIterable === 'object' &&
|
|
18
|
-
typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
|
|
19
|
-
}
|
|
6
|
+
const graphql = require('graphql');
|
|
7
|
+
const promClient = require('prom-client');
|
|
20
8
|
|
|
21
9
|
function shouldTraceFieldResolver(info, whitelist) {
|
|
22
10
|
if (!whitelist) {
|
|
@@ -293,7 +281,7 @@ const usePrometheus = (config = {}) => {
|
|
|
293
281
|
const summaryTime = (Date.now() - args.contextValue[promPluginExecutionStartTimeSymbol]) / 1000;
|
|
294
282
|
requestSummary.summary.observe(requestSummary.fillLabelsFn(args.contextValue[promPluginContext], args.contextValue), summaryTime);
|
|
295
283
|
}
|
|
296
|
-
if (errorsCounter && !isAsyncIterable(result) && result.errors && result.errors.length > 0) {
|
|
284
|
+
if (errorsCounter && !core.isAsyncIterable(result) && result.errors && result.errors.length > 0) {
|
|
297
285
|
for (const error of result.errors) {
|
|
298
286
|
errorsCounter.counter
|
|
299
287
|
.labels(errorsCounter.fillLabelsFn({
|
package/index.mjs
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isIntrospectionOperationString, isAsyncIterable } from '@envelop/core';
|
|
2
2
|
import { visit, visitWithTypeInfo, TypeInfo } from 'graphql';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns true if the provided object implements the AsyncIterator protocol via
|
|
7
|
-
* implementing a `Symbol.asyncIterator` method.
|
|
8
|
-
*
|
|
9
|
-
* Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
|
|
10
|
-
*/
|
|
11
|
-
function isAsyncIterable(maybeAsyncIterable) {
|
|
12
|
-
return (maybeAsyncIterable != null &&
|
|
13
|
-
typeof maybeAsyncIterable === 'object' &&
|
|
14
|
-
typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
|
|
15
|
-
}
|
|
3
|
+
import { Histogram, register, Summary, Counter } from 'prom-client';
|
|
16
4
|
|
|
17
5
|
function shouldTraceFieldResolver(info, whitelist) {
|
|
18
6
|
if (!whitelist) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/prometheus",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "1.
|
|
7
|
-
"graphql": "^14.0.0 || ^15.0.0",
|
|
6
|
+
"@envelop/core": "^1.7.0",
|
|
7
|
+
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
8
8
|
"prom-client": "^13 || ^14.0.0"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"./*": {
|
|
29
29
|
"require": "./*.js",
|
|
30
30
|
"import": "./*.mjs"
|
|
31
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
32
33
|
}
|
|
33
34
|
}
|
package/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLError, DocumentNode, OperationDefinitionNode, GraphQLResolveInfo, TypeInfo, ASTNode } from 'graphql';
|
|
2
|
-
import { AfterParseEventPayload } from '@envelop/
|
|
2
|
+
import { AfterParseEventPayload } from '@envelop/core';
|
|
3
3
|
import { PrometheusTracingPluginConfig } from './config';
|
|
4
4
|
import { Counter, Histogram, Summary } from 'prom-client';
|
|
5
5
|
export declare type DeprecatedFieldInfo = {
|