|
1 | 1 | // @ts-expect-error not a dependency
|
2 |
| -import { createOtlpHttpExporter, defineConfig } from '@graphql-hive/gateway'; |
| 2 | +import { defineConfig } from '@graphql-hive/gateway'; |
| 3 | +// @ts-expect-error not a dependency |
| 4 | +import { openTelemetrySetup } from '@graphql-hive/gateway/opentelemetry/setup'; |
| 5 | +import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'; |
| 6 | +import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; |
| 7 | + |
| 8 | +openTelemetrySetup({ |
| 9 | + // Mandatory: It depends on the available API in your runtime. |
| 10 | + // We recommend AsyncLocalStorage based manager when possible. |
| 11 | + // `@opentelemetry/context-zone` is also available for other runtimes. |
| 12 | + // Pass `false` to disable context manager usage. |
| 13 | + contextManager: new AsyncLocalStorageContextManager(), |
| 14 | + |
| 15 | + traces: { |
| 16 | + // Define your exporter, most of the time the OTLP HTTP one. Traces are batched by default. |
| 17 | + exporter: new OTLPTraceExporter({ url: process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT']! }), |
| 18 | + // You can easily enable a console exporter for quick debug |
| 19 | + console: process.env['DEBUG_TRACES'] === '1', |
| 20 | + }, |
| 21 | +}); |
3 | 22 |
|
4 | 23 | const defaultQuery = `#
|
5 | 24 | # Welcome to the Hive Console GraphQL API.
|
@@ -34,11 +53,6 @@ export const gatewayConfig = defineConfig({
|
34 | 53 | openTelemetry: process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT']
|
35 | 54 | ? {
|
36 | 55 | serviceName: 'public-graphql-api-gateway',
|
37 |
| - exporters: [ |
38 |
| - createOtlpHttpExporter({ |
39 |
| - url: process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT'], |
40 |
| - }), |
41 |
| - ], |
42 | 56 | }
|
43 | 57 | : false,
|
44 | 58 | demandControl: {
|
|
0 commit comments