@graphql-mesh/plugin-prometheus 2.0.15 → 2.1.0-alpha-ee0794bed6ab0e9b0d4516d8e05c7c8823763fa6
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/CHANGELOG.md +57 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @graphql-mesh/plugin-prometheus
|
|
2
2
|
|
|
3
|
+
## 2.1.0-alpha-ee0794bed6ab0e9b0d4516d8e05c7c8823763fa6
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1653](https://github.com/graphql-hive/gateway/pull/1653) [`ee0794b`](https://github.com/graphql-hive/gateway/commit/ee0794bed6ab0e9b0d4516d8e05c7c8823763fa6) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - New `ignoreRequest` OpenTelemetry API to allow other plugins (like Prometheus integration) to mark
|
|
9
|
+
an HTTP Request to be excluded from OpenTelemetry tracing.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { hive } from '@graphql-hive/gateway/opentelemetry/api';
|
|
13
|
+
import { defineConfig } from 'graphql-hive/gateway';
|
|
14
|
+
|
|
15
|
+
export const gatewayConfig = defineConfig({
|
|
16
|
+
openTelemetry: {
|
|
17
|
+
traces: true,
|
|
18
|
+
},
|
|
19
|
+
plugins: () => [
|
|
20
|
+
{
|
|
21
|
+
instrumentation: {
|
|
22
|
+
request: ({ request }) => {
|
|
23
|
+
hive.ignoreRequest(request); // marks the request to be ignored by OTEL tracing
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
I addition to this new API, the Prometheus integration now automatically marks metrics scraping
|
|
32
|
+
request to be ignored.
|
|
33
|
+
|
|
34
|
+
If you are defining a custom request span filter, a new payload attribute have been added so that
|
|
35
|
+
you can respect (or not, depending on your needs) the ignored request list:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { defineConfig } from 'graphql-hive/gateway';
|
|
39
|
+
|
|
40
|
+
export const gatewayConfig = defineConfig({
|
|
41
|
+
openTelemetry: {
|
|
42
|
+
traces: {
|
|
43
|
+
spans: {
|
|
44
|
+
http: ({ request, ignoredRequests }) => {
|
|
45
|
+
// First check if the request is ignored. This is the default http span filter implementation.
|
|
46
|
+
if (ignoredRequests.has(request)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Then apply your custom filtering
|
|
51
|
+
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
3
60
|
## 2.0.15
|
|
4
61
|
### Patch Changes
|
|
5
62
|
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ const DEFAULT_METRICS_CONFIG = {
|
|
|
26
26
|
graphql_gateway_subgraph_execute_errors: true
|
|
27
27
|
};
|
|
28
28
|
function useMeshPrometheus(pluginOptions) {
|
|
29
|
+
const endpoint = pluginOptions.endpoint || "/metrics";
|
|
29
30
|
let registry;
|
|
30
31
|
if (!pluginOptions.registry) {
|
|
31
32
|
registry = promClient.register;
|
|
@@ -167,6 +168,12 @@ function useMeshPrometheus(pluginOptions) {
|
|
|
167
168
|
};
|
|
168
169
|
});
|
|
169
170
|
return {
|
|
171
|
+
instrumentation: {
|
|
172
|
+
request({ request }, wrapped) {
|
|
173
|
+
if (new URL(request.url).pathname === endpoint) ;
|
|
174
|
+
return wrapped();
|
|
175
|
+
}
|
|
176
|
+
},
|
|
170
177
|
onPluginInit({ addPlugin }) {
|
|
171
178
|
addPlugin(
|
|
172
179
|
// @ts-expect-error TODO: plugin context generic is missing in yoga's prometheus plugin
|
package/dist/index.d.cts
CHANGED
|
@@ -29,7 +29,7 @@ type MeshMetricsConfig = {
|
|
|
29
29
|
* - string[]: Enable the metric on a list of phases
|
|
30
30
|
* - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
|
|
31
31
|
*/
|
|
32
|
-
graphql_gateway_fetch_duration
|
|
32
|
+
graphql_gateway_fetch_duration?: HistogramMetricOption<'fetch', string, FetchMetricsLabelParams>;
|
|
33
33
|
/**
|
|
34
34
|
* Tracks the duration of subgraph execution.
|
|
35
35
|
* It reports the time spent on each subgraph queries made to resolve incoming operations as an
|
|
@@ -42,7 +42,7 @@ type MeshMetricsConfig = {
|
|
|
42
42
|
* - string[]: Enable the metric on a list of phases
|
|
43
43
|
* - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
|
|
44
44
|
*/
|
|
45
|
-
graphql_gateway_subgraph_execute_duration
|
|
45
|
+
graphql_gateway_subgraph_execute_duration?: HistogramMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
|
|
46
46
|
/**
|
|
47
47
|
* This metric tracks the number of errors that occurred during the subgraph execution.
|
|
48
48
|
* It counts all errors found in the response returned by the subgraph execution.
|
|
@@ -55,7 +55,7 @@ type MeshMetricsConfig = {
|
|
|
55
55
|
* - string[]: Enable the metric on a list of phases
|
|
56
56
|
* - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
|
|
57
57
|
*/
|
|
58
|
-
graphql_gateway_subgraph_execute_errors
|
|
58
|
+
graphql_gateway_subgraph_execute_errors?: CounterMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
|
|
59
59
|
};
|
|
60
60
|
labels?: {
|
|
61
61
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ type MeshMetricsConfig = {
|
|
|
29
29
|
* - string[]: Enable the metric on a list of phases
|
|
30
30
|
* - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
|
|
31
31
|
*/
|
|
32
|
-
graphql_gateway_fetch_duration
|
|
32
|
+
graphql_gateway_fetch_duration?: HistogramMetricOption<'fetch', string, FetchMetricsLabelParams>;
|
|
33
33
|
/**
|
|
34
34
|
* Tracks the duration of subgraph execution.
|
|
35
35
|
* It reports the time spent on each subgraph queries made to resolve incoming operations as an
|
|
@@ -42,7 +42,7 @@ type MeshMetricsConfig = {
|
|
|
42
42
|
* - string[]: Enable the metric on a list of phases
|
|
43
43
|
* - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
|
|
44
44
|
*/
|
|
45
|
-
graphql_gateway_subgraph_execute_duration
|
|
45
|
+
graphql_gateway_subgraph_execute_duration?: HistogramMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
|
|
46
46
|
/**
|
|
47
47
|
* This metric tracks the number of errors that occurred during the subgraph execution.
|
|
48
48
|
* It counts all errors found in the response returned by the subgraph execution.
|
|
@@ -55,7 +55,7 @@ type MeshMetricsConfig = {
|
|
|
55
55
|
* - string[]: Enable the metric on a list of phases
|
|
56
56
|
* - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
|
|
57
57
|
*/
|
|
58
|
-
graphql_gateway_subgraph_execute_errors
|
|
58
|
+
graphql_gateway_subgraph_execute_errors?: CounterMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
|
|
59
59
|
};
|
|
60
60
|
labels?: {
|
|
61
61
|
/**
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const DEFAULT_METRICS_CONFIG = {
|
|
|
23
23
|
graphql_gateway_subgraph_execute_errors: true
|
|
24
24
|
};
|
|
25
25
|
function useMeshPrometheus(pluginOptions) {
|
|
26
|
+
const endpoint = pluginOptions.endpoint || "/metrics";
|
|
26
27
|
let registry;
|
|
27
28
|
if (!pluginOptions.registry) {
|
|
28
29
|
registry = register;
|
|
@@ -164,6 +165,12 @@ function useMeshPrometheus(pluginOptions) {
|
|
|
164
165
|
};
|
|
165
166
|
});
|
|
166
167
|
return {
|
|
168
|
+
instrumentation: {
|
|
169
|
+
request({ request }, wrapped) {
|
|
170
|
+
if (new URL(request.url).pathname === endpoint) ;
|
|
171
|
+
return wrapped();
|
|
172
|
+
}
|
|
173
|
+
},
|
|
167
174
|
onPluginInit({ addPlugin }) {
|
|
168
175
|
addPlugin(
|
|
169
176
|
// @ts-expect-error TODO: plugin context generic is missing in yoga's prometheus plugin
|