@graphql-mesh/plugin-prometheus 2.1.4 → 2.1.5-rc-5f3b1c504d18b46bb1a276f751611f507b22e7f3

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @graphql-mesh/plugin-prometheus
2
2
 
3
+ ## 2.1.5-rc-5f3b1c504d18b46bb1a276f751611f507b22e7f3
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#1719](https://github.com/graphql-hive/gateway/pull/1719) [`b449b05`](https://github.com/graphql-hive/gateway/commit/b449b0523eb1aef32235bdd74f1aacaa750f67c6) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Built-in Prometheus plugin inherits the logger from context
9
+
10
+
11
+
12
+ - [#1719](https://github.com/graphql-hive/gateway/pull/1719) [`b449b05`](https://github.com/graphql-hive/gateway/commit/b449b0523eb1aef32235bdd74f1aacaa750f67c6) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Metrics configuration accepts `true` which will enable only the defaults
13
+
3
14
  ## 2.1.4
4
15
  ### Patch Changes
5
16
 
package/dist/index.cjs CHANGED
@@ -40,7 +40,7 @@ function useMeshPrometheus(pluginOptions) {
40
40
  registry,
41
41
  metrics: {
42
42
  ...DEFAULT_METRICS_CONFIG,
43
- ...pluginOptions.metrics
43
+ ...pluginOptions.metrics === true ? {} : pluginOptions.metrics
44
44
  }
45
45
  };
46
46
  const fetchLabelNames = [
package/dist/index.d.cts CHANGED
@@ -15,48 +15,53 @@ interface TransportEntry<Options extends Record<string, any> = Record<string, an
15
15
  options?: Options;
16
16
  }
17
17
 
18
- type MeshMetricsConfig = {
19
- metrics: {
20
- /**
21
- * Tracks the duration of outgoing HTTP requests.
22
- * It reports the time spent on each request made using the `fetch` function provided by Mesh.
23
- * It is reported as an histogram.
24
- *
25
- * You can pass multiple type of values:
26
- * - boolean: Disable or Enable the metric with default configuration
27
- * - string: Enable the metric with custom name
28
- * - number[]: Enable the metric with custom buckets
29
- * - string[]: Enable the metric on a list of phases
30
- * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
31
- */
32
- graphql_gateway_fetch_duration?: HistogramMetricOption<'fetch', string, FetchMetricsLabelParams>;
33
- /**
34
- * Tracks the duration of subgraph execution.
35
- * It reports the time spent on each subgraph queries made to resolve incoming operations as an
36
- * histogram.
37
- *
38
- * You can pass multiple type of values:
39
- * - boolean: Disable or Enable the metric with default configuration
40
- * - string: Enable the metric with custom name
41
- * - number[]: Enable the metric with custom buckets
42
- * - string[]: Enable the metric on a list of phases
43
- * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
44
- */
45
- graphql_gateway_subgraph_execute_duration?: HistogramMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
46
- /**
47
- * This metric tracks the number of errors that occurred during the subgraph execution.
48
- * It counts all errors found in the response returned by the subgraph execution.
49
- * It is exposed as a counter
50
- *
51
- * You can pass multiple type of values:
52
- * - boolean: Disable or Enable the metric with default configuration
53
- * - string: Enable the metric with custom name
54
- * - number[]: Enable the metric with custom buckets
55
- * - string[]: Enable the metric on a list of phases
56
- * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
57
- */
58
- graphql_gateway_subgraph_execute_errors?: CounterMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
59
- };
18
+ type MetricsConfig = NonNullable<PrometheusTracingPluginConfig['metrics']> & {
19
+ /**
20
+ * Tracks the duration of outgoing HTTP requests.
21
+ * It reports the time spent on each request made using the `fetch` function provided by Mesh.
22
+ * It is reported as an histogram.
23
+ *
24
+ * You can pass multiple type of values:
25
+ * - boolean: Disable or Enable the metric with default configuration
26
+ * - string: Enable the metric with custom name
27
+ * - number[]: Enable the metric with custom buckets
28
+ * - string[]: Enable the metric on a list of phases
29
+ * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
30
+ */
31
+ graphql_gateway_fetch_duration?: HistogramMetricOption<'fetch', string, FetchMetricsLabelParams>;
32
+ /**
33
+ * Tracks the duration of subgraph execution.
34
+ * It reports the time spent on each subgraph queries made to resolve incoming operations as an
35
+ * histogram.
36
+ *
37
+ * You can pass multiple type of values:
38
+ * - boolean: Disable or Enable the metric with default configuration
39
+ * - string: Enable the metric with custom name
40
+ * - number[]: Enable the metric with custom buckets
41
+ * - string[]: Enable the metric on a list of phases
42
+ * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
43
+ */
44
+ graphql_gateway_subgraph_execute_duration?: HistogramMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
45
+ /**
46
+ * This metric tracks the number of errors that occurred during the subgraph execution.
47
+ * It counts all errors found in the response returned by the subgraph execution.
48
+ * It is exposed as a counter
49
+ *
50
+ * You can pass multiple type of values:
51
+ * - boolean: Disable or Enable the metric with default configuration
52
+ * - string: Enable the metric with custom name
53
+ * - number[]: Enable the metric with custom buckets
54
+ * - string[]: Enable the metric on a list of phases
55
+ * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
56
+ */
57
+ graphql_gateway_subgraph_execute_errors?: CounterMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
58
+ };
59
+ type PrometheusPluginOptions = PrometheusTracingPluginConfig & {
60
+ /**
61
+ * The metrics to provide when reporting to Prometheus.
62
+ * When `true`, defaults will be used from {@link DEFAULT_METRICS_CONFIG}.
63
+ */
64
+ metrics: true | MetricsConfig;
60
65
  labels?: {
61
66
  /**
62
67
  * The name of the targeted subgraph.
@@ -79,9 +84,8 @@ type MeshMetricsConfig = {
79
84
  * The logger instance used by the plugin to log messages.
80
85
  * This should be the logger instance provided by Mesh in the plugins context.
81
86
  */
82
- log: Logger;
87
+ log?: Logger;
83
88
  };
84
- type PrometheusPluginOptions = PrometheusTracingPluginConfig & MeshMetricsConfig;
85
89
  type YamlConfig = {
86
90
  baseDir?: string;
87
91
  importFn?: ImportFn;
@@ -97,6 +101,8 @@ type FetchMetricsLabelParams = {
97
101
  options: MeshFetchRequestInit;
98
102
  response: Response;
99
103
  };
100
- declare function useMeshPrometheus(pluginOptions: Omit<PrometheusPluginOptions, 'registry'> & YamlConfig): MeshPlugin<any> & Plugin & GatewayPlugin;
104
+ declare function useMeshPrometheus(pluginOptions: Omit<PrometheusPluginOptions, 'registry'> & YamlConfig & {
105
+ log: Logger;
106
+ }): MeshPlugin<any> & Plugin & GatewayPlugin;
101
107
 
102
108
  export { type PrometheusPluginOptions, useMeshPrometheus as default };
package/dist/index.d.ts CHANGED
@@ -15,48 +15,53 @@ interface TransportEntry<Options extends Record<string, any> = Record<string, an
15
15
  options?: Options;
16
16
  }
17
17
 
18
- type MeshMetricsConfig = {
19
- metrics: {
20
- /**
21
- * Tracks the duration of outgoing HTTP requests.
22
- * It reports the time spent on each request made using the `fetch` function provided by Mesh.
23
- * It is reported as an histogram.
24
- *
25
- * You can pass multiple type of values:
26
- * - boolean: Disable or Enable the metric with default configuration
27
- * - string: Enable the metric with custom name
28
- * - number[]: Enable the metric with custom buckets
29
- * - string[]: Enable the metric on a list of phases
30
- * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
31
- */
32
- graphql_gateway_fetch_duration?: HistogramMetricOption<'fetch', string, FetchMetricsLabelParams>;
33
- /**
34
- * Tracks the duration of subgraph execution.
35
- * It reports the time spent on each subgraph queries made to resolve incoming operations as an
36
- * histogram.
37
- *
38
- * You can pass multiple type of values:
39
- * - boolean: Disable or Enable the metric with default configuration
40
- * - string: Enable the metric with custom name
41
- * - number[]: Enable the metric with custom buckets
42
- * - string[]: Enable the metric on a list of phases
43
- * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
44
- */
45
- graphql_gateway_subgraph_execute_duration?: HistogramMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
46
- /**
47
- * This metric tracks the number of errors that occurred during the subgraph execution.
48
- * It counts all errors found in the response returned by the subgraph execution.
49
- * It is exposed as a counter
50
- *
51
- * You can pass multiple type of values:
52
- * - boolean: Disable or Enable the metric with default configuration
53
- * - string: Enable the metric with custom name
54
- * - number[]: Enable the metric with custom buckets
55
- * - string[]: Enable the metric on a list of phases
56
- * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
57
- */
58
- graphql_gateway_subgraph_execute_errors?: CounterMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
59
- };
18
+ type MetricsConfig = NonNullable<PrometheusTracingPluginConfig['metrics']> & {
19
+ /**
20
+ * Tracks the duration of outgoing HTTP requests.
21
+ * It reports the time spent on each request made using the `fetch` function provided by Mesh.
22
+ * It is reported as an histogram.
23
+ *
24
+ * You can pass multiple type of values:
25
+ * - boolean: Disable or Enable the metric with default configuration
26
+ * - string: Enable the metric with custom name
27
+ * - number[]: Enable the metric with custom buckets
28
+ * - string[]: Enable the metric on a list of phases
29
+ * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
30
+ */
31
+ graphql_gateway_fetch_duration?: HistogramMetricOption<'fetch', string, FetchMetricsLabelParams>;
32
+ /**
33
+ * Tracks the duration of subgraph execution.
34
+ * It reports the time spent on each subgraph queries made to resolve incoming operations as an
35
+ * histogram.
36
+ *
37
+ * You can pass multiple type of values:
38
+ * - boolean: Disable or Enable the metric with default configuration
39
+ * - string: Enable the metric with custom name
40
+ * - number[]: Enable the metric with custom buckets
41
+ * - string[]: Enable the metric on a list of phases
42
+ * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
43
+ */
44
+ graphql_gateway_subgraph_execute_duration?: HistogramMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
45
+ /**
46
+ * This metric tracks the number of errors that occurred during the subgraph execution.
47
+ * It counts all errors found in the response returned by the subgraph execution.
48
+ * It is exposed as a counter
49
+ *
50
+ * You can pass multiple type of values:
51
+ * - boolean: Disable or Enable the metric with default configuration
52
+ * - string: Enable the metric with custom name
53
+ * - number[]: Enable the metric with custom buckets
54
+ * - string[]: Enable the metric on a list of phases
55
+ * - ReturnType<typeof createHistogram>: Enable the metric with custom configuration
56
+ */
57
+ graphql_gateway_subgraph_execute_errors?: CounterMetricOption<'subgraphExecute', string, SubgraphMetricsLabelParams>;
58
+ };
59
+ type PrometheusPluginOptions = PrometheusTracingPluginConfig & {
60
+ /**
61
+ * The metrics to provide when reporting to Prometheus.
62
+ * When `true`, defaults will be used from {@link DEFAULT_METRICS_CONFIG}.
63
+ */
64
+ metrics: true | MetricsConfig;
60
65
  labels?: {
61
66
  /**
62
67
  * The name of the targeted subgraph.
@@ -79,9 +84,8 @@ type MeshMetricsConfig = {
79
84
  * The logger instance used by the plugin to log messages.
80
85
  * This should be the logger instance provided by Mesh in the plugins context.
81
86
  */
82
- log: Logger;
87
+ log?: Logger;
83
88
  };
84
- type PrometheusPluginOptions = PrometheusTracingPluginConfig & MeshMetricsConfig;
85
89
  type YamlConfig = {
86
90
  baseDir?: string;
87
91
  importFn?: ImportFn;
@@ -97,6 +101,8 @@ type FetchMetricsLabelParams = {
97
101
  options: MeshFetchRequestInit;
98
102
  response: Response;
99
103
  };
100
- declare function useMeshPrometheus(pluginOptions: Omit<PrometheusPluginOptions, 'registry'> & YamlConfig): MeshPlugin<any> & Plugin & GatewayPlugin;
104
+ declare function useMeshPrometheus(pluginOptions: Omit<PrometheusPluginOptions, 'registry'> & YamlConfig & {
105
+ log: Logger;
106
+ }): MeshPlugin<any> & Plugin & GatewayPlugin;
101
107
 
102
108
  export { type PrometheusPluginOptions, useMeshPrometheus as default };
package/dist/index.js CHANGED
@@ -37,7 +37,7 @@ function useMeshPrometheus(pluginOptions) {
37
37
  registry,
38
38
  metrics: {
39
39
  ...DEFAULT_METRICS_CONFIG,
40
- ...pluginOptions.metrics
40
+ ...pluginOptions.metrics === true ? {} : pluginOptions.metrics
41
41
  }
42
42
  };
43
43
  const fetchLabelNames = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/plugin-prometheus",
3
- "version": "2.1.4",
3
+ "version": "2.1.5-rc-5f3b1c504d18b46bb1a276f751611f507b22e7f3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",