@promster/apollo 1.0.2 → 1.0.6

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.
@@ -37,7 +37,7 @@ const createPlugin = ({
37
37
  options: undefined
38
38
  }) => {
39
39
  const allDefaultedOptions = merge__default["default"](metrics.createGcMetrics.defaultOptions, metrics.createGraphQlMetrics.defaultOptions, metrics.defaultNormalizers, {
40
- labels: ['operation_name']
40
+ labels: ['operation_name', 'field_name']
41
41
  }, options);
42
42
  const shouldSkipMetricsByEnvironment = allDefaultedOptions.detectKubernetes && !metrics.isRunningInKubernetes();
43
43
  const gcMetrics = metrics.createGcMetrics(allDefaultedOptions);
@@ -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
- (_graphQlMetrics$graph = graphQlMetrics.graphQlParseDuration) === null || _graphQlMetrics$graph === void 0 ? void 0 : _graphQlMetrics$graph.forEach(metric => {
91
- metric.observe(labels, parseDurationSeconds);
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
- (_graphQlMetrics$graph3 = graphQlMetrics.graphQlValidationDuration) === null || _graphQlMetrics$graph3 === void 0 ? void 0 : _graphQlMetrics$graph3.forEach(metric => {
116
- metric.observe(labels, validationDurationSeconds);
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
- (_graphQlMetrics$graph5 = graphQlMetrics.graphQlResolveFieldDuration) === null || _graphQlMetrics$graph5 === void 0 ? void 0 : _graphQlMetrics$graph5.forEach(metric => {
148
- metric.observe(labels, fieldResolveDurationSeconds);
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
- (_graphQlMetrics$graph7 = graphQlMetrics.graphQlRequestDuration) === null || _graphQlMetrics$graph7 === void 0 ? void 0 : _graphQlMetrics$graph7.forEach(metric => {
174
- metric.observe(labels, requestDurationSeconds);
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
  };
@@ -37,7 +37,7 @@ const createPlugin = ({
37
37
  options: undefined
38
38
  }) => {
39
39
  const allDefaultedOptions = merge__default["default"](metrics.createGcMetrics.defaultOptions, metrics.createGraphQlMetrics.defaultOptions, metrics.defaultNormalizers, {
40
- labels: ['operation_name']
40
+ labels: ['operation_name', 'field_name']
41
41
  }, options);
42
42
  const shouldSkipMetricsByEnvironment = allDefaultedOptions.detectKubernetes && !metrics.isRunningInKubernetes();
43
43
  const gcMetrics = metrics.createGcMetrics(allDefaultedOptions);
@@ -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
- (_graphQlMetrics$graph = graphQlMetrics.graphQlParseDuration) === null || _graphQlMetrics$graph === void 0 ? void 0 : _graphQlMetrics$graph.forEach(metric => {
91
- metric.observe(labels, parseDurationSeconds);
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
- (_graphQlMetrics$graph3 = graphQlMetrics.graphQlValidationDuration) === null || _graphQlMetrics$graph3 === void 0 ? void 0 : _graphQlMetrics$graph3.forEach(metric => {
116
- metric.observe(labels, validationDurationSeconds);
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
- (_graphQlMetrics$graph5 = graphQlMetrics.graphQlResolveFieldDuration) === null || _graphQlMetrics$graph5 === void 0 ? void 0 : _graphQlMetrics$graph5.forEach(metric => {
148
- metric.observe(labels, fieldResolveDurationSeconds);
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
- (_graphQlMetrics$graph7 = graphQlMetrics.graphQlRequestDuration) === null || _graphQlMetrics$graph7 === void 0 ? void 0 : _graphQlMetrics$graph7.forEach(metric => {
174
- metric.observe(labels, requestDurationSeconds);
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.2",
3
+ "version": "1.0.6",
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,15 +36,17 @@
36
36
  "prometheus"
37
37
  ],
38
38
  "dependencies": {
39
- "@promster/metrics": "^9.1.1",
40
- "apollo-server-plugin-base": "3.4.0",
39
+ "@promster/metrics": "^9.1.4",
40
+ "apollo-server-plugin-base": "3.5.1",
41
41
  "merge-options": "3.0.4",
42
42
  "tslib": "2.3.1"
43
43
  },
44
44
  "devDependencies": {
45
- "apollo-server": "3.5.0",
46
- "graphql": "16.0.1",
47
- "node-fetch": "2.6.6",
45
+ "@graphql-tools/schema": "^8.3.1",
46
+ "@graphql-tools/utils": "^8.6.1",
47
+ "apollo-server": "3.6.3",
48
+ "graphql": "16.3.0",
49
+ "node-fetch": "2.6.7",
48
50
  "parse-prometheus-text-format": "1.1.1"
49
51
  }
50
52
  }