@promster/apollo 1.0.2 → 1.0.3
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.
|
@@ -81,15 +81,18 @@ const createPlugin = ({
|
|
|
81
81
|
async parsingDidStart(parsingRequestContext) {
|
|
82
82
|
const parseTiming = metrics.timing.start();
|
|
83
83
|
return async error => {
|
|
84
|
-
var _graphQlMetrics$graph;
|
|
85
|
-
|
|
86
84
|
const {
|
|
87
85
|
seconds: parseDurationSeconds
|
|
88
86
|
} = parseTiming.end().value();
|
|
89
87
|
const labels = getDefaultLabelsOrSkipMeasurement(parsingRequestContext);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
|
|
89
|
+
if (parseDurationSeconds !== undefined) {
|
|
90
|
+
var _graphQlMetrics$graph;
|
|
91
|
+
|
|
92
|
+
(_graphQlMetrics$graph = graphQlMetrics.graphQlParseDuration) === null || _graphQlMetrics$graph === void 0 ? void 0 : _graphQlMetrics$graph.forEach(metric => {
|
|
93
|
+
metric.observe(labels, parseDurationSeconds);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
93
96
|
|
|
94
97
|
if (error) {
|
|
95
98
|
var _graphQlMetrics$graph2;
|
|
@@ -106,15 +109,18 @@ const createPlugin = ({
|
|
|
106
109
|
async validationDidStart(validationRequestContext) {
|
|
107
110
|
const validationTiming = metrics.timing.start();
|
|
108
111
|
return async error => {
|
|
109
|
-
var _graphQlMetrics$graph3;
|
|
110
|
-
|
|
111
112
|
const {
|
|
112
113
|
seconds: validationDurationSeconds
|
|
113
114
|
} = validationTiming.end().value();
|
|
114
115
|
const labels = getDefaultLabelsOrSkipMeasurement(validationRequestContext);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
|
|
117
|
+
if (validationDurationSeconds !== undefined) {
|
|
118
|
+
var _graphQlMetrics$graph3;
|
|
119
|
+
|
|
120
|
+
(_graphQlMetrics$graph3 = graphQlMetrics.graphQlValidationDuration) === null || _graphQlMetrics$graph3 === void 0 ? void 0 : _graphQlMetrics$graph3.forEach(metric => {
|
|
121
|
+
metric.observe(labels, validationDurationSeconds);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
118
124
|
|
|
119
125
|
if (error) {
|
|
120
126
|
var _graphQlMetrics$graph4;
|
|
@@ -135,8 +141,6 @@ const createPlugin = ({
|
|
|
135
141
|
}) {
|
|
136
142
|
const fieldResolveTiming = metrics.timing.start();
|
|
137
143
|
return error => {
|
|
138
|
-
var _graphQlMetrics$graph5;
|
|
139
|
-
|
|
140
144
|
const {
|
|
141
145
|
seconds: fieldResolveDurationSeconds
|
|
142
146
|
} = fieldResolveTiming.end().value();
|
|
@@ -144,9 +148,14 @@ const createPlugin = ({
|
|
|
144
148
|
const labels = Object.assign({}, defaultLabels, {
|
|
145
149
|
field_name: info.fieldName
|
|
146
150
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
|
|
152
|
+
if (fieldResolveDurationSeconds !== undefined) {
|
|
153
|
+
var _graphQlMetrics$graph5;
|
|
154
|
+
|
|
155
|
+
(_graphQlMetrics$graph5 = graphQlMetrics.graphQlResolveFieldDuration) === null || _graphQlMetrics$graph5 === void 0 ? void 0 : _graphQlMetrics$graph5.forEach(metric => {
|
|
156
|
+
metric.observe(labels, fieldResolveDurationSeconds);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
150
159
|
|
|
151
160
|
if (error) {
|
|
152
161
|
var _graphQlMetrics$graph6;
|
|
@@ -164,15 +173,18 @@ const createPlugin = ({
|
|
|
164
173
|
},
|
|
165
174
|
|
|
166
175
|
async willSendResponse(responseRequestContext) {
|
|
167
|
-
var _graphQlMetrics$graph7;
|
|
168
|
-
|
|
169
176
|
const {
|
|
170
177
|
seconds: requestDurationSeconds
|
|
171
178
|
} = requestTiming.end().value();
|
|
172
179
|
const labels = getDefaultLabelsOrSkipMeasurement(responseRequestContext);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
|
|
181
|
+
if (requestDurationSeconds !== undefined) {
|
|
182
|
+
var _graphQlMetrics$graph7;
|
|
183
|
+
|
|
184
|
+
(_graphQlMetrics$graph7 = graphQlMetrics.graphQlRequestDuration) === null || _graphQlMetrics$graph7 === void 0 ? void 0 : _graphQlMetrics$graph7.forEach(metric => {
|
|
185
|
+
metric.observe(labels, requestDurationSeconds);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
176
188
|
}
|
|
177
189
|
|
|
178
190
|
};
|
|
@@ -81,15 +81,18 @@ const createPlugin = ({
|
|
|
81
81
|
async parsingDidStart(parsingRequestContext) {
|
|
82
82
|
const parseTiming = metrics.timing.start();
|
|
83
83
|
return async error => {
|
|
84
|
-
var _graphQlMetrics$graph;
|
|
85
|
-
|
|
86
84
|
const {
|
|
87
85
|
seconds: parseDurationSeconds
|
|
88
86
|
} = parseTiming.end().value();
|
|
89
87
|
const labels = getDefaultLabelsOrSkipMeasurement(parsingRequestContext);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
|
|
89
|
+
if (parseDurationSeconds !== undefined) {
|
|
90
|
+
var _graphQlMetrics$graph;
|
|
91
|
+
|
|
92
|
+
(_graphQlMetrics$graph = graphQlMetrics.graphQlParseDuration) === null || _graphQlMetrics$graph === void 0 ? void 0 : _graphQlMetrics$graph.forEach(metric => {
|
|
93
|
+
metric.observe(labels, parseDurationSeconds);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
93
96
|
|
|
94
97
|
if (error) {
|
|
95
98
|
var _graphQlMetrics$graph2;
|
|
@@ -106,15 +109,18 @@ const createPlugin = ({
|
|
|
106
109
|
async validationDidStart(validationRequestContext) {
|
|
107
110
|
const validationTiming = metrics.timing.start();
|
|
108
111
|
return async error => {
|
|
109
|
-
var _graphQlMetrics$graph3;
|
|
110
|
-
|
|
111
112
|
const {
|
|
112
113
|
seconds: validationDurationSeconds
|
|
113
114
|
} = validationTiming.end().value();
|
|
114
115
|
const labels = getDefaultLabelsOrSkipMeasurement(validationRequestContext);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
|
|
117
|
+
if (validationDurationSeconds !== undefined) {
|
|
118
|
+
var _graphQlMetrics$graph3;
|
|
119
|
+
|
|
120
|
+
(_graphQlMetrics$graph3 = graphQlMetrics.graphQlValidationDuration) === null || _graphQlMetrics$graph3 === void 0 ? void 0 : _graphQlMetrics$graph3.forEach(metric => {
|
|
121
|
+
metric.observe(labels, validationDurationSeconds);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
118
124
|
|
|
119
125
|
if (error) {
|
|
120
126
|
var _graphQlMetrics$graph4;
|
|
@@ -135,8 +141,6 @@ const createPlugin = ({
|
|
|
135
141
|
}) {
|
|
136
142
|
const fieldResolveTiming = metrics.timing.start();
|
|
137
143
|
return error => {
|
|
138
|
-
var _graphQlMetrics$graph5;
|
|
139
|
-
|
|
140
144
|
const {
|
|
141
145
|
seconds: fieldResolveDurationSeconds
|
|
142
146
|
} = fieldResolveTiming.end().value();
|
|
@@ -144,9 +148,14 @@ const createPlugin = ({
|
|
|
144
148
|
const labels = Object.assign({}, defaultLabels, {
|
|
145
149
|
field_name: info.fieldName
|
|
146
150
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
|
|
152
|
+
if (fieldResolveDurationSeconds !== undefined) {
|
|
153
|
+
var _graphQlMetrics$graph5;
|
|
154
|
+
|
|
155
|
+
(_graphQlMetrics$graph5 = graphQlMetrics.graphQlResolveFieldDuration) === null || _graphQlMetrics$graph5 === void 0 ? void 0 : _graphQlMetrics$graph5.forEach(metric => {
|
|
156
|
+
metric.observe(labels, fieldResolveDurationSeconds);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
150
159
|
|
|
151
160
|
if (error) {
|
|
152
161
|
var _graphQlMetrics$graph6;
|
|
@@ -164,15 +173,18 @@ const createPlugin = ({
|
|
|
164
173
|
},
|
|
165
174
|
|
|
166
175
|
async willSendResponse(responseRequestContext) {
|
|
167
|
-
var _graphQlMetrics$graph7;
|
|
168
|
-
|
|
169
176
|
const {
|
|
170
177
|
seconds: requestDurationSeconds
|
|
171
178
|
} = requestTiming.end().value();
|
|
172
179
|
const labels = getDefaultLabelsOrSkipMeasurement(responseRequestContext);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
|
|
181
|
+
if (requestDurationSeconds !== undefined) {
|
|
182
|
+
var _graphQlMetrics$graph7;
|
|
183
|
+
|
|
184
|
+
(_graphQlMetrics$graph7 = graphQlMetrics.graphQlRequestDuration) === null || _graphQlMetrics$graph7 === void 0 ? void 0 : _graphQlMetrics$graph7.forEach(metric => {
|
|
185
|
+
metric.observe(labels, requestDurationSeconds);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
176
188
|
}
|
|
177
189
|
|
|
178
190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promster/apollo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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,14 +36,14 @@
|
|
|
36
36
|
"prometheus"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@promster/metrics": "^9.1.
|
|
39
|
+
"@promster/metrics": "^9.1.2",
|
|
40
40
|
"apollo-server-plugin-base": "3.4.0",
|
|
41
41
|
"merge-options": "3.0.4",
|
|
42
42
|
"tslib": "2.3.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"apollo-server": "3.5.0",
|
|
46
|
-
"graphql": "16.0
|
|
46
|
+
"graphql": "16.1.0",
|
|
47
47
|
"node-fetch": "2.6.6",
|
|
48
48
|
"parse-prometheus-text-format": "1.1.1"
|
|
49
49
|
}
|