@graphql-hive/gateway 2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41 → 2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc

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,6 +1,6 @@
1
1
  # @graphql-hive/gateway
2
2
 
3
- ## 2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
3
+ ## 2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
4
4
 
5
5
  ### Major Changes
6
6
 
@@ -105,6 +105,10 @@
105
105
  - Added dependency [`@opentelemetry/api-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api-logs/v/0.202.0) (to `dependencies`)
106
106
  - Added dependency [`@opentelemetry/sdk-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-logs/v/0.202.0) (to `dependencies`)
107
107
 
108
+ - [#1300](https://github.com/graphql-hive/gateway/pull/1300) [`e195589`](https://github.com/graphql-hive/gateway/commit/e1955891936be30c63727f8c15e2f55318ceb6fc) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
109
+ - Added dependency [`@opentelemetry/context-async-hooks@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/context-async-hooks/v/2.0.1) (to `dependencies`)
110
+ - Added dependency [`@opentelemetry/sdk-trace-base@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-trace-base/v/2.0.1) (to `dependencies`)
111
+
108
112
  - [#1318](https://github.com/graphql-hive/gateway/pull/1318) [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
109
113
  - Updated dependency [`@graphql-yoga/render-graphiql@^5.15.1` ↗︎](https://www.npmjs.com/package/@graphql-yoga/render-graphiql/v/5.15.1) (from `^5.13.5`, in `dependencies`)
110
114
  - Updated dependency [`graphql-yoga@^5.15.1` ↗︎](https://www.npmjs.com/package/graphql-yoga/v/5.15.1) (from `^5.13.5`, in `dependencies`)
@@ -123,6 +127,7 @@
123
127
  - Added dependency [`@graphql-hive/logger@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-hive/logger/v/workspace:^) (to `dependencies`)
124
128
  - Added dependency [`@opentelemetry/api@^1.9.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api/v/1.9.0) (to `dependencies`)
125
129
  - Added dependency [`@opentelemetry/api-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api-logs/v/0.202.0) (to `dependencies`)
130
+ - Added dependency [`@opentelemetry/context-async-hooks@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/context-async-hooks/v/2.0.1) (to `dependencies`)
126
131
  - Added dependency [`@opentelemetry/context-zone@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/context-zone/v/2.0.1) (to `dependencies`)
127
132
  - Added dependency [`@opentelemetry/core@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/core/v/2.0.1) (to `dependencies`)
128
133
  - Added dependency [`@opentelemetry/exporter-jaeger@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/exporter-jaeger/v/2.0.1) (to `dependencies`)
@@ -132,24 +137,25 @@
132
137
  - Added dependency [`@opentelemetry/sampler-jaeger-remote@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sampler-jaeger-remote/v/0.202.0) (to `dependencies`)
133
138
  - Added dependency [`@opentelemetry/sdk-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-logs/v/0.202.0) (to `dependencies`)
134
139
  - Added dependency [`@opentelemetry/sdk-metrics@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-metrics/v/2.0.1) (to `dependencies`)
140
+ - Added dependency [`@opentelemetry/sdk-trace-base@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-trace-base/v/2.0.1) (to `dependencies`)
135
141
  - Removed dependency [`@graphql-mesh/plugin-mock@^0.105.6` ↗︎](https://www.npmjs.com/package/@graphql-mesh/plugin-mock/v/0.105.6) (from `dependencies`)
136
142
 
137
143
  - [#1333](https://github.com/graphql-hive/gateway/pull/1333) [`ffa3753`](https://github.com/graphql-hive/gateway/commit/ffa3753ccb9045c5b2d62af05edc7f1d78336cb3) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Isomorphic environment variable getter with truthy value parsing
138
144
 
139
- - Updated dependencies [[`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`f12f2b7`](https://github.com/graphql-hive/gateway/commit/f12f2b78163fbef797a42b5999a0b5a8ef6b2c98), [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d), [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`b97d5d7`](https://github.com/graphql-hive/gateway/commit/b97d5d7d086dcaf140da83bf0c279e4a40b50fe2), [`76b49db`](https://github.com/graphql-hive/gateway/commit/76b49db569d9608af80a635e7cb40b1cc7d3b313), [`1d4bcd3`](https://github.com/graphql-hive/gateway/commit/1d4bcd3a417aa603e9b66ebc4b4dd000b25f9781), [`7cbe3f5`](https://github.com/graphql-hive/gateway/commit/7cbe3f5301cbdba1d160153761dfafaefc2aa107), [`eaf4735`](https://github.com/graphql-hive/gateway/commit/eaf4735e06023d2f0e393998a6d2075898bc82fc), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce), [`7287ffa`](https://github.com/graphql-hive/gateway/commit/7287ffa2ac0f08801c3058e96a7c4eba7102c1d0), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d), [`ffa3753`](https://github.com/graphql-hive/gateway/commit/ffa3753ccb9045c5b2d62af05edc7f1d78336cb3), [`8273fde`](https://github.com/graphql-hive/gateway/commit/8273fde686a666fa7f974ad4f9084f8b9cb0df57), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`2fa0c8f`](https://github.com/graphql-hive/gateway/commit/2fa0c8f1dd074c9da8e6ac4086eb3009be9fdf07), [`f212e12`](https://github.com/graphql-hive/gateway/commit/f212e1289d8e0c57cb3d7ace2aca3cbbf8d38889), [`247ecfe`](https://github.com/graphql-hive/gateway/commit/247ecfe81319a4383dd33c9dba5779189e12b15d), [`9b230f3`](https://github.com/graphql-hive/gateway/commit/9b230f35b47afbf3b253e4c21720e836c5a2a8d1), [`b6c1e88`](https://github.com/graphql-hive/gateway/commit/b6c1e8812e817f616d780af4276bd7e2a7f7dbef), [`849db00`](https://github.com/graphql-hive/gateway/commit/849db001c6a8e8efeb25cc314538783a924b090e), [`c03ff30`](https://github.com/graphql-hive/gateway/commit/c03ff30aca8fab824a1e3b896f3c4359b0c84726), [`eaf4735`](https://github.com/graphql-hive/gateway/commit/eaf4735e06023d2f0e393998a6d2075898bc82fc), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`777d90b`](https://github.com/graphql-hive/gateway/commit/777d90b0ed03f113633015e48474231eda2b8398)]:
140
- - @graphql-hive/gateway-runtime@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
141
- - @graphql-hive/plugin-aws-sigv4@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
142
- - @graphql-mesh/plugin-jwt-auth@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
143
- - @graphql-mesh/plugin-opentelemetry@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
144
- - @graphql-mesh/plugin-prometheus@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
145
- - @graphql-mesh/transport-http-callback@1.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
146
- - @graphql-mesh/transport-ws@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
147
- - @graphql-mesh/hmac-upstream-signature@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
148
- - @graphql-hive/plugin-deduplicate-request@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
149
- - @graphql-mesh/transport-http@1.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
150
- - @graphql-hive/importer@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
151
- - @graphql-hive/pubsub@2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41
152
- - @graphql-hive/logger@1.0.1-next-c8fe4c675533551cd98c6101206b9395a5621f41
145
+ - Updated dependencies [[`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`f12f2b7`](https://github.com/graphql-hive/gateway/commit/f12f2b78163fbef797a42b5999a0b5a8ef6b2c98), [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d), [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`b97d5d7`](https://github.com/graphql-hive/gateway/commit/b97d5d7d086dcaf140da83bf0c279e4a40b50fe2), [`76b49db`](https://github.com/graphql-hive/gateway/commit/76b49db569d9608af80a635e7cb40b1cc7d3b313), [`e195589`](https://github.com/graphql-hive/gateway/commit/e1955891936be30c63727f8c15e2f55318ceb6fc), [`1d4bcd3`](https://github.com/graphql-hive/gateway/commit/1d4bcd3a417aa603e9b66ebc4b4dd000b25f9781), [`7cbe3f5`](https://github.com/graphql-hive/gateway/commit/7cbe3f5301cbdba1d160153761dfafaefc2aa107), [`eaf4735`](https://github.com/graphql-hive/gateway/commit/eaf4735e06023d2f0e393998a6d2075898bc82fc), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce), [`7287ffa`](https://github.com/graphql-hive/gateway/commit/7287ffa2ac0f08801c3058e96a7c4eba7102c1d0), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d), [`ffa3753`](https://github.com/graphql-hive/gateway/commit/ffa3753ccb9045c5b2d62af05edc7f1d78336cb3), [`8273fde`](https://github.com/graphql-hive/gateway/commit/8273fde686a666fa7f974ad4f9084f8b9cb0df57), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`2fa0c8f`](https://github.com/graphql-hive/gateway/commit/2fa0c8f1dd074c9da8e6ac4086eb3009be9fdf07), [`f212e12`](https://github.com/graphql-hive/gateway/commit/f212e1289d8e0c57cb3d7ace2aca3cbbf8d38889), [`247ecfe`](https://github.com/graphql-hive/gateway/commit/247ecfe81319a4383dd33c9dba5779189e12b15d), [`9b230f3`](https://github.com/graphql-hive/gateway/commit/9b230f35b47afbf3b253e4c21720e836c5a2a8d1), [`b6c1e88`](https://github.com/graphql-hive/gateway/commit/b6c1e8812e817f616d780af4276bd7e2a7f7dbef), [`849db00`](https://github.com/graphql-hive/gateway/commit/849db001c6a8e8efeb25cc314538783a924b090e), [`c03ff30`](https://github.com/graphql-hive/gateway/commit/c03ff30aca8fab824a1e3b896f3c4359b0c84726), [`eaf4735`](https://github.com/graphql-hive/gateway/commit/eaf4735e06023d2f0e393998a6d2075898bc82fc), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`777d90b`](https://github.com/graphql-hive/gateway/commit/777d90b0ed03f113633015e48474231eda2b8398)]:
146
+ - @graphql-hive/gateway-runtime@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
147
+ - @graphql-hive/plugin-aws-sigv4@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
148
+ - @graphql-mesh/plugin-jwt-auth@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
149
+ - @graphql-mesh/plugin-opentelemetry@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
150
+ - @graphql-mesh/plugin-prometheus@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
151
+ - @graphql-mesh/transport-http-callback@1.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
152
+ - @graphql-mesh/transport-ws@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
153
+ - @graphql-mesh/hmac-upstream-signature@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
154
+ - @graphql-hive/plugin-deduplicate-request@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
155
+ - @graphql-mesh/transport-http@1.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
156
+ - @graphql-hive/importer@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
157
+ - @graphql-hive/pubsub@2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc
158
+ - @graphql-hive/logger@1.0.1-next-2806fc3679108314404c709df381d642ebb4b2dc
153
159
 
154
160
  ## 1.15.4
155
161
 
package/dist/bin.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  require('dotenv/config');
4
4
  var module$1 = require('node:module');
5
5
  var logger = require('@graphql-hive/logger');
6
- var cli = require('./cli-B4botk_4.cjs');
6
+ var cli = require('./cli-Cm9aDkDW.cjs');
7
7
  require('node:cluster');
8
8
  require('node:os');
9
9
  require('node:path');
@@ -18,6 +18,7 @@ require('node:fs');
18
18
  require('node:http');
19
19
  require('node:https');
20
20
  require('@graphql-tools/utils');
21
+ require('@opentelemetry/sdk-trace-base');
21
22
  require('@graphql-tools/code-file-loader');
22
23
  require('@graphql-tools/graphql-file-loader');
23
24
  require('@graphql-tools/load');
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import 'dotenv/config';
3
3
  import module from 'node:module';
4
4
  import { Logger } from '@graphql-hive/logger';
5
- import { e as enableModuleCachingIfPossible, h as handleNodeWarnings, r as run } from './cli-BykXyWTB.js';
5
+ import { e as enableModuleCachingIfPossible, h as handleNodeWarnings, r as run } from './cli-BPJkk_8e.js';
6
6
  import 'node:cluster';
7
7
  import 'node:os';
8
8
  import 'node:path';
@@ -17,6 +17,7 @@ import 'node:fs';
17
17
  import 'node:http';
18
18
  import 'node:https';
19
19
  import '@graphql-tools/utils';
20
+ import '@opentelemetry/sdk-trace-base';
20
21
  import '@graphql-tools/code-file-loader';
21
22
  import '@graphql-tools/graphql-file-loader';
22
23
  import '@graphql-tools/load';
@@ -13,7 +13,8 @@ import { pathToFileURL } from 'node:url';
13
13
  import { promises } from 'node:fs';
14
14
  import { createServer as createServer$1 } from 'node:http';
15
15
  import { createServer } from 'node:https';
16
- import { isValidPath, asArray } from '@graphql-tools/utils';
16
+ import { fakePromise, isValidPath, asArray } from '@graphql-tools/utils';
17
+ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
17
18
  import { CodeFileLoader } from '@graphql-tools/code-file-loader';
18
19
  import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
19
20
  import { loadTypedefs } from '@graphql-tools/load';
@@ -513,11 +514,83 @@ function handleFork(log, config) {
513
514
  return false;
514
515
  }
515
516
 
517
+ async function handleOpenTelemetryConfig(ctx, cliOpts) {
518
+ const accessToken = cliOpts.hiveTraceAccessToken;
519
+ const traceEndpoint = cliOpts.hiveTraceEndpoint;
520
+ const target = cliOpts.hiveTarget;
521
+ const openTelemetry = cliOpts.openTelemetry;
522
+ const exporterType = cliOpts.openTelemetryExporterType ?? "otlp-http";
523
+ const log = ctx.log.child("[OpenTelemetry] ");
524
+ if (openTelemetry || accessToken) {
525
+ log.debug(
526
+ { openTelemetry, exporterType, target, traceEndpoint },
527
+ "Initializing OpenTelemetry SDK"
528
+ );
529
+ return fakePromise().then(async () => {
530
+ const { openTelemetrySetup, HiveTracingSpanProcessor, getEnvVar } = await import('@graphql-mesh/plugin-opentelemetry/setup');
531
+ const processors = [];
532
+ const logAttributes = {
533
+ traceEndpoints: [],
534
+ contextManager: false
535
+ };
536
+ let integrationName;
537
+ if (openTelemetry) {
538
+ const otelEndpoint = typeof openTelemetry === "string" ? openTelemetry : getEnvVar("OTEL_EXPORTER_OTLP_ENDPOINT", void 0);
539
+ log.debug({ exporterType, otelEndpoint }, "Setting up OTLP Exporter");
540
+ integrationName = "OpenTelemetry";
541
+ logAttributes.traceEndpoints.push({
542
+ url: otelEndpoint ?? null,
543
+ type: exporterType
544
+ });
545
+ log.debug({ type: exporterType }, "Loading OpenTelemetry exporter");
546
+ const { OTLPTraceExporter } = await import(`@opentelemetry/exporter-trace-${exporterType}`);
547
+ processors.push(
548
+ new BatchSpanProcessor(new OTLPTraceExporter({ url: otelEndpoint }))
549
+ );
550
+ }
551
+ if (accessToken) {
552
+ log.debug({ target, traceEndpoint }, "Setting up Hive Tracing");
553
+ integrationName ??= "Hive Tracing";
554
+ if (!target) {
555
+ ctx.log.error(
556
+ 'Hive tracing needs a target. Please provide it through "--hive-target <target>"'
557
+ );
558
+ process.exit(1);
559
+ }
560
+ logAttributes.traceEndpoints.push({
561
+ url: traceEndpoint,
562
+ type: "hive tracing",
563
+ target
564
+ });
565
+ processors.push(
566
+ new HiveTracingSpanProcessor({
567
+ accessToken,
568
+ target,
569
+ endpoint: traceEndpoint
570
+ })
571
+ );
572
+ }
573
+ log.debug("Trying to load AsyncLocalStorage based Context Manager");
574
+ const contextManager = await import('@opentelemetry/context-async-hooks').then((module) => {
575
+ logAttributes.contextManager = true;
576
+ return new module.AsyncLocalStorageContextManager();
577
+ }).catch(() => null);
578
+ openTelemetrySetup({
579
+ traces: { processors },
580
+ contextManager
581
+ });
582
+ log.info(logAttributes, `${integrationName} integration is enabled`);
583
+ return true;
584
+ });
585
+ }
586
+ return false;
587
+ }
588
+
516
589
  function handleReportingConfig(ctx, loadedConfig, cliOpts) {
517
590
  const confOpts = {
518
591
  ...loadedConfig.reporting?.type === "hive" ? {
519
592
  hiveRegistryToken: loadedConfig.reporting.token,
520
- hiveUsageTarget: loadedConfig.reporting.target,
593
+ hiveTarget: loadedConfig.reporting.target,
521
594
  hiveUsageAccessToken: loadedConfig.reporting.token
522
595
  } : {},
523
596
  ...loadedConfig.reporting?.type === "graphos" ? {
@@ -525,32 +598,45 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
525
598
  apolloKey: loadedConfig.reporting.apiKey
526
599
  } : {}
527
600
  };
528
- const opts = { ...confOpts, ...cliOpts };
601
+ const opts = {
602
+ ...confOpts,
603
+ ...cliOpts,
604
+ hiveTarget: (
605
+ // cli arguments always take precedence over config
606
+ confOpts.hiveTarget ?? cliOpts.hiveTarget ?? cliOpts.hiveUsageTarget
607
+ )
608
+ };
529
609
  if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) {
530
610
  ctx.log.error(
531
611
  'Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
532
612
  );
533
613
  process.exit(1);
534
614
  }
535
- if (cliOpts.hiveRegistryToken && opts.hiveUsageTarget) {
615
+ if (cliOpts.hiveUsageTarget && cliOpts.hiveTarget) {
616
+ ctx.log.error(
617
+ 'Cannot use "--hive-usage-target" with "--hive-target". Please only use "--hive-target"'
618
+ );
619
+ process.exit(1);
620
+ }
621
+ if (cliOpts.hiveRegistryToken && opts.hiveTarget) {
536
622
  ctx.log.error(
537
623
  'Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
538
624
  );
539
625
  process.exit(1);
540
626
  }
541
- if (opts.hiveUsageTarget && !opts.hiveUsageAccessToken) {
627
+ if (opts.hiveTarget && !opts.hiveAccessToken && !opts.hiveUsageAccessToken && !opts.hiveTraceAccessToken) {
542
628
  ctx.log.error(
543
- 'Hive usage target needs an access token. Please provide it through the "--hive-usage-access-token <token>" option or the config.'
629
+ 'Hive usage target needs an access token. Please provide it through "--hive-access-token <token>", or specific "--hive-usage-access-token <token>" and "--hive-trace-access-token" options, or the config.'
544
630
  );
545
631
  process.exit(1);
546
632
  }
547
- if (opts.hiveUsageAccessToken && !opts.hiveUsageTarget) {
633
+ if ((opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveTraceAccessToken) && !opts.hiveTarget) {
548
634
  ctx.log.error(
549
- 'Hive usage access token needs a target. Please provide it through the "--hive-usage-target <target>" option or the config.'
635
+ 'Hive access token needs a target. Please provide it through the "--hive-target <target>" option or the config.'
550
636
  );
551
637
  process.exit(1);
552
638
  }
553
- const hiveUsageAccessToken = opts.hiveUsageAccessToken || opts.hiveRegistryToken;
639
+ const hiveUsageAccessToken = opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveRegistryToken;
554
640
  if (hiveUsageAccessToken) {
555
641
  if (opts.hiveUsageTarget) {
556
642
  ctx.log.info("Configuring Hive usage reporting");
@@ -561,7 +647,7 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
561
647
  ...loadedConfig.reporting,
562
648
  type: "hive",
563
649
  token: hiveUsageAccessToken,
564
- target: opts.hiveUsageTarget
650
+ target: opts.hiveTarget
565
651
  };
566
652
  }
567
653
  if (opts.apolloKey) {
@@ -589,17 +675,30 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
589
675
  "path to the GraphQL schema file or a url from where to pull the schema"
590
676
  ).action(async function proxy(endpoint) {
591
677
  const {
678
+ opentelemetry,
679
+ opentelemetryExporterType,
592
680
  hiveCdnEndpoint,
593
681
  hiveCdnKey,
594
682
  hiveRegistryToken,
683
+ hiveTarget,
595
684
  hiveUsageTarget,
685
+ hiveAccessToken,
596
686
  hiveUsageAccessToken,
687
+ hiveTraceAccessToken,
688
+ hiveTraceEndpoint,
597
689
  maskedErrors,
598
690
  hivePersistedDocumentsEndpoint,
599
691
  hivePersistedDocumentsToken,
600
692
  ...opts
601
693
  } = this.optsWithGlobals();
602
694
  ctx.log.info(`Starting ${ctx.productName} ${ctx.version} in proxy mode`);
695
+ const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
696
+ openTelemetry: opentelemetry,
697
+ openTelemetryExporterType: opentelemetryExporterType,
698
+ hiveTarget,
699
+ hiveTraceAccessToken,
700
+ hiveTraceEndpoint
701
+ });
603
702
  const loadedConfig = await loadConfig({
604
703
  log: ctx.log,
605
704
  configPath: opts.configPath,
@@ -653,8 +752,11 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
653
752
  const registryConfig = {};
654
753
  const reporting = handleReportingConfig(ctx, loadedConfig, {
655
754
  hiveRegistryToken,
755
+ hiveTarget,
656
756
  hiveUsageTarget,
757
+ hiveAccessToken,
657
758
  hiveUsageAccessToken,
759
+ hiveTraceAccessToken,
658
760
  // proxy can only do reporting to hive registry
659
761
  apolloGraphRef: void 0,
660
762
  apolloKey: void 0
@@ -675,7 +777,8 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
675
777
  const builtinPlugins = await getBuiltinPluginsFromConfig(
676
778
  {
677
779
  ...loadedConfig,
678
- ...opts
780
+ ...opts,
781
+ openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
679
782
  },
680
783
  {
681
784
  log: ctx.log,
@@ -750,15 +853,28 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
750
853
  'path to the subgraph schema file or a url from where to pull the subgraph schema (default: "subgraph.graphql")'
751
854
  ).action(async function subgraph(schemaPathOrUrl) {
752
855
  const {
856
+ opentelemetry,
857
+ opentelemetryExporterType,
753
858
  maskedErrors,
754
859
  hiveRegistryToken,
860
+ hiveTarget,
755
861
  hiveUsageTarget,
862
+ hiveAccessToken,
756
863
  hiveUsageAccessToken,
864
+ hiveTraceAccessToken,
865
+ hiveTraceEndpoint,
757
866
  hivePersistedDocumentsEndpoint,
758
867
  hivePersistedDocumentsToken,
759
868
  ...opts
760
869
  } = this.optsWithGlobals();
761
870
  ctx.log.info(`Starting ${ctx.productName} ${ctx.version} as subgraph`);
871
+ const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
872
+ openTelemetry: opentelemetry,
873
+ openTelemetryExporterType: opentelemetryExporterType,
874
+ hiveTarget,
875
+ hiveTraceAccessToken,
876
+ hiveTraceEndpoint
877
+ });
762
878
  const loadedConfig = await loadConfig({
763
879
  log: ctx.log,
764
880
  configPath: opts.configPath,
@@ -774,8 +890,11 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
774
890
  const registryConfig = {};
775
891
  const reporting = handleReportingConfig(ctx, loadedConfig, {
776
892
  hiveRegistryToken,
893
+ hiveTarget,
777
894
  hiveUsageTarget,
895
+ hiveAccessToken,
778
896
  hiveUsageAccessToken,
897
+ hiveTraceAccessToken,
779
898
  // subgraph can only do reporting to hive registry
780
899
  apolloGraphRef: void 0,
781
900
  apolloKey: void 0
@@ -796,7 +915,8 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
796
915
  const builtinPlugins = await getBuiltinPluginsFromConfig(
797
916
  {
798
917
  ...loadedConfig,
799
- ...opts
918
+ ...opts,
919
+ openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
800
920
  },
801
921
  {
802
922
  log: ctx.log,
@@ -890,11 +1010,17 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
890
1010
  ).env("APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT")
891
1011
  ).action(async function supergraph(schemaPathOrUrl) {
892
1012
  const {
1013
+ opentelemetry,
1014
+ opentelemetryExporterType,
893
1015
  hiveCdnEndpoint,
894
1016
  hiveCdnKey,
895
1017
  hiveRegistryToken,
896
1018
  hiveUsageTarget,
1019
+ hiveTarget,
1020
+ hiveAccessToken,
897
1021
  hiveUsageAccessToken,
1022
+ hiveTraceAccessToken,
1023
+ hiveTraceEndpoint,
898
1024
  maskedErrors,
899
1025
  apolloGraphRef,
900
1026
  apolloKey,
@@ -906,6 +1032,13 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
906
1032
  ctx.log.info(
907
1033
  `Starting ${ctx.productName} ${ctx.version} with supergraph`
908
1034
  );
1035
+ const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
1036
+ openTelemetry: opentelemetry,
1037
+ openTelemetryExporterType: opentelemetryExporterType,
1038
+ hiveTarget,
1039
+ hiveTraceAccessToken,
1040
+ hiveTraceEndpoint
1041
+ });
909
1042
  const loadedConfig = await loadConfig({
910
1043
  log: ctx.log,
911
1044
  configPath: opts.configPath,
@@ -991,6 +1124,9 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
991
1124
  }
992
1125
  const registryConfig = {};
993
1126
  const reporting = handleReportingConfig(ctx, loadedConfig, {
1127
+ hiveTarget,
1128
+ hiveAccessToken,
1129
+ hiveTraceAccessToken,
994
1130
  hiveRegistryToken,
995
1131
  hiveUsageTarget,
996
1132
  hiveUsageAccessToken,
@@ -1013,7 +1149,8 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
1013
1149
  const builtinPlugins = await getBuiltinPluginsFromConfig(
1014
1150
  {
1015
1151
  ...loadedConfig,
1016
- ...opts
1152
+ ...opts,
1153
+ openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
1017
1154
  },
1018
1155
  {
1019
1156
  log: ctx.log,
@@ -1263,27 +1400,57 @@ let cli = new Command().configureHelp({
1263
1400
  // see here https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/command.js#L655
1264
1401
  // @ts-expect-error
1265
1402
  null
1403
+ ).addOption(
1404
+ new Option(
1405
+ "--opentelemetry [exporter-endpoint]",
1406
+ `Enable OpenTelemetry integration with an exporter using this option's value as endpoint. By default, it uses OTLP HTTP, use "--opentelemetry-exporter-type" to change the default.`
1407
+ ).env("OPENTELEMETRY")
1408
+ ).addOption(
1409
+ new Option(
1410
+ "--opentelemetry-exporter-type <type>",
1411
+ `OpenTelemetry exporter type to use when setting up OpenTelemetry integration. Requires "--opentelemetry" to set the endpoint.`
1412
+ ).choices(["otlp-http", "otlp-grpc"]).default("otlp-http").env("OPENTELEMETRY_EXPORTER_TYPE")
1266
1413
  ).addOption(
1267
1414
  new Option(
1268
1415
  "--hive-registry-token <token>",
1269
- '[DEPRECATED: please use "--hive-usage-target" and "--hive-usage-access-token"] Hive registry token for usage metrics reporting'
1416
+ '[DEPRECATED] please use "--hive-target" and "--hive-access-token"'
1270
1417
  ).env("HIVE_REGISTRY_TOKEN")
1271
1418
  ).addOption(
1272
1419
  new Option(
1273
1420
  "--hive-usage-target <target>",
1274
- 'Hive registry target to which the usage data should be reported to. requires the "--hive-usage-access-token <token>" option'
1421
+ "[DEPRECATED] please use --hive-target instead."
1275
1422
  ).env("HIVE_USAGE_TARGET")
1423
+ ).addOption(
1424
+ new Option(
1425
+ "--hive-target <target>",
1426
+ 'Hive registry target to which the usage and tracing data should be reported to. Requires either "--hive-access-token <token>", "--hive-usage-access-token <token>" or "--hive-trace-access-token" option'
1427
+ ).env("HIVE_TARGET")
1428
+ ).addOption(
1429
+ new Option(
1430
+ "--hive-access-token <token>",
1431
+ 'Hive registry access token for usage metrics reporting and tracing. Enables both usage reporting and tracing. Requires the "--hive-target <target>" option'
1432
+ ).env("HIVE_ACCESS_TOKEN")
1276
1433
  ).addOption(
1277
1434
  new Option(
1278
1435
  "--hive-usage-access-token <token>",
1279
- 'Hive registry access token for usage metrics reporting. requires the "--hive-usage-target <target>" option'
1436
+ `Hive registry access token for usage reporting. Enables Hive usage report. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
1280
1437
  ).env("HIVE_USAGE_ACCESS_TOKEN")
1438
+ ).addOption(
1439
+ new Option(
1440
+ "--hive-trace-access-token <token>",
1441
+ `Hive registry access token for tracing. Enables Hive tracing. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
1442
+ ).env("HIVE_TRACE_ACCESS_TOKEN")
1443
+ ).addOption(
1444
+ new Option(
1445
+ "--hive-trace-endpoint <endpoint>",
1446
+ `Hive registry tracing endpoint.`
1447
+ ).env("HIVE_TRACE_ENDPOINT").default(`https://api.graphql-hive.com/otel/v1/traces`)
1281
1448
  ).option(
1282
1449
  "--hive-persisted-documents-endpoint <endpoint>",
1283
- '[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. requires the "--hive-persisted-documents-token <token>" option'
1450
+ '[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. Requires the "--hive-persisted-documents-token <token>" option'
1284
1451
  ).option(
1285
1452
  "--hive-persisted-documents-token <token>",
1286
- '[EXPERIMENTAL] Hive persisted documents CDN endpoint token. requires the "--hive-persisted-documents-endpoint <endpoint>" option'
1453
+ '[EXPERIMENTAL] Hive persisted documents CDN endpoint token. Requires the "--hive-persisted-documents-endpoint <endpoint>" option'
1287
1454
  ).addOption(
1288
1455
  new Option(
1289
1456
  "--hive-cdn-endpoint <endpoint>",
@@ -16,6 +16,7 @@ var node_fs = require('node:fs');
16
16
  var node_http = require('node:http');
17
17
  var node_https = require('node:https');
18
18
  var utils$1 = require('@graphql-tools/utils');
19
+ var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
19
20
  var codeFileLoader = require('@graphql-tools/code-file-loader');
20
21
  var graphqlFileLoader = require('@graphql-tools/graphql-file-loader');
21
22
  var load = require('@graphql-tools/load');
@@ -520,11 +521,83 @@ function handleFork(log, config) {
520
521
  return false;
521
522
  }
522
523
 
524
+ async function handleOpenTelemetryConfig(ctx, cliOpts) {
525
+ const accessToken = cliOpts.hiveTraceAccessToken;
526
+ const traceEndpoint = cliOpts.hiveTraceEndpoint;
527
+ const target = cliOpts.hiveTarget;
528
+ const openTelemetry = cliOpts.openTelemetry;
529
+ const exporterType = cliOpts.openTelemetryExporterType ?? "otlp-http";
530
+ const log = ctx.log.child("[OpenTelemetry] ");
531
+ if (openTelemetry || accessToken) {
532
+ log.debug(
533
+ { openTelemetry, exporterType, target, traceEndpoint },
534
+ "Initializing OpenTelemetry SDK"
535
+ );
536
+ return utils$1.fakePromise().then(async () => {
537
+ const { openTelemetrySetup, HiveTracingSpanProcessor, getEnvVar } = await import('@graphql-mesh/plugin-opentelemetry/setup');
538
+ const processors = [];
539
+ const logAttributes = {
540
+ traceEndpoints: [],
541
+ contextManager: false
542
+ };
543
+ let integrationName;
544
+ if (openTelemetry) {
545
+ const otelEndpoint = typeof openTelemetry === "string" ? openTelemetry : getEnvVar("OTEL_EXPORTER_OTLP_ENDPOINT", void 0);
546
+ log.debug({ exporterType, otelEndpoint }, "Setting up OTLP Exporter");
547
+ integrationName = "OpenTelemetry";
548
+ logAttributes.traceEndpoints.push({
549
+ url: otelEndpoint ?? null,
550
+ type: exporterType
551
+ });
552
+ log.debug({ type: exporterType }, "Loading OpenTelemetry exporter");
553
+ const { OTLPTraceExporter } = await import(`@opentelemetry/exporter-trace-${exporterType}`);
554
+ processors.push(
555
+ new sdkTraceBase.BatchSpanProcessor(new OTLPTraceExporter({ url: otelEndpoint }))
556
+ );
557
+ }
558
+ if (accessToken) {
559
+ log.debug({ target, traceEndpoint }, "Setting up Hive Tracing");
560
+ integrationName ??= "Hive Tracing";
561
+ if (!target) {
562
+ ctx.log.error(
563
+ 'Hive tracing needs a target. Please provide it through "--hive-target <target>"'
564
+ );
565
+ process.exit(1);
566
+ }
567
+ logAttributes.traceEndpoints.push({
568
+ url: traceEndpoint,
569
+ type: "hive tracing",
570
+ target
571
+ });
572
+ processors.push(
573
+ new HiveTracingSpanProcessor({
574
+ accessToken,
575
+ target,
576
+ endpoint: traceEndpoint
577
+ })
578
+ );
579
+ }
580
+ log.debug("Trying to load AsyncLocalStorage based Context Manager");
581
+ const contextManager = await import('@opentelemetry/context-async-hooks').then((module) => {
582
+ logAttributes.contextManager = true;
583
+ return new module.AsyncLocalStorageContextManager();
584
+ }).catch(() => null);
585
+ openTelemetrySetup({
586
+ traces: { processors },
587
+ contextManager
588
+ });
589
+ log.info(logAttributes, `${integrationName} integration is enabled`);
590
+ return true;
591
+ });
592
+ }
593
+ return false;
594
+ }
595
+
523
596
  function handleReportingConfig(ctx, loadedConfig, cliOpts) {
524
597
  const confOpts = {
525
598
  ...loadedConfig.reporting?.type === "hive" ? {
526
599
  hiveRegistryToken: loadedConfig.reporting.token,
527
- hiveUsageTarget: loadedConfig.reporting.target,
600
+ hiveTarget: loadedConfig.reporting.target,
528
601
  hiveUsageAccessToken: loadedConfig.reporting.token
529
602
  } : {},
530
603
  ...loadedConfig.reporting?.type === "graphos" ? {
@@ -532,32 +605,45 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
532
605
  apolloKey: loadedConfig.reporting.apiKey
533
606
  } : {}
534
607
  };
535
- const opts = { ...confOpts, ...cliOpts };
608
+ const opts = {
609
+ ...confOpts,
610
+ ...cliOpts,
611
+ hiveTarget: (
612
+ // cli arguments always take precedence over config
613
+ confOpts.hiveTarget ?? cliOpts.hiveTarget ?? cliOpts.hiveUsageTarget
614
+ )
615
+ };
536
616
  if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) {
537
617
  ctx.log.error(
538
618
  'Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
539
619
  );
540
620
  process.exit(1);
541
621
  }
542
- if (cliOpts.hiveRegistryToken && opts.hiveUsageTarget) {
622
+ if (cliOpts.hiveUsageTarget && cliOpts.hiveTarget) {
623
+ ctx.log.error(
624
+ 'Cannot use "--hive-usage-target" with "--hive-target". Please only use "--hive-target"'
625
+ );
626
+ process.exit(1);
627
+ }
628
+ if (cliOpts.hiveRegistryToken && opts.hiveTarget) {
543
629
  ctx.log.error(
544
630
  'Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
545
631
  );
546
632
  process.exit(1);
547
633
  }
548
- if (opts.hiveUsageTarget && !opts.hiveUsageAccessToken) {
634
+ if (opts.hiveTarget && !opts.hiveAccessToken && !opts.hiveUsageAccessToken && !opts.hiveTraceAccessToken) {
549
635
  ctx.log.error(
550
- 'Hive usage target needs an access token. Please provide it through the "--hive-usage-access-token <token>" option or the config.'
636
+ 'Hive usage target needs an access token. Please provide it through "--hive-access-token <token>", or specific "--hive-usage-access-token <token>" and "--hive-trace-access-token" options, or the config.'
551
637
  );
552
638
  process.exit(1);
553
639
  }
554
- if (opts.hiveUsageAccessToken && !opts.hiveUsageTarget) {
640
+ if ((opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveTraceAccessToken) && !opts.hiveTarget) {
555
641
  ctx.log.error(
556
- 'Hive usage access token needs a target. Please provide it through the "--hive-usage-target <target>" option or the config.'
642
+ 'Hive access token needs a target. Please provide it through the "--hive-target <target>" option or the config.'
557
643
  );
558
644
  process.exit(1);
559
645
  }
560
- const hiveUsageAccessToken = opts.hiveUsageAccessToken || opts.hiveRegistryToken;
646
+ const hiveUsageAccessToken = opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveRegistryToken;
561
647
  if (hiveUsageAccessToken) {
562
648
  if (opts.hiveUsageTarget) {
563
649
  ctx.log.info("Configuring Hive usage reporting");
@@ -568,7 +654,7 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
568
654
  ...loadedConfig.reporting,
569
655
  type: "hive",
570
656
  token: hiveUsageAccessToken,
571
- target: opts.hiveUsageTarget
657
+ target: opts.hiveTarget
572
658
  };
573
659
  }
574
660
  if (opts.apolloKey) {
@@ -596,17 +682,30 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
596
682
  "path to the GraphQL schema file or a url from where to pull the schema"
597
683
  ).action(async function proxy(endpoint) {
598
684
  const {
685
+ opentelemetry,
686
+ opentelemetryExporterType,
599
687
  hiveCdnEndpoint,
600
688
  hiveCdnKey,
601
689
  hiveRegistryToken,
690
+ hiveTarget,
602
691
  hiveUsageTarget,
692
+ hiveAccessToken,
603
693
  hiveUsageAccessToken,
694
+ hiveTraceAccessToken,
695
+ hiveTraceEndpoint,
604
696
  maskedErrors,
605
697
  hivePersistedDocumentsEndpoint,
606
698
  hivePersistedDocumentsToken,
607
699
  ...opts
608
700
  } = this.optsWithGlobals();
609
701
  ctx.log.info(`Starting ${ctx.productName} ${ctx.version} in proxy mode`);
702
+ const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
703
+ openTelemetry: opentelemetry,
704
+ openTelemetryExporterType: opentelemetryExporterType,
705
+ hiveTarget,
706
+ hiveTraceAccessToken,
707
+ hiveTraceEndpoint
708
+ });
610
709
  const loadedConfig = await loadConfig({
611
710
  log: ctx.log,
612
711
  configPath: opts.configPath,
@@ -660,8 +759,11 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
660
759
  const registryConfig = {};
661
760
  const reporting = handleReportingConfig(ctx, loadedConfig, {
662
761
  hiveRegistryToken,
762
+ hiveTarget,
663
763
  hiveUsageTarget,
764
+ hiveAccessToken,
664
765
  hiveUsageAccessToken,
766
+ hiveTraceAccessToken,
665
767
  // proxy can only do reporting to hive registry
666
768
  apolloGraphRef: void 0,
667
769
  apolloKey: void 0
@@ -682,7 +784,8 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
682
784
  const builtinPlugins = await getBuiltinPluginsFromConfig(
683
785
  {
684
786
  ...loadedConfig,
685
- ...opts
787
+ ...opts,
788
+ openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
686
789
  },
687
790
  {
688
791
  log: ctx.log,
@@ -757,15 +860,28 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
757
860
  'path to the subgraph schema file or a url from where to pull the subgraph schema (default: "subgraph.graphql")'
758
861
  ).action(async function subgraph(schemaPathOrUrl) {
759
862
  const {
863
+ opentelemetry,
864
+ opentelemetryExporterType,
760
865
  maskedErrors,
761
866
  hiveRegistryToken,
867
+ hiveTarget,
762
868
  hiveUsageTarget,
869
+ hiveAccessToken,
763
870
  hiveUsageAccessToken,
871
+ hiveTraceAccessToken,
872
+ hiveTraceEndpoint,
764
873
  hivePersistedDocumentsEndpoint,
765
874
  hivePersistedDocumentsToken,
766
875
  ...opts
767
876
  } = this.optsWithGlobals();
768
877
  ctx.log.info(`Starting ${ctx.productName} ${ctx.version} as subgraph`);
878
+ const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
879
+ openTelemetry: opentelemetry,
880
+ openTelemetryExporterType: opentelemetryExporterType,
881
+ hiveTarget,
882
+ hiveTraceAccessToken,
883
+ hiveTraceEndpoint
884
+ });
769
885
  const loadedConfig = await loadConfig({
770
886
  log: ctx.log,
771
887
  configPath: opts.configPath,
@@ -781,8 +897,11 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
781
897
  const registryConfig = {};
782
898
  const reporting = handleReportingConfig(ctx, loadedConfig, {
783
899
  hiveRegistryToken,
900
+ hiveTarget,
784
901
  hiveUsageTarget,
902
+ hiveAccessToken,
785
903
  hiveUsageAccessToken,
904
+ hiveTraceAccessToken,
786
905
  // subgraph can only do reporting to hive registry
787
906
  apolloGraphRef: void 0,
788
907
  apolloKey: void 0
@@ -803,7 +922,8 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
803
922
  const builtinPlugins = await getBuiltinPluginsFromConfig(
804
923
  {
805
924
  ...loadedConfig,
806
- ...opts
925
+ ...opts,
926
+ openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
807
927
  },
808
928
  {
809
929
  log: ctx.log,
@@ -897,11 +1017,17 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
897
1017
  ).env("APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT")
898
1018
  ).action(async function supergraph(schemaPathOrUrl) {
899
1019
  const {
1020
+ opentelemetry,
1021
+ opentelemetryExporterType,
900
1022
  hiveCdnEndpoint,
901
1023
  hiveCdnKey,
902
1024
  hiveRegistryToken,
903
1025
  hiveUsageTarget,
1026
+ hiveTarget,
1027
+ hiveAccessToken,
904
1028
  hiveUsageAccessToken,
1029
+ hiveTraceAccessToken,
1030
+ hiveTraceEndpoint,
905
1031
  maskedErrors,
906
1032
  apolloGraphRef,
907
1033
  apolloKey,
@@ -913,6 +1039,13 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
913
1039
  ctx.log.info(
914
1040
  `Starting ${ctx.productName} ${ctx.version} with supergraph`
915
1041
  );
1042
+ const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
1043
+ openTelemetry: opentelemetry,
1044
+ openTelemetryExporterType: opentelemetryExporterType,
1045
+ hiveTarget,
1046
+ hiveTraceAccessToken,
1047
+ hiveTraceEndpoint
1048
+ });
916
1049
  const loadedConfig = await loadConfig({
917
1050
  log: ctx.log,
918
1051
  configPath: opts.configPath,
@@ -998,6 +1131,9 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
998
1131
  }
999
1132
  const registryConfig = {};
1000
1133
  const reporting = handleReportingConfig(ctx, loadedConfig, {
1134
+ hiveTarget,
1135
+ hiveAccessToken,
1136
+ hiveTraceAccessToken,
1001
1137
  hiveRegistryToken,
1002
1138
  hiveUsageTarget,
1003
1139
  hiveUsageAccessToken,
@@ -1020,7 +1156,8 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
1020
1156
  const builtinPlugins = await getBuiltinPluginsFromConfig(
1021
1157
  {
1022
1158
  ...loadedConfig,
1023
- ...opts
1159
+ ...opts,
1160
+ openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
1024
1161
  },
1025
1162
  {
1026
1163
  log: ctx.log,
@@ -1270,27 +1407,57 @@ let cli = new extraTypings.Command().configureHelp({
1270
1407
  // see here https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/command.js#L655
1271
1408
  // @ts-expect-error
1272
1409
  null
1410
+ ).addOption(
1411
+ new extraTypings.Option(
1412
+ "--opentelemetry [exporter-endpoint]",
1413
+ `Enable OpenTelemetry integration with an exporter using this option's value as endpoint. By default, it uses OTLP HTTP, use "--opentelemetry-exporter-type" to change the default.`
1414
+ ).env("OPENTELEMETRY")
1415
+ ).addOption(
1416
+ new extraTypings.Option(
1417
+ "--opentelemetry-exporter-type <type>",
1418
+ `OpenTelemetry exporter type to use when setting up OpenTelemetry integration. Requires "--opentelemetry" to set the endpoint.`
1419
+ ).choices(["otlp-http", "otlp-grpc"]).default("otlp-http").env("OPENTELEMETRY_EXPORTER_TYPE")
1273
1420
  ).addOption(
1274
1421
  new extraTypings.Option(
1275
1422
  "--hive-registry-token <token>",
1276
- '[DEPRECATED: please use "--hive-usage-target" and "--hive-usage-access-token"] Hive registry token for usage metrics reporting'
1423
+ '[DEPRECATED] please use "--hive-target" and "--hive-access-token"'
1277
1424
  ).env("HIVE_REGISTRY_TOKEN")
1278
1425
  ).addOption(
1279
1426
  new extraTypings.Option(
1280
1427
  "--hive-usage-target <target>",
1281
- 'Hive registry target to which the usage data should be reported to. requires the "--hive-usage-access-token <token>" option'
1428
+ "[DEPRECATED] please use --hive-target instead."
1282
1429
  ).env("HIVE_USAGE_TARGET")
1430
+ ).addOption(
1431
+ new extraTypings.Option(
1432
+ "--hive-target <target>",
1433
+ 'Hive registry target to which the usage and tracing data should be reported to. Requires either "--hive-access-token <token>", "--hive-usage-access-token <token>" or "--hive-trace-access-token" option'
1434
+ ).env("HIVE_TARGET")
1435
+ ).addOption(
1436
+ new extraTypings.Option(
1437
+ "--hive-access-token <token>",
1438
+ 'Hive registry access token for usage metrics reporting and tracing. Enables both usage reporting and tracing. Requires the "--hive-target <target>" option'
1439
+ ).env("HIVE_ACCESS_TOKEN")
1283
1440
  ).addOption(
1284
1441
  new extraTypings.Option(
1285
1442
  "--hive-usage-access-token <token>",
1286
- 'Hive registry access token for usage metrics reporting. requires the "--hive-usage-target <target>" option'
1443
+ `Hive registry access token for usage reporting. Enables Hive usage report. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
1287
1444
  ).env("HIVE_USAGE_ACCESS_TOKEN")
1445
+ ).addOption(
1446
+ new extraTypings.Option(
1447
+ "--hive-trace-access-token <token>",
1448
+ `Hive registry access token for tracing. Enables Hive tracing. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
1449
+ ).env("HIVE_TRACE_ACCESS_TOKEN")
1450
+ ).addOption(
1451
+ new extraTypings.Option(
1452
+ "--hive-trace-endpoint <endpoint>",
1453
+ `Hive registry tracing endpoint.`
1454
+ ).env("HIVE_TRACE_ENDPOINT").default(`https://api.graphql-hive.com/otel/v1/traces`)
1288
1455
  ).option(
1289
1456
  "--hive-persisted-documents-endpoint <endpoint>",
1290
- '[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. requires the "--hive-persisted-documents-token <token>" option'
1457
+ '[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. Requires the "--hive-persisted-documents-token <token>" option'
1291
1458
  ).option(
1292
1459
  "--hive-persisted-documents-token <token>",
1293
- '[EXPERIMENTAL] Hive persisted documents CDN endpoint token. requires the "--hive-persisted-documents-endpoint <endpoint>" option'
1460
+ '[EXPERIMENTAL] Hive persisted documents CDN endpoint token. Requires the "--hive-persisted-documents-endpoint <endpoint>" option'
1294
1461
  ).addOption(
1295
1462
  new extraTypings.Option(
1296
1463
  "--hive-cdn-endpoint <endpoint>",
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var cli = require('./cli-B4botk_4.cjs');
3
+ var cli = require('./cli-Cm9aDkDW.cjs');
4
4
  var logger = require('@graphql-hive/logger');
5
5
  var gatewayRuntime = require('@graphql-hive/gateway-runtime');
6
6
  var pubsub = require('@graphql-hive/pubsub');
@@ -31,6 +31,7 @@ require('node:fs');
31
31
  require('node:http');
32
32
  require('node:https');
33
33
  require('@graphql-tools/utils');
34
+ require('@opentelemetry/sdk-trace-base');
34
35
  require('@graphql-tools/code-file-loader');
35
36
  require('@graphql-tools/graphql-file-loader');
36
37
  require('@graphql-tools/load');
package/dist/index.d.cts CHANGED
@@ -268,9 +268,15 @@ declare let cli: Command<[], {
268
268
  port?: number | undefined;
269
269
  polling?: number | undefined;
270
270
  maskedErrors: string | boolean | string[] | [];
271
+ opentelemetry?: string | true | undefined;
272
+ opentelemetryExporterType: "otlp-http" | "otlp-grpc";
271
273
  hiveRegistryToken?: string | undefined;
272
274
  hiveUsageTarget?: string | undefined;
275
+ hiveTarget?: string | undefined;
276
+ hiveAccessToken?: string | undefined;
273
277
  hiveUsageAccessToken?: string | undefined;
278
+ hiveTraceAccessToken?: string | undefined;
279
+ hiveTraceEndpoint: string;
274
280
  hivePersistedDocumentsEndpoint?: string | undefined;
275
281
  hivePersistedDocumentsToken?: string | undefined;
276
282
  hiveCdnEndpoint?: string | undefined;
@@ -287,9 +293,15 @@ declare function run(userCtx: Partial<CLIContext>): Promise<Command<[], {
287
293
  port?: number | undefined;
288
294
  polling?: number | undefined;
289
295
  maskedErrors: string | boolean | string[] | [];
296
+ opentelemetry?: string | true | undefined;
297
+ opentelemetryExporterType: "otlp-http" | "otlp-grpc";
290
298
  hiveRegistryToken?: string | undefined;
291
299
  hiveUsageTarget?: string | undefined;
300
+ hiveTarget?: string | undefined;
301
+ hiveAccessToken?: string | undefined;
292
302
  hiveUsageAccessToken?: string | undefined;
303
+ hiveTraceAccessToken?: string | undefined;
304
+ hiveTraceEndpoint: string;
293
305
  hivePersistedDocumentsEndpoint?: string | undefined;
294
306
  hivePersistedDocumentsToken?: string | undefined;
295
307
  hiveCdnEndpoint?: string | undefined;
package/dist/index.d.ts CHANGED
@@ -268,9 +268,15 @@ declare let cli: Command<[], {
268
268
  port?: number | undefined;
269
269
  polling?: number | undefined;
270
270
  maskedErrors: string | boolean | string[] | [];
271
+ opentelemetry?: string | true | undefined;
272
+ opentelemetryExporterType: "otlp-http" | "otlp-grpc";
271
273
  hiveRegistryToken?: string | undefined;
272
274
  hiveUsageTarget?: string | undefined;
275
+ hiveTarget?: string | undefined;
276
+ hiveAccessToken?: string | undefined;
273
277
  hiveUsageAccessToken?: string | undefined;
278
+ hiveTraceAccessToken?: string | undefined;
279
+ hiveTraceEndpoint: string;
274
280
  hivePersistedDocumentsEndpoint?: string | undefined;
275
281
  hivePersistedDocumentsToken?: string | undefined;
276
282
  hiveCdnEndpoint?: string | undefined;
@@ -287,9 +293,15 @@ declare function run(userCtx: Partial<CLIContext>): Promise<Command<[], {
287
293
  port?: number | undefined;
288
294
  polling?: number | undefined;
289
295
  maskedErrors: string | boolean | string[] | [];
296
+ opentelemetry?: string | true | undefined;
297
+ opentelemetryExporterType: "otlp-http" | "otlp-grpc";
290
298
  hiveRegistryToken?: string | undefined;
291
299
  hiveUsageTarget?: string | undefined;
300
+ hiveTarget?: string | undefined;
301
+ hiveAccessToken?: string | undefined;
292
302
  hiveUsageAccessToken?: string | undefined;
303
+ hiveTraceAccessToken?: string | undefined;
304
+ hiveTraceEndpoint: string;
293
305
  hivePersistedDocumentsEndpoint?: string | undefined;
294
306
  hivePersistedDocumentsToken?: string | undefined;
295
307
  hiveCdnEndpoint?: string | undefined;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { b as defaultOptions, d as defineConfig, e as enableModuleCachingIfPossible, a as getBuiltinPluginsFromConfig, g as getCacheInstanceFromConfig, h as handleNodeWarnings, r as run } from './cli-BykXyWTB.js';
1
+ export { b as defaultOptions, d as defineConfig, e as enableModuleCachingIfPossible, a as getBuiltinPluginsFromConfig, g as getCacheInstanceFromConfig, h as handleNodeWarnings, r as run } from './cli-BPJkk_8e.js';
2
2
  export * from '@graphql-hive/logger';
3
3
  export * from '@graphql-hive/gateway-runtime';
4
4
  export { PubSub } from '@graphql-hive/pubsub';
@@ -30,6 +30,7 @@ import 'node:fs';
30
30
  import 'node:http';
31
31
  import 'node:https';
32
32
  import '@graphql-tools/utils';
33
+ import '@opentelemetry/sdk-trace-base';
33
34
  import '@graphql-tools/code-file-loader';
34
35
  import '@graphql-tools/graphql-file-loader';
35
36
  import '@graphql-tools/load';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/gateway",
3
- "version": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
3
+ "version": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,28 +53,28 @@
53
53
  "@escape.tech/graphql-armor-block-field-suggestions": "^3.0.0",
54
54
  "@escape.tech/graphql-armor-max-depth": "^2.4.0",
55
55
  "@escape.tech/graphql-armor-max-tokens": "^2.5.0",
56
- "@graphql-hive/gateway-runtime": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
57
- "@graphql-hive/importer": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
58
- "@graphql-hive/logger": "1.0.1-next-c8fe4c675533551cd98c6101206b9395a5621f41",
59
- "@graphql-hive/plugin-aws-sigv4": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
60
- "@graphql-hive/plugin-deduplicate-request": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
61
- "@graphql-hive/pubsub": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
56
+ "@graphql-hive/gateway-runtime": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
57
+ "@graphql-hive/importer": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
58
+ "@graphql-hive/logger": "1.0.1-next-2806fc3679108314404c709df381d642ebb4b2dc",
59
+ "@graphql-hive/plugin-aws-sigv4": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
60
+ "@graphql-hive/plugin-deduplicate-request": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
61
+ "@graphql-hive/pubsub": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
62
62
  "@graphql-mesh/cache-cfw-kv": "^0.105.5",
63
63
  "@graphql-mesh/cache-localforage": "^0.105.6",
64
64
  "@graphql-mesh/cache-redis": "^0.104.5",
65
65
  "@graphql-mesh/cache-upstash-redis": "^0.1.5",
66
66
  "@graphql-mesh/cross-helpers": "^0.4.10",
67
- "@graphql-mesh/hmac-upstream-signature": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
67
+ "@graphql-mesh/hmac-upstream-signature": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
68
68
  "@graphql-mesh/plugin-http-cache": "^0.105.6",
69
69
  "@graphql-mesh/plugin-jit": "^0.2.5",
70
- "@graphql-mesh/plugin-jwt-auth": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
71
- "@graphql-mesh/plugin-opentelemetry": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
72
- "@graphql-mesh/plugin-prometheus": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
70
+ "@graphql-mesh/plugin-jwt-auth": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
71
+ "@graphql-mesh/plugin-opentelemetry": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
72
+ "@graphql-mesh/plugin-prometheus": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
73
73
  "@graphql-mesh/plugin-rate-limit": "^0.104.5",
74
74
  "@graphql-mesh/plugin-snapshot": "^0.104.5",
75
- "@graphql-mesh/transport-http": "1.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
76
- "@graphql-mesh/transport-http-callback": "1.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
77
- "@graphql-mesh/transport-ws": "2.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
75
+ "@graphql-mesh/transport-http": "1.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
76
+ "@graphql-mesh/transport-http-callback": "1.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
77
+ "@graphql-mesh/transport-ws": "2.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
78
78
  "@graphql-mesh/types": "^0.104.5",
79
79
  "@graphql-mesh/utils": "^0.104.5",
80
80
  "@graphql-tools/code-file-loader": "^8.1.15",
@@ -84,6 +84,7 @@
84
84
  "@graphql-yoga/render-graphiql": "^5.15.1",
85
85
  "@opentelemetry/api": "^1.9.0",
86
86
  "@opentelemetry/api-logs": "^0.202.0",
87
+ "@opentelemetry/context-async-hooks": "^2.0.1",
87
88
  "@opentelemetry/context-zone": "^2.0.1",
88
89
  "@opentelemetry/core": "^2.0.1",
89
90
  "@opentelemetry/exporter-jaeger": "^2.0.1",
@@ -93,6 +94,7 @@
93
94
  "@opentelemetry/sampler-jaeger-remote": "^0.202.0",
94
95
  "@opentelemetry/sdk-logs": "^0.202.0",
95
96
  "@opentelemetry/sdk-metrics": "^2.0.1",
97
+ "@opentelemetry/sdk-trace-base": "^2.0.1",
96
98
  "commander": "^13.1.0",
97
99
  "dotenv": "^17.2.0",
98
100
  "graphql-ws": "^6.0.6",
@@ -101,7 +103,7 @@
101
103
  "ws": "^8.18.3"
102
104
  },
103
105
  "devDependencies": {
104
- "@graphql-mesh/transport-common": "1.0.0-next-c8fe4c675533551cd98c6101206b9395a5621f41",
106
+ "@graphql-mesh/transport-common": "1.0.0-next-2806fc3679108314404c709df381d642ebb4b2dc",
105
107
  "@graphql-mesh/transport-soap": "^0.10.6",
106
108
  "@graphql-tools/executor": "^1.4.7",
107
109
  "@rollup/plugin-commonjs": "^28.0.0",