@graphql-hive/gateway 2.0.0-alpha-6c3626db73cf3cea88b05a477f5a1b2f8b1e45f5 → 2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
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 +19 -15
- package/dist/bin.cjs +2 -1
- package/dist/bin.js +2 -1
- package/dist/{cli-CpJrCTMy.js → cli-C8SAeNPg.js} +185 -18
- package/dist/{cli-BQ10GobO.cjs → cli-CQdLYWjW.cjs} +184 -17
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2 -1
- package/package.json +17 -15
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# @graphql-hive/gateway
|
2
2
|
|
3
|
-
## 2.0.0-alpha-
|
3
|
+
## 2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
4
4
|
|
5
5
|
### Major Changes
|
6
6
|
|
@@ -44,6 +44,10 @@
|
|
44
44
|
- Added dependency [`@opentelemetry/api-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api-logs/v/0.202.0) (to `dependencies`)
|
45
45
|
- Added dependency [`@opentelemetry/sdk-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-logs/v/0.202.0) (to `dependencies`)
|
46
46
|
|
47
|
+
- [#1300](https://github.com/graphql-hive/gateway/pull/1300) [`1ba0cf4`](https://github.com/graphql-hive/gateway/commit/1ba0cf4a6359e41a6ab16f940d8733d3ad9d800b) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
48
|
+
- Added dependency [`@opentelemetry/context-async-hooks@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/context-async-hooks/v/2.0.1) (to `dependencies`)
|
49
|
+
- Added dependency [`@opentelemetry/sdk-trace-base@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-trace-base/v/2.0.1) (to `dependencies`)
|
50
|
+
|
47
51
|
- [#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:
|
48
52
|
- 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`)
|
49
53
|
- Updated dependency [`graphql-yoga@^5.15.1` ↗︎](https://www.npmjs.com/package/graphql-yoga/v/5.15.1) (from `^5.13.5`, in `dependencies`)
|
@@ -70,20 +74,20 @@
|
|
70
74
|
- Added dependency [`@opentelemetry/sdk-metrics@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-metrics/v/2.0.1) (to `dependencies`)
|
71
75
|
- Removed dependency [`@graphql-mesh/plugin-mock@^0.105.6` ↗︎](https://www.npmjs.com/package/@graphql-mesh/plugin-mock/v/0.105.6) (from `dependencies`)
|
72
76
|
|
73
|
-
- Updated dependencies [[`95484c2`](https://github.com/graphql-hive/gateway/commit/95484c2ca0cea1cd732df4bfe8ce45032ec31d42), [`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), [`8b7db06`](https://github.com/graphql-hive/gateway/commit/8b7db06887f5dec52d380bfc123dbf495cbe04ef), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`9e4d81c`](https://github.com/graphql-hive/gateway/commit/9e4d81c2ad9e99d2195e3f2a021a30a9312cf980), [`f3caa12`](https://github.com/graphql-hive/gateway/commit/f3caa12a7ad50cdc03c82f2336f820e8ccbad55e), [`
|
74
|
-
- @graphql-hive/gateway-runtime@2.0.0-alpha-
|
75
|
-
- @graphql-hive/plugin-aws-sigv4@2.0.0-alpha-
|
76
|
-
- @graphql-mesh/plugin-jwt-auth@2.0.0-alpha-
|
77
|
-
- @graphql-mesh/plugin-opentelemetry@2.0.0-alpha-
|
78
|
-
- @graphql-mesh/plugin-prometheus@2.0.0-alpha-
|
79
|
-
- @graphql-mesh/transport-ws@2.0.0-alpha-
|
80
|
-
- @graphql-mesh/hmac-upstream-signature@2.0.0-alpha-
|
81
|
-
- @graphql-hive/plugin-deduplicate-request@2.0.0-alpha-
|
82
|
-
- @graphql-mesh/transport-http-callback@1.0.0-alpha-
|
83
|
-
- @graphql-mesh/transport-http@1.0.0-alpha-
|
84
|
-
- @graphql-hive/importer@2.0.0-alpha-
|
85
|
-
- @graphql-hive/pubsub@2.0.0-alpha-
|
86
|
-
- @graphql-hive/logger@1.0.1-alpha-
|
77
|
+
- Updated dependencies [[`95484c2`](https://github.com/graphql-hive/gateway/commit/95484c2ca0cea1cd732df4bfe8ce45032ec31d42), [`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), [`8b7db06`](https://github.com/graphql-hive/gateway/commit/8b7db06887f5dec52d380bfc123dbf495cbe04ef), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`9e4d81c`](https://github.com/graphql-hive/gateway/commit/9e4d81c2ad9e99d2195e3f2a021a30a9312cf980), [`f3caa12`](https://github.com/graphql-hive/gateway/commit/f3caa12a7ad50cdc03c82f2336f820e8ccbad55e), [`1ba0cf4`](https://github.com/graphql-hive/gateway/commit/1ba0cf4a6359e41a6ab16f940d8733d3ad9d800b), [`dfe6f58`](https://github.com/graphql-hive/gateway/commit/dfe6f58209afd27953676c5b51b8b9f07fc99671), [`ceb07a6`](https://github.com/graphql-hive/gateway/commit/ceb07a61f6f1c7ca345df2c23860950e5152288e), [`732c6f5`](https://github.com/graphql-hive/gateway/commit/732c6f5c82fdf6b730109fbc7c05c69da8ce6fb4), [`95484c2`](https://github.com/graphql-hive/gateway/commit/95484c2ca0cea1cd732df4bfe8ce45032ec31d42), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`8b7db06`](https://github.com/graphql-hive/gateway/commit/8b7db06887f5dec52d380bfc123dbf495cbe04ef), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`cd9b7ce`](https://github.com/graphql-hive/gateway/commit/cd9b7ce551ec702c00b33e6c1b2cf68f0a6c82a3), [`95484c2`](https://github.com/graphql-hive/gateway/commit/95484c2ca0cea1cd732df4bfe8ce45032ec31d42), [`f052709`](https://github.com/graphql-hive/gateway/commit/f0527092e4942b4c97cb3272266f93f3200fac98), [`9bee8e9`](https://github.com/graphql-hive/gateway/commit/9bee8e9ff165c43591c0b20637b6d1f2a2cb9cc2), [`9b230f3`](https://github.com/graphql-hive/gateway/commit/9b230f35b47afbf3b253e4c21720e836c5a2a8d1), [`10a5887`](https://github.com/graphql-hive/gateway/commit/10a58873acde8734f05dfda455fe7b366861676b), [`2a56e5f`](https://github.com/graphql-hive/gateway/commit/2a56e5fd5a07f6784e8c2d0ad767d8c55710ada4), [`ae37c4a`](https://github.com/graphql-hive/gateway/commit/ae37c4a4189e3ea20f2ce0d24e2509d2053eb244), [`732c6f5`](https://github.com/graphql-hive/gateway/commit/732c6f5c82fdf6b730109fbc7c05c69da8ce6fb4), [`95484c2`](https://github.com/graphql-hive/gateway/commit/95484c2ca0cea1cd732df4bfe8ce45032ec31d42), [`dbb4fd9`](https://github.com/graphql-hive/gateway/commit/dbb4fd9287ff872de5cc9f18546987bd71232df5)]:
|
78
|
+
- @graphql-hive/gateway-runtime@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
79
|
+
- @graphql-hive/plugin-aws-sigv4@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
80
|
+
- @graphql-mesh/plugin-jwt-auth@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
81
|
+
- @graphql-mesh/plugin-opentelemetry@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
82
|
+
- @graphql-mesh/plugin-prometheus@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
83
|
+
- @graphql-mesh/transport-ws@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
84
|
+
- @graphql-mesh/hmac-upstream-signature@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
85
|
+
- @graphql-hive/plugin-deduplicate-request@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
86
|
+
- @graphql-mesh/transport-http-callback@1.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
87
|
+
- @graphql-mesh/transport-http@1.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
88
|
+
- @graphql-hive/importer@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
89
|
+
- @graphql-hive/pubsub@2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
90
|
+
- @graphql-hive/logger@1.0.1-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f
|
87
91
|
|
88
92
|
## 1.15.4
|
89
93
|
|
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-
|
6
|
+
var cli = require('./cli-CQdLYWjW.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-
|
5
|
+
import { e as enableModuleCachingIfPossible, h as handleNodeWarnings, r as run } from './cli-C8SAeNPg.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';
|
@@ -485,11 +486,83 @@ function handleFork(log, config) {
|
|
485
486
|
return false;
|
486
487
|
}
|
487
488
|
|
489
|
+
async function handleOpenTelemetryConfig(ctx, cliOpts) {
|
490
|
+
const accessToken = cliOpts.hiveTraceAccessToken;
|
491
|
+
const traceEndpoint = cliOpts.hiveTraceEndpoint;
|
492
|
+
const target = cliOpts.hiveTarget;
|
493
|
+
const openTelemetry = cliOpts.openTelemetry;
|
494
|
+
const exporterType = cliOpts.openTelemetryExporterType ?? "otlp-http";
|
495
|
+
const log = ctx.log.child("[OpenTelemetry] ");
|
496
|
+
if (openTelemetry || accessToken) {
|
497
|
+
log.debug(
|
498
|
+
{ openTelemetry, exporterType, target, traceEndpoint },
|
499
|
+
"Initializing OpenTelemetry SDK"
|
500
|
+
);
|
501
|
+
return fakePromise().then(async () => {
|
502
|
+
const { openTelemetrySetup, HiveTracingSpanProcessor, getEnvVar } = await import('@graphql-mesh/plugin-opentelemetry/setup');
|
503
|
+
const processors = [];
|
504
|
+
const logAttributes = {
|
505
|
+
traceEndpoints: [],
|
506
|
+
contextManager: false
|
507
|
+
};
|
508
|
+
let integrationName;
|
509
|
+
if (openTelemetry) {
|
510
|
+
const otelEndpoint = typeof openTelemetry === "string" ? openTelemetry : getEnvVar("OTEL_EXPORTER_OTLP_ENDPOINT", void 0);
|
511
|
+
log.debug({ exporterType, otelEndpoint }, "Setting up OTLP Exporter");
|
512
|
+
integrationName = "OpenTelemetry";
|
513
|
+
logAttributes.traceEndpoints.push({
|
514
|
+
url: otelEndpoint ?? null,
|
515
|
+
type: exporterType
|
516
|
+
});
|
517
|
+
log.debug({ type: exporterType }, "Loading OpenTelemetry exporter");
|
518
|
+
const { OTLPTraceExporter } = await import(`@opentelemetry/exporter-trace-${exporterType}`);
|
519
|
+
processors.push(
|
520
|
+
new BatchSpanProcessor(new OTLPTraceExporter({ url: otelEndpoint }))
|
521
|
+
);
|
522
|
+
}
|
523
|
+
if (accessToken) {
|
524
|
+
log.debug({ target, traceEndpoint }, "Setting up Hive Tracing");
|
525
|
+
integrationName ??= "Hive Tracing";
|
526
|
+
if (!target) {
|
527
|
+
ctx.log.error(
|
528
|
+
'Hive tracing needs a target. Please provide it through "--hive-target <target>"'
|
529
|
+
);
|
530
|
+
process.exit(1);
|
531
|
+
}
|
532
|
+
logAttributes.traceEndpoints.push({
|
533
|
+
url: traceEndpoint,
|
534
|
+
type: "hive tracing",
|
535
|
+
target
|
536
|
+
});
|
537
|
+
processors.push(
|
538
|
+
new HiveTracingSpanProcessor({
|
539
|
+
accessToken,
|
540
|
+
target,
|
541
|
+
endpoint: traceEndpoint
|
542
|
+
})
|
543
|
+
);
|
544
|
+
}
|
545
|
+
log.debug("Trying to load AsyncLocalStorage based Context Manager");
|
546
|
+
const contextManager = await import('@opentelemetry/context-async-hooks').then((module) => {
|
547
|
+
logAttributes.contextManager = true;
|
548
|
+
return new module.AsyncLocalStorageContextManager();
|
549
|
+
}).catch(() => null);
|
550
|
+
openTelemetrySetup({
|
551
|
+
traces: { processors },
|
552
|
+
contextManager
|
553
|
+
});
|
554
|
+
log.info(logAttributes, `${integrationName} integration is enabled`);
|
555
|
+
return true;
|
556
|
+
});
|
557
|
+
}
|
558
|
+
return false;
|
559
|
+
}
|
560
|
+
|
488
561
|
function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
489
562
|
const confOpts = {
|
490
563
|
...loadedConfig.reporting?.type === "hive" ? {
|
491
564
|
hiveRegistryToken: loadedConfig.reporting.token,
|
492
|
-
|
565
|
+
hiveTarget: loadedConfig.reporting.target,
|
493
566
|
hiveUsageAccessToken: loadedConfig.reporting.token
|
494
567
|
} : {},
|
495
568
|
...loadedConfig.reporting?.type === "graphos" ? {
|
@@ -497,32 +570,45 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
497
570
|
apolloKey: loadedConfig.reporting.apiKey
|
498
571
|
} : {}
|
499
572
|
};
|
500
|
-
const opts = {
|
573
|
+
const opts = {
|
574
|
+
...confOpts,
|
575
|
+
...cliOpts,
|
576
|
+
hiveTarget: (
|
577
|
+
// cli arguments always take precedence over config
|
578
|
+
confOpts.hiveTarget ?? cliOpts.hiveTarget ?? cliOpts.hiveUsageTarget
|
579
|
+
)
|
580
|
+
};
|
501
581
|
if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) {
|
502
582
|
ctx.log.error(
|
503
583
|
'Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
504
584
|
);
|
505
585
|
process.exit(1);
|
506
586
|
}
|
507
|
-
if (cliOpts.
|
587
|
+
if (cliOpts.hiveUsageTarget && cliOpts.hiveTarget) {
|
588
|
+
ctx.log.error(
|
589
|
+
'Cannot use "--hive-usage-target" with "--hive-target". Please only use "--hive-target"'
|
590
|
+
);
|
591
|
+
process.exit(1);
|
592
|
+
}
|
593
|
+
if (cliOpts.hiveRegistryToken && opts.hiveTarget) {
|
508
594
|
ctx.log.error(
|
509
595
|
'Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
510
596
|
);
|
511
597
|
process.exit(1);
|
512
598
|
}
|
513
|
-
if (opts.
|
599
|
+
if (opts.hiveTarget && !opts.hiveAccessToken && !opts.hiveUsageAccessToken && !opts.hiveTraceAccessToken) {
|
514
600
|
ctx.log.error(
|
515
|
-
'Hive usage target needs an access token. Please provide it through
|
601
|
+
'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.'
|
516
602
|
);
|
517
603
|
process.exit(1);
|
518
604
|
}
|
519
|
-
if (opts.hiveUsageAccessToken && !opts.
|
605
|
+
if ((opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveTraceAccessToken) && !opts.hiveTarget) {
|
520
606
|
ctx.log.error(
|
521
|
-
'Hive
|
607
|
+
'Hive access token needs a target. Please provide it through the "--hive-target <target>" option or the config.'
|
522
608
|
);
|
523
609
|
process.exit(1);
|
524
610
|
}
|
525
|
-
const hiveUsageAccessToken = opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
611
|
+
const hiveUsageAccessToken = opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
526
612
|
if (hiveUsageAccessToken) {
|
527
613
|
if (opts.hiveUsageTarget) {
|
528
614
|
ctx.log.info("Configuring Hive usage reporting");
|
@@ -533,7 +619,7 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
533
619
|
...loadedConfig.reporting,
|
534
620
|
type: "hive",
|
535
621
|
token: hiveUsageAccessToken,
|
536
|
-
target: opts.
|
622
|
+
target: opts.hiveTarget
|
537
623
|
};
|
538
624
|
}
|
539
625
|
if (opts.apolloKey) {
|
@@ -561,17 +647,30 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
561
647
|
"path to the GraphQL schema file or a url from where to pull the schema"
|
562
648
|
).action(async function proxy(endpoint) {
|
563
649
|
const {
|
650
|
+
opentelemetry,
|
651
|
+
opentelemetryExporterType,
|
564
652
|
hiveCdnEndpoint,
|
565
653
|
hiveCdnKey,
|
566
654
|
hiveRegistryToken,
|
655
|
+
hiveTarget,
|
567
656
|
hiveUsageTarget,
|
657
|
+
hiveAccessToken,
|
568
658
|
hiveUsageAccessToken,
|
659
|
+
hiveTraceAccessToken,
|
660
|
+
hiveTraceEndpoint,
|
569
661
|
maskedErrors,
|
570
662
|
hivePersistedDocumentsEndpoint,
|
571
663
|
hivePersistedDocumentsToken,
|
572
664
|
...opts
|
573
665
|
} = this.optsWithGlobals();
|
574
666
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} in proxy mode`);
|
667
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
668
|
+
openTelemetry: opentelemetry,
|
669
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
670
|
+
hiveTarget,
|
671
|
+
hiveTraceAccessToken,
|
672
|
+
hiveTraceEndpoint
|
673
|
+
});
|
575
674
|
const loadedConfig = await loadConfig({
|
576
675
|
log: ctx.log,
|
577
676
|
configPath: opts.configPath,
|
@@ -625,8 +724,11 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
625
724
|
const registryConfig = {};
|
626
725
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
627
726
|
hiveRegistryToken,
|
727
|
+
hiveTarget,
|
628
728
|
hiveUsageTarget,
|
729
|
+
hiveAccessToken,
|
629
730
|
hiveUsageAccessToken,
|
731
|
+
hiveTraceAccessToken,
|
630
732
|
// proxy can only do reporting to hive registry
|
631
733
|
apolloGraphRef: void 0,
|
632
734
|
apolloKey: void 0
|
@@ -647,7 +749,8 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
647
749
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
648
750
|
{
|
649
751
|
...loadedConfig,
|
650
|
-
...opts
|
752
|
+
...opts,
|
753
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
651
754
|
},
|
652
755
|
{
|
653
756
|
log: ctx.log,
|
@@ -722,15 +825,28 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
722
825
|
'path to the subgraph schema file or a url from where to pull the subgraph schema (default: "subgraph.graphql")'
|
723
826
|
).action(async function subgraph(schemaPathOrUrl) {
|
724
827
|
const {
|
828
|
+
opentelemetry,
|
829
|
+
opentelemetryExporterType,
|
725
830
|
maskedErrors,
|
726
831
|
hiveRegistryToken,
|
832
|
+
hiveTarget,
|
727
833
|
hiveUsageTarget,
|
834
|
+
hiveAccessToken,
|
728
835
|
hiveUsageAccessToken,
|
836
|
+
hiveTraceAccessToken,
|
837
|
+
hiveTraceEndpoint,
|
729
838
|
hivePersistedDocumentsEndpoint,
|
730
839
|
hivePersistedDocumentsToken,
|
731
840
|
...opts
|
732
841
|
} = this.optsWithGlobals();
|
733
842
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} as subgraph`);
|
843
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
844
|
+
openTelemetry: opentelemetry,
|
845
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
846
|
+
hiveTarget,
|
847
|
+
hiveTraceAccessToken,
|
848
|
+
hiveTraceEndpoint
|
849
|
+
});
|
734
850
|
const loadedConfig = await loadConfig({
|
735
851
|
log: ctx.log,
|
736
852
|
configPath: opts.configPath,
|
@@ -746,8 +862,11 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
746
862
|
const registryConfig = {};
|
747
863
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
748
864
|
hiveRegistryToken,
|
865
|
+
hiveTarget,
|
749
866
|
hiveUsageTarget,
|
867
|
+
hiveAccessToken,
|
750
868
|
hiveUsageAccessToken,
|
869
|
+
hiveTraceAccessToken,
|
751
870
|
// subgraph can only do reporting to hive registry
|
752
871
|
apolloGraphRef: void 0,
|
753
872
|
apolloKey: void 0
|
@@ -768,7 +887,8 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
768
887
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
769
888
|
{
|
770
889
|
...loadedConfig,
|
771
|
-
...opts
|
890
|
+
...opts,
|
891
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
772
892
|
},
|
773
893
|
{
|
774
894
|
log: ctx.log,
|
@@ -862,11 +982,17 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
862
982
|
).env("APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT")
|
863
983
|
).action(async function supergraph(schemaPathOrUrl) {
|
864
984
|
const {
|
985
|
+
opentelemetry,
|
986
|
+
opentelemetryExporterType,
|
865
987
|
hiveCdnEndpoint,
|
866
988
|
hiveCdnKey,
|
867
989
|
hiveRegistryToken,
|
868
990
|
hiveUsageTarget,
|
991
|
+
hiveTarget,
|
992
|
+
hiveAccessToken,
|
869
993
|
hiveUsageAccessToken,
|
994
|
+
hiveTraceAccessToken,
|
995
|
+
hiveTraceEndpoint,
|
870
996
|
maskedErrors,
|
871
997
|
apolloGraphRef,
|
872
998
|
apolloKey,
|
@@ -878,6 +1004,13 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
878
1004
|
ctx.log.info(
|
879
1005
|
`Starting ${ctx.productName} ${ctx.version} with supergraph`
|
880
1006
|
);
|
1007
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
1008
|
+
openTelemetry: opentelemetry,
|
1009
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
1010
|
+
hiveTarget,
|
1011
|
+
hiveTraceAccessToken,
|
1012
|
+
hiveTraceEndpoint
|
1013
|
+
});
|
881
1014
|
const loadedConfig = await loadConfig({
|
882
1015
|
log: ctx.log,
|
883
1016
|
configPath: opts.configPath,
|
@@ -963,6 +1096,9 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
963
1096
|
}
|
964
1097
|
const registryConfig = {};
|
965
1098
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
1099
|
+
hiveTarget,
|
1100
|
+
hiveAccessToken,
|
1101
|
+
hiveTraceAccessToken,
|
966
1102
|
hiveRegistryToken,
|
967
1103
|
hiveUsageTarget,
|
968
1104
|
hiveUsageAccessToken,
|
@@ -985,7 +1121,8 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
985
1121
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
986
1122
|
{
|
987
1123
|
...loadedConfig,
|
988
|
-
...opts
|
1124
|
+
...opts,
|
1125
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
989
1126
|
},
|
990
1127
|
{
|
991
1128
|
log: ctx.log,
|
@@ -1235,27 +1372,57 @@ let cli = new Command().configureHelp({
|
|
1235
1372
|
// see here https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/command.js#L655
|
1236
1373
|
// @ts-expect-error
|
1237
1374
|
null
|
1375
|
+
).addOption(
|
1376
|
+
new Option(
|
1377
|
+
"--opentelemetry [exporter-endpoint]",
|
1378
|
+
`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.`
|
1379
|
+
).env("OPENTELEMETRY")
|
1380
|
+
).addOption(
|
1381
|
+
new Option(
|
1382
|
+
"--opentelemetry-exporter-type <type>",
|
1383
|
+
`OpenTelemetry exporter type to use when setting up OpenTelemetry integration. Requires "--opentelemetry" to set the endpoint.`
|
1384
|
+
).choices(["otlp-http", "otlp-grpc"]).default("otlp-http").env("OPENTELEMETRY_EXPORTER_TYPE")
|
1238
1385
|
).addOption(
|
1239
1386
|
new Option(
|
1240
1387
|
"--hive-registry-token <token>",
|
1241
|
-
'[DEPRECATED: please use "--hive-
|
1388
|
+
'[DEPRECATED: please use "--hive-target" and "--hive-access-token"] Hive registry token for usage metrics reporting'
|
1242
1389
|
).env("HIVE_REGISTRY_TOKEN")
|
1243
1390
|
).addOption(
|
1244
1391
|
new Option(
|
1245
1392
|
"--hive-usage-target <target>",
|
1246
|
-
|
1393
|
+
"[DEPRECATED] please use --hive-target instead."
|
1247
1394
|
).env("HIVE_USAGE_TARGET")
|
1395
|
+
).addOption(
|
1396
|
+
new Option(
|
1397
|
+
"--hive-target <target>",
|
1398
|
+
'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'
|
1399
|
+
).env("HIVE_TARGET")
|
1400
|
+
).addOption(
|
1401
|
+
new Option(
|
1402
|
+
"--hive-access-token <token>",
|
1403
|
+
'Hive registry access token for usage metrics reporting and tracing. Enables both usage reporting and tracing. Requires the "--hive-target <target>" option'
|
1404
|
+
).env("HIVE_ACCESS_TOKEN")
|
1248
1405
|
).addOption(
|
1249
1406
|
new Option(
|
1250
1407
|
"--hive-usage-access-token <token>",
|
1251
|
-
|
1408
|
+
`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"`
|
1252
1409
|
).env("HIVE_USAGE_ACCESS_TOKEN")
|
1410
|
+
).addOption(
|
1411
|
+
new Option(
|
1412
|
+
"--hive-trace-access-token <token>",
|
1413
|
+
`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"`
|
1414
|
+
).env("HIVE_TRACE_ACCESS_TOKEN")
|
1415
|
+
).addOption(
|
1416
|
+
new Option(
|
1417
|
+
"--hive-trace-endpoint <endpoint>",
|
1418
|
+
`Hive registry tracing endpoint.`
|
1419
|
+
).env("HIVE_TRACE_ENDPOINT").default(`https://api.graphql-hive.com/otel/v1/traces`)
|
1253
1420
|
).option(
|
1254
1421
|
"--hive-persisted-documents-endpoint <endpoint>",
|
1255
|
-
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents.
|
1422
|
+
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. Requires the "--hive-persisted-documents-token <token>" option'
|
1256
1423
|
).option(
|
1257
1424
|
"--hive-persisted-documents-token <token>",
|
1258
|
-
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token.
|
1425
|
+
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token. Requires the "--hive-persisted-documents-endpoint <endpoint>" option'
|
1259
1426
|
).addOption(
|
1260
1427
|
new Option(
|
1261
1428
|
"--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');
|
@@ -492,11 +493,83 @@ function handleFork(log, config) {
|
|
492
493
|
return false;
|
493
494
|
}
|
494
495
|
|
496
|
+
async function handleOpenTelemetryConfig(ctx, cliOpts) {
|
497
|
+
const accessToken = cliOpts.hiveTraceAccessToken;
|
498
|
+
const traceEndpoint = cliOpts.hiveTraceEndpoint;
|
499
|
+
const target = cliOpts.hiveTarget;
|
500
|
+
const openTelemetry = cliOpts.openTelemetry;
|
501
|
+
const exporterType = cliOpts.openTelemetryExporterType ?? "otlp-http";
|
502
|
+
const log = ctx.log.child("[OpenTelemetry] ");
|
503
|
+
if (openTelemetry || accessToken) {
|
504
|
+
log.debug(
|
505
|
+
{ openTelemetry, exporterType, target, traceEndpoint },
|
506
|
+
"Initializing OpenTelemetry SDK"
|
507
|
+
);
|
508
|
+
return utils$1.fakePromise().then(async () => {
|
509
|
+
const { openTelemetrySetup, HiveTracingSpanProcessor, getEnvVar } = await import('@graphql-mesh/plugin-opentelemetry/setup');
|
510
|
+
const processors = [];
|
511
|
+
const logAttributes = {
|
512
|
+
traceEndpoints: [],
|
513
|
+
contextManager: false
|
514
|
+
};
|
515
|
+
let integrationName;
|
516
|
+
if (openTelemetry) {
|
517
|
+
const otelEndpoint = typeof openTelemetry === "string" ? openTelemetry : getEnvVar("OTEL_EXPORTER_OTLP_ENDPOINT", void 0);
|
518
|
+
log.debug({ exporterType, otelEndpoint }, "Setting up OTLP Exporter");
|
519
|
+
integrationName = "OpenTelemetry";
|
520
|
+
logAttributes.traceEndpoints.push({
|
521
|
+
url: otelEndpoint ?? null,
|
522
|
+
type: exporterType
|
523
|
+
});
|
524
|
+
log.debug({ type: exporterType }, "Loading OpenTelemetry exporter");
|
525
|
+
const { OTLPTraceExporter } = await import(`@opentelemetry/exporter-trace-${exporterType}`);
|
526
|
+
processors.push(
|
527
|
+
new sdkTraceBase.BatchSpanProcessor(new OTLPTraceExporter({ url: otelEndpoint }))
|
528
|
+
);
|
529
|
+
}
|
530
|
+
if (accessToken) {
|
531
|
+
log.debug({ target, traceEndpoint }, "Setting up Hive Tracing");
|
532
|
+
integrationName ??= "Hive Tracing";
|
533
|
+
if (!target) {
|
534
|
+
ctx.log.error(
|
535
|
+
'Hive tracing needs a target. Please provide it through "--hive-target <target>"'
|
536
|
+
);
|
537
|
+
process.exit(1);
|
538
|
+
}
|
539
|
+
logAttributes.traceEndpoints.push({
|
540
|
+
url: traceEndpoint,
|
541
|
+
type: "hive tracing",
|
542
|
+
target
|
543
|
+
});
|
544
|
+
processors.push(
|
545
|
+
new HiveTracingSpanProcessor({
|
546
|
+
accessToken,
|
547
|
+
target,
|
548
|
+
endpoint: traceEndpoint
|
549
|
+
})
|
550
|
+
);
|
551
|
+
}
|
552
|
+
log.debug("Trying to load AsyncLocalStorage based Context Manager");
|
553
|
+
const contextManager = await import('@opentelemetry/context-async-hooks').then((module) => {
|
554
|
+
logAttributes.contextManager = true;
|
555
|
+
return new module.AsyncLocalStorageContextManager();
|
556
|
+
}).catch(() => null);
|
557
|
+
openTelemetrySetup({
|
558
|
+
traces: { processors },
|
559
|
+
contextManager
|
560
|
+
});
|
561
|
+
log.info(logAttributes, `${integrationName} integration is enabled`);
|
562
|
+
return true;
|
563
|
+
});
|
564
|
+
}
|
565
|
+
return false;
|
566
|
+
}
|
567
|
+
|
495
568
|
function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
496
569
|
const confOpts = {
|
497
570
|
...loadedConfig.reporting?.type === "hive" ? {
|
498
571
|
hiveRegistryToken: loadedConfig.reporting.token,
|
499
|
-
|
572
|
+
hiveTarget: loadedConfig.reporting.target,
|
500
573
|
hiveUsageAccessToken: loadedConfig.reporting.token
|
501
574
|
} : {},
|
502
575
|
...loadedConfig.reporting?.type === "graphos" ? {
|
@@ -504,32 +577,45 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
504
577
|
apolloKey: loadedConfig.reporting.apiKey
|
505
578
|
} : {}
|
506
579
|
};
|
507
|
-
const opts = {
|
580
|
+
const opts = {
|
581
|
+
...confOpts,
|
582
|
+
...cliOpts,
|
583
|
+
hiveTarget: (
|
584
|
+
// cli arguments always take precedence over config
|
585
|
+
confOpts.hiveTarget ?? cliOpts.hiveTarget ?? cliOpts.hiveUsageTarget
|
586
|
+
)
|
587
|
+
};
|
508
588
|
if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) {
|
509
589
|
ctx.log.error(
|
510
590
|
'Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
511
591
|
);
|
512
592
|
process.exit(1);
|
513
593
|
}
|
514
|
-
if (cliOpts.
|
594
|
+
if (cliOpts.hiveUsageTarget && cliOpts.hiveTarget) {
|
595
|
+
ctx.log.error(
|
596
|
+
'Cannot use "--hive-usage-target" with "--hive-target". Please only use "--hive-target"'
|
597
|
+
);
|
598
|
+
process.exit(1);
|
599
|
+
}
|
600
|
+
if (cliOpts.hiveRegistryToken && opts.hiveTarget) {
|
515
601
|
ctx.log.error(
|
516
602
|
'Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
517
603
|
);
|
518
604
|
process.exit(1);
|
519
605
|
}
|
520
|
-
if (opts.
|
606
|
+
if (opts.hiveTarget && !opts.hiveAccessToken && !opts.hiveUsageAccessToken && !opts.hiveTraceAccessToken) {
|
521
607
|
ctx.log.error(
|
522
|
-
'Hive usage target needs an access token. Please provide it through
|
608
|
+
'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.'
|
523
609
|
);
|
524
610
|
process.exit(1);
|
525
611
|
}
|
526
|
-
if (opts.hiveUsageAccessToken && !opts.
|
612
|
+
if ((opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveTraceAccessToken) && !opts.hiveTarget) {
|
527
613
|
ctx.log.error(
|
528
|
-
'Hive
|
614
|
+
'Hive access token needs a target. Please provide it through the "--hive-target <target>" option or the config.'
|
529
615
|
);
|
530
616
|
process.exit(1);
|
531
617
|
}
|
532
|
-
const hiveUsageAccessToken = opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
618
|
+
const hiveUsageAccessToken = opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
533
619
|
if (hiveUsageAccessToken) {
|
534
620
|
if (opts.hiveUsageTarget) {
|
535
621
|
ctx.log.info("Configuring Hive usage reporting");
|
@@ -540,7 +626,7 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
540
626
|
...loadedConfig.reporting,
|
541
627
|
type: "hive",
|
542
628
|
token: hiveUsageAccessToken,
|
543
|
-
target: opts.
|
629
|
+
target: opts.hiveTarget
|
544
630
|
};
|
545
631
|
}
|
546
632
|
if (opts.apolloKey) {
|
@@ -568,17 +654,30 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
568
654
|
"path to the GraphQL schema file or a url from where to pull the schema"
|
569
655
|
).action(async function proxy(endpoint) {
|
570
656
|
const {
|
657
|
+
opentelemetry,
|
658
|
+
opentelemetryExporterType,
|
571
659
|
hiveCdnEndpoint,
|
572
660
|
hiveCdnKey,
|
573
661
|
hiveRegistryToken,
|
662
|
+
hiveTarget,
|
574
663
|
hiveUsageTarget,
|
664
|
+
hiveAccessToken,
|
575
665
|
hiveUsageAccessToken,
|
666
|
+
hiveTraceAccessToken,
|
667
|
+
hiveTraceEndpoint,
|
576
668
|
maskedErrors,
|
577
669
|
hivePersistedDocumentsEndpoint,
|
578
670
|
hivePersistedDocumentsToken,
|
579
671
|
...opts
|
580
672
|
} = this.optsWithGlobals();
|
581
673
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} in proxy mode`);
|
674
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
675
|
+
openTelemetry: opentelemetry,
|
676
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
677
|
+
hiveTarget,
|
678
|
+
hiveTraceAccessToken,
|
679
|
+
hiveTraceEndpoint
|
680
|
+
});
|
582
681
|
const loadedConfig = await loadConfig({
|
583
682
|
log: ctx.log,
|
584
683
|
configPath: opts.configPath,
|
@@ -632,8 +731,11 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
632
731
|
const registryConfig = {};
|
633
732
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
634
733
|
hiveRegistryToken,
|
734
|
+
hiveTarget,
|
635
735
|
hiveUsageTarget,
|
736
|
+
hiveAccessToken,
|
636
737
|
hiveUsageAccessToken,
|
738
|
+
hiveTraceAccessToken,
|
637
739
|
// proxy can only do reporting to hive registry
|
638
740
|
apolloGraphRef: void 0,
|
639
741
|
apolloKey: void 0
|
@@ -654,7 +756,8 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
654
756
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
655
757
|
{
|
656
758
|
...loadedConfig,
|
657
|
-
...opts
|
759
|
+
...opts,
|
760
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
658
761
|
},
|
659
762
|
{
|
660
763
|
log: ctx.log,
|
@@ -729,15 +832,28 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
729
832
|
'path to the subgraph schema file or a url from where to pull the subgraph schema (default: "subgraph.graphql")'
|
730
833
|
).action(async function subgraph(schemaPathOrUrl) {
|
731
834
|
const {
|
835
|
+
opentelemetry,
|
836
|
+
opentelemetryExporterType,
|
732
837
|
maskedErrors,
|
733
838
|
hiveRegistryToken,
|
839
|
+
hiveTarget,
|
734
840
|
hiveUsageTarget,
|
841
|
+
hiveAccessToken,
|
735
842
|
hiveUsageAccessToken,
|
843
|
+
hiveTraceAccessToken,
|
844
|
+
hiveTraceEndpoint,
|
736
845
|
hivePersistedDocumentsEndpoint,
|
737
846
|
hivePersistedDocumentsToken,
|
738
847
|
...opts
|
739
848
|
} = this.optsWithGlobals();
|
740
849
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} as subgraph`);
|
850
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
851
|
+
openTelemetry: opentelemetry,
|
852
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
853
|
+
hiveTarget,
|
854
|
+
hiveTraceAccessToken,
|
855
|
+
hiveTraceEndpoint
|
856
|
+
});
|
741
857
|
const loadedConfig = await loadConfig({
|
742
858
|
log: ctx.log,
|
743
859
|
configPath: opts.configPath,
|
@@ -753,8 +869,11 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
753
869
|
const registryConfig = {};
|
754
870
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
755
871
|
hiveRegistryToken,
|
872
|
+
hiveTarget,
|
756
873
|
hiveUsageTarget,
|
874
|
+
hiveAccessToken,
|
757
875
|
hiveUsageAccessToken,
|
876
|
+
hiveTraceAccessToken,
|
758
877
|
// subgraph can only do reporting to hive registry
|
759
878
|
apolloGraphRef: void 0,
|
760
879
|
apolloKey: void 0
|
@@ -775,7 +894,8 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
775
894
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
776
895
|
{
|
777
896
|
...loadedConfig,
|
778
|
-
...opts
|
897
|
+
...opts,
|
898
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
779
899
|
},
|
780
900
|
{
|
781
901
|
log: ctx.log,
|
@@ -869,11 +989,17 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
869
989
|
).env("APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT")
|
870
990
|
).action(async function supergraph(schemaPathOrUrl) {
|
871
991
|
const {
|
992
|
+
opentelemetry,
|
993
|
+
opentelemetryExporterType,
|
872
994
|
hiveCdnEndpoint,
|
873
995
|
hiveCdnKey,
|
874
996
|
hiveRegistryToken,
|
875
997
|
hiveUsageTarget,
|
998
|
+
hiveTarget,
|
999
|
+
hiveAccessToken,
|
876
1000
|
hiveUsageAccessToken,
|
1001
|
+
hiveTraceAccessToken,
|
1002
|
+
hiveTraceEndpoint,
|
877
1003
|
maskedErrors,
|
878
1004
|
apolloGraphRef,
|
879
1005
|
apolloKey,
|
@@ -885,6 +1011,13 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
885
1011
|
ctx.log.info(
|
886
1012
|
`Starting ${ctx.productName} ${ctx.version} with supergraph`
|
887
1013
|
);
|
1014
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
1015
|
+
openTelemetry: opentelemetry,
|
1016
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
1017
|
+
hiveTarget,
|
1018
|
+
hiveTraceAccessToken,
|
1019
|
+
hiveTraceEndpoint
|
1020
|
+
});
|
888
1021
|
const loadedConfig = await loadConfig({
|
889
1022
|
log: ctx.log,
|
890
1023
|
configPath: opts.configPath,
|
@@ -970,6 +1103,9 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
970
1103
|
}
|
971
1104
|
const registryConfig = {};
|
972
1105
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
1106
|
+
hiveTarget,
|
1107
|
+
hiveAccessToken,
|
1108
|
+
hiveTraceAccessToken,
|
973
1109
|
hiveRegistryToken,
|
974
1110
|
hiveUsageTarget,
|
975
1111
|
hiveUsageAccessToken,
|
@@ -992,7 +1128,8 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
992
1128
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
993
1129
|
{
|
994
1130
|
...loadedConfig,
|
995
|
-
...opts
|
1131
|
+
...opts,
|
1132
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
996
1133
|
},
|
997
1134
|
{
|
998
1135
|
log: ctx.log,
|
@@ -1242,27 +1379,57 @@ let cli = new extraTypings.Command().configureHelp({
|
|
1242
1379
|
// see here https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/command.js#L655
|
1243
1380
|
// @ts-expect-error
|
1244
1381
|
null
|
1382
|
+
).addOption(
|
1383
|
+
new extraTypings.Option(
|
1384
|
+
"--opentelemetry [exporter-endpoint]",
|
1385
|
+
`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.`
|
1386
|
+
).env("OPENTELEMETRY")
|
1387
|
+
).addOption(
|
1388
|
+
new extraTypings.Option(
|
1389
|
+
"--opentelemetry-exporter-type <type>",
|
1390
|
+
`OpenTelemetry exporter type to use when setting up OpenTelemetry integration. Requires "--opentelemetry" to set the endpoint.`
|
1391
|
+
).choices(["otlp-http", "otlp-grpc"]).default("otlp-http").env("OPENTELEMETRY_EXPORTER_TYPE")
|
1245
1392
|
).addOption(
|
1246
1393
|
new extraTypings.Option(
|
1247
1394
|
"--hive-registry-token <token>",
|
1248
|
-
'[DEPRECATED: please use "--hive-
|
1395
|
+
'[DEPRECATED: please use "--hive-target" and "--hive-access-token"] Hive registry token for usage metrics reporting'
|
1249
1396
|
).env("HIVE_REGISTRY_TOKEN")
|
1250
1397
|
).addOption(
|
1251
1398
|
new extraTypings.Option(
|
1252
1399
|
"--hive-usage-target <target>",
|
1253
|
-
|
1400
|
+
"[DEPRECATED] please use --hive-target instead."
|
1254
1401
|
).env("HIVE_USAGE_TARGET")
|
1402
|
+
).addOption(
|
1403
|
+
new extraTypings.Option(
|
1404
|
+
"--hive-target <target>",
|
1405
|
+
'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'
|
1406
|
+
).env("HIVE_TARGET")
|
1407
|
+
).addOption(
|
1408
|
+
new extraTypings.Option(
|
1409
|
+
"--hive-access-token <token>",
|
1410
|
+
'Hive registry access token for usage metrics reporting and tracing. Enables both usage reporting and tracing. Requires the "--hive-target <target>" option'
|
1411
|
+
).env("HIVE_ACCESS_TOKEN")
|
1255
1412
|
).addOption(
|
1256
1413
|
new extraTypings.Option(
|
1257
1414
|
"--hive-usage-access-token <token>",
|
1258
|
-
|
1415
|
+
`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"`
|
1259
1416
|
).env("HIVE_USAGE_ACCESS_TOKEN")
|
1417
|
+
).addOption(
|
1418
|
+
new extraTypings.Option(
|
1419
|
+
"--hive-trace-access-token <token>",
|
1420
|
+
`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"`
|
1421
|
+
).env("HIVE_TRACE_ACCESS_TOKEN")
|
1422
|
+
).addOption(
|
1423
|
+
new extraTypings.Option(
|
1424
|
+
"--hive-trace-endpoint <endpoint>",
|
1425
|
+
`Hive registry tracing endpoint.`
|
1426
|
+
).env("HIVE_TRACE_ENDPOINT").default(`https://api.graphql-hive.com/otel/v1/traces`)
|
1260
1427
|
).option(
|
1261
1428
|
"--hive-persisted-documents-endpoint <endpoint>",
|
1262
|
-
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents.
|
1429
|
+
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. Requires the "--hive-persisted-documents-token <token>" option'
|
1263
1430
|
).option(
|
1264
1431
|
"--hive-persisted-documents-token <token>",
|
1265
|
-
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token.
|
1432
|
+
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token. Requires the "--hive-persisted-documents-endpoint <endpoint>" option'
|
1266
1433
|
).addOption(
|
1267
1434
|
new extraTypings.Option(
|
1268
1435
|
"--hive-cdn-endpoint <endpoint>",
|
package/dist/index.cjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var cli = require('./cli-
|
3
|
+
var cli = require('./cli-CQdLYWjW.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-
|
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-C8SAeNPg.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-alpha-
|
3
|
+
"version": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
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-alpha-
|
57
|
-
"@graphql-hive/importer": "2.0.0-alpha-
|
58
|
-
"@graphql-hive/logger": "1.0.1-alpha-
|
59
|
-
"@graphql-hive/plugin-aws-sigv4": "2.0.0-alpha-
|
60
|
-
"@graphql-hive/plugin-deduplicate-request": "2.0.0-alpha-
|
61
|
-
"@graphql-hive/pubsub": "2.0.0-alpha-
|
56
|
+
"@graphql-hive/gateway-runtime": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
57
|
+
"@graphql-hive/importer": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
58
|
+
"@graphql-hive/logger": "1.0.1-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
59
|
+
"@graphql-hive/plugin-aws-sigv4": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
60
|
+
"@graphql-hive/plugin-deduplicate-request": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
61
|
+
"@graphql-hive/pubsub": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
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-alpha-
|
67
|
+
"@graphql-mesh/hmac-upstream-signature": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
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-alpha-
|
71
|
-
"@graphql-mesh/plugin-opentelemetry": "2.0.0-alpha-
|
72
|
-
"@graphql-mesh/plugin-prometheus": "2.0.0-alpha-
|
70
|
+
"@graphql-mesh/plugin-jwt-auth": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
71
|
+
"@graphql-mesh/plugin-opentelemetry": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
72
|
+
"@graphql-mesh/plugin-prometheus": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
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-alpha-
|
76
|
-
"@graphql-mesh/transport-http-callback": "1.0.0-alpha-
|
77
|
-
"@graphql-mesh/transport-ws": "2.0.0-alpha-
|
75
|
+
"@graphql-mesh/transport-http": "1.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
76
|
+
"@graphql-mesh/transport-http-callback": "1.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
77
|
+
"@graphql-mesh/transport-ws": "2.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
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.4",
|
@@ -101,7 +103,7 @@
|
|
101
103
|
"ws": "^8.18.3"
|
102
104
|
},
|
103
105
|
"devDependencies": {
|
104
|
-
"@graphql-mesh/transport-common": "1.0.0-alpha-
|
106
|
+
"@graphql-mesh/transport-common": "1.0.0-alpha-abdd4d2782839ab5e3686c296ec2e12d372abc8f",
|
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",
|