@promster/apollo 14.0.0 → 15.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/LICENSE +1 -1
- package/dist/declarations/src/index.d.ts +2 -2
- package/dist/declarations/src/plugin/index.d.ts +1 -1
- package/dist/declarations/src/plugin/plugin.d.ts +3 -3
- package/dist/promster-apollo.cjs.d.ts +1 -1
- package/dist/promster-apollo.cjs.dev.js +46 -41
- package/dist/promster-apollo.cjs.prod.js +46 -41
- package/package.json +9 -9
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Prometheus, defaultNormalizers, defaultRegister, getContentType, getSummary, timing } from '@promster/metrics';
|
|
2
|
+
import { type TPromsterOptions, createPlugin, signalIsNotUp, signalIsUp } from "./plugin/index.js";
|
|
3
3
|
export { type TPromsterOptions, createPlugin, signalIsUp, signalIsNotUp, getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, timing, };
|
|
4
4
|
export * from '@promster/types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type TPromsterOptions, createPlugin,
|
|
1
|
+
import { type TPromsterOptions, createPlugin, signalIsNotUp, signalIsUp } from "./plugin.js";
|
|
2
2
|
export { type TPromsterOptions, createPlugin, signalIsUp, signalIsNotUp };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import type { ApolloServerPlugin, BaseContext, GraphQLRequest, GraphQLRequestContext } from '@apollo/server';
|
|
2
|
+
import type { TRequestRecorder } from '@promster/metrics';
|
|
3
|
+
import type { TLabelValues, TOptionalPromsterOptions } from '@promster/types';
|
|
4
4
|
declare const getRequestRecorder: () => TRequestRecorder;
|
|
5
5
|
declare const signalIsUp: () => void;
|
|
6
6
|
declare const signalIsNotUp: () => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./declarations/src/index";
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
2
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvbXN0ZXItYXBvbGxvLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var merge = require('merge-options');
|
|
6
5
|
var metrics = require('@promster/metrics');
|
|
6
|
+
var merge = require('merge-options');
|
|
7
7
|
var types = require('@promster/types');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -15,17 +15,17 @@ const signalIsUp = () => {
|
|
|
15
15
|
if (!upMetric) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
for (const upMetricType of upMetric) {
|
|
19
19
|
upMetricType.set(1);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
};
|
|
22
22
|
const signalIsNotUp = () => {
|
|
23
23
|
if (!upMetric) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
for (const upMetricType of upMetric) {
|
|
27
27
|
upMetricType.set(0);
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
};
|
|
30
30
|
const createPlugin = ({
|
|
31
31
|
options
|
|
@@ -46,7 +46,6 @@ const createPlugin = ({
|
|
|
46
46
|
function getDefaultLabelsOrSkipMeasurement(requestContext) {
|
|
47
47
|
var _allDefaultedOptions$, _allDefaultedOptions$2;
|
|
48
48
|
const labels = Object.assign({}, {
|
|
49
|
-
// eslint-disable-next-line camelcase
|
|
50
49
|
operation_name: requestContext.request.operationName
|
|
51
50
|
}, (_allDefaultedOptions$ = allDefaultedOptions.getLabelValues) === null || _allDefaultedOptions$ === void 0 ? void 0 : _allDefaultedOptions$.call(allDefaultedOptions, requestContext.request, requestContext.response));
|
|
52
51
|
const shouldSkipByRequest = (_allDefaultedOptions$2 = allDefaultedOptions.skip) === null || _allDefaultedOptions$2 === void 0 ? void 0 : _allDefaultedOptions$2.call(allDefaultedOptions, requestContext.request, requestContext.response, labels);
|
|
@@ -75,18 +74,20 @@ const createPlugin = ({
|
|
|
75
74
|
} = parseTiming.end().value();
|
|
76
75
|
const labels = getDefaultLabelsOrSkipMeasurement(parsingRequestContext);
|
|
77
76
|
if (parseDurationSeconds !== undefined) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
if (graphQlMetrics.graphQlParseDuration) {
|
|
78
|
+
for (const metric of graphQlMetrics.graphQlParseDuration) {
|
|
79
|
+
metric.observe(labels, parseDurationSeconds);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
82
|
}
|
|
83
83
|
if (error) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
if (graphQlMetrics.graphQlErrorsTotal) {
|
|
85
|
+
for (const metric of graphQlMetrics.graphQlErrorsTotal) {
|
|
86
|
+
metric.inc(Object.assign({}, labels, {
|
|
87
|
+
phase: 'parsing'
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
93
|
},
|
|
@@ -98,18 +99,20 @@ const createPlugin = ({
|
|
|
98
99
|
} = validationTiming.end().value();
|
|
99
100
|
const labels = getDefaultLabelsOrSkipMeasurement(validationRequestContext);
|
|
100
101
|
if (validationDurationSeconds !== undefined) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (graphQlMetrics.graphQlValidationDuration) {
|
|
103
|
+
for (const metric of graphQlMetrics.graphQlValidationDuration) {
|
|
104
|
+
metric.observe(labels, validationDurationSeconds);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
if (error) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
if (graphQlMetrics.graphQlErrorsTotal) {
|
|
110
|
+
for (const metric of graphQlMetrics.graphQlErrorsTotal) {
|
|
111
|
+
metric.inc(Object.assign({}, labels, {
|
|
112
|
+
phase: 'validation'
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
};
|
|
115
118
|
},
|
|
@@ -125,22 +128,23 @@ const createPlugin = ({
|
|
|
125
128
|
} = fieldResolveTiming.end().value();
|
|
126
129
|
const defaultLabels = getDefaultLabelsOrSkipMeasurement(executionRequestContext);
|
|
127
130
|
const labels = Object.assign({}, defaultLabels, {
|
|
128
|
-
// eslint-disable-next-line camelcase
|
|
129
131
|
field_name: info.fieldName
|
|
130
132
|
});
|
|
131
133
|
if (fieldResolveDurationSeconds !== undefined) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
if (graphQlMetrics.graphQlResolveFieldDuration) {
|
|
135
|
+
for (const metric of graphQlMetrics.graphQlResolveFieldDuration) {
|
|
136
|
+
metric.observe(labels, fieldResolveDurationSeconds);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
136
139
|
}
|
|
137
140
|
if (error) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
if (graphQlMetrics.graphQlErrorsTotal) {
|
|
142
|
+
for (const metric of graphQlMetrics.graphQlErrorsTotal) {
|
|
143
|
+
metric.inc(Object.assign({}, labels, {
|
|
144
|
+
phase: 'execution'
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
144
148
|
}
|
|
145
149
|
};
|
|
146
150
|
}
|
|
@@ -152,10 +156,11 @@ const createPlugin = ({
|
|
|
152
156
|
} = requestTiming.end().value();
|
|
153
157
|
const labels = getDefaultLabelsOrSkipMeasurement(responseRequestContext);
|
|
154
158
|
if (requestDurationSeconds !== undefined) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
if (graphQlMetrics.graphQlRequestDuration) {
|
|
160
|
+
for (const metric of graphQlMetrics.graphQlRequestDuration) {
|
|
161
|
+
metric.observe(labels, requestDurationSeconds);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var merge = require('merge-options');
|
|
6
5
|
var metrics = require('@promster/metrics');
|
|
6
|
+
var merge = require('merge-options');
|
|
7
7
|
var types = require('@promster/types');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -15,17 +15,17 @@ const signalIsUp = () => {
|
|
|
15
15
|
if (!upMetric) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
for (const upMetricType of upMetric) {
|
|
19
19
|
upMetricType.set(1);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
};
|
|
22
22
|
const signalIsNotUp = () => {
|
|
23
23
|
if (!upMetric) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
for (const upMetricType of upMetric) {
|
|
27
27
|
upMetricType.set(0);
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
};
|
|
30
30
|
const createPlugin = ({
|
|
31
31
|
options
|
|
@@ -46,7 +46,6 @@ const createPlugin = ({
|
|
|
46
46
|
function getDefaultLabelsOrSkipMeasurement(requestContext) {
|
|
47
47
|
var _allDefaultedOptions$, _allDefaultedOptions$2;
|
|
48
48
|
const labels = Object.assign({}, {
|
|
49
|
-
// eslint-disable-next-line camelcase
|
|
50
49
|
operation_name: requestContext.request.operationName
|
|
51
50
|
}, (_allDefaultedOptions$ = allDefaultedOptions.getLabelValues) === null || _allDefaultedOptions$ === void 0 ? void 0 : _allDefaultedOptions$.call(allDefaultedOptions, requestContext.request, requestContext.response));
|
|
52
51
|
const shouldSkipByRequest = (_allDefaultedOptions$2 = allDefaultedOptions.skip) === null || _allDefaultedOptions$2 === void 0 ? void 0 : _allDefaultedOptions$2.call(allDefaultedOptions, requestContext.request, requestContext.response, labels);
|
|
@@ -75,18 +74,20 @@ const createPlugin = ({
|
|
|
75
74
|
} = parseTiming.end().value();
|
|
76
75
|
const labels = getDefaultLabelsOrSkipMeasurement(parsingRequestContext);
|
|
77
76
|
if (parseDurationSeconds !== undefined) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
if (graphQlMetrics.graphQlParseDuration) {
|
|
78
|
+
for (const metric of graphQlMetrics.graphQlParseDuration) {
|
|
79
|
+
metric.observe(labels, parseDurationSeconds);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
82
|
}
|
|
83
83
|
if (error) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
if (graphQlMetrics.graphQlErrorsTotal) {
|
|
85
|
+
for (const metric of graphQlMetrics.graphQlErrorsTotal) {
|
|
86
|
+
metric.inc(Object.assign({}, labels, {
|
|
87
|
+
phase: 'parsing'
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
93
|
},
|
|
@@ -98,18 +99,20 @@ const createPlugin = ({
|
|
|
98
99
|
} = validationTiming.end().value();
|
|
99
100
|
const labels = getDefaultLabelsOrSkipMeasurement(validationRequestContext);
|
|
100
101
|
if (validationDurationSeconds !== undefined) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (graphQlMetrics.graphQlValidationDuration) {
|
|
103
|
+
for (const metric of graphQlMetrics.graphQlValidationDuration) {
|
|
104
|
+
metric.observe(labels, validationDurationSeconds);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
if (error) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
if (graphQlMetrics.graphQlErrorsTotal) {
|
|
110
|
+
for (const metric of graphQlMetrics.graphQlErrorsTotal) {
|
|
111
|
+
metric.inc(Object.assign({}, labels, {
|
|
112
|
+
phase: 'validation'
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
};
|
|
115
118
|
},
|
|
@@ -125,22 +128,23 @@ const createPlugin = ({
|
|
|
125
128
|
} = fieldResolveTiming.end().value();
|
|
126
129
|
const defaultLabels = getDefaultLabelsOrSkipMeasurement(executionRequestContext);
|
|
127
130
|
const labels = Object.assign({}, defaultLabels, {
|
|
128
|
-
// eslint-disable-next-line camelcase
|
|
129
131
|
field_name: info.fieldName
|
|
130
132
|
});
|
|
131
133
|
if (fieldResolveDurationSeconds !== undefined) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
if (graphQlMetrics.graphQlResolveFieldDuration) {
|
|
135
|
+
for (const metric of graphQlMetrics.graphQlResolveFieldDuration) {
|
|
136
|
+
metric.observe(labels, fieldResolveDurationSeconds);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
136
139
|
}
|
|
137
140
|
if (error) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
if (graphQlMetrics.graphQlErrorsTotal) {
|
|
142
|
+
for (const metric of graphQlMetrics.graphQlErrorsTotal) {
|
|
143
|
+
metric.inc(Object.assign({}, labels, {
|
|
144
|
+
phase: 'execution'
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
144
148
|
}
|
|
145
149
|
};
|
|
146
150
|
}
|
|
@@ -152,10 +156,11 @@ const createPlugin = ({
|
|
|
152
156
|
} = requestTiming.end().value();
|
|
153
157
|
const labels = getDefaultLabelsOrSkipMeasurement(responseRequestContext);
|
|
154
158
|
if (requestDurationSeconds !== undefined) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
if (graphQlMetrics.graphQlRequestDuration) {
|
|
160
|
+
for (const metric of graphQlMetrics.graphQlRequestDuration) {
|
|
161
|
+
metric.observe(labels, requestDurationSeconds);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promster/apollo",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Apollo server integrations of promster",
|
|
5
5
|
"main": "dist/promster-apollo.cjs.js",
|
|
6
6
|
"typings": "dist/promster-apollo.cjs.d.ts",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"prometheus"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@apollo/server": "4.10.
|
|
40
|
-
"@promster/metrics": "^14.0.0",
|
|
41
|
-
"@promster/types": "^14.0.0",
|
|
39
|
+
"@apollo/server": "4.10.5",
|
|
42
40
|
"merge-options": "3.0.4",
|
|
43
|
-
"tslib": "2.
|
|
41
|
+
"tslib": "2.8.1",
|
|
42
|
+
"@promster/metrics": "15.0.0",
|
|
43
|
+
"@promster/types": "15.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@graphql-tools/schema": "10.0.
|
|
47
|
-
"@graphql-tools/utils": "10.
|
|
46
|
+
"@graphql-tools/schema": "10.0.23",
|
|
47
|
+
"@graphql-tools/utils": "10.8.6",
|
|
48
48
|
"apollo-server": "3.13.0",
|
|
49
|
-
"graphql": "16.
|
|
49
|
+
"graphql": "16.10.0",
|
|
50
50
|
"parse-prometheus-text-format": "1.1.1",
|
|
51
|
-
"@promster/server": "
|
|
51
|
+
"@promster/server": "15.0.0"
|
|
52
52
|
}
|
|
53
53
|
}
|