-
Notifications
You must be signed in to change notification settings - Fork 121
chore: use hive console in addition to additional trace collector #7104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
0a7e3a3
fc0351e
fc2546e
4e3f9c2
9e6715a
c04bf43
696f5c0
cb40d28
13de6bd
237aab5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,41 @@ | ||
// @ts-expect-error not a dependency | ||
import { defineConfig } from '@graphql-hive/gateway'; | ||
// @ts-expect-error not a dependency | ||
import { openTelemetrySetup } from '@graphql-hive/gateway/opentelemetry/setup'; | ||
import { hiveTracingSetup } from '@graphql-hive/plugin-opentelemetry/setup'; | ||
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'; | ||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; | ||
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'; | ||
import { MultiSpanProcessor } from '@opentelemetry/sdk-trace-base/build/src/MultiSpanProcessor'; | ||
|
||
openTelemetrySetup({ | ||
// Mandatory: It depends on the available API in your runtime. | ||
// We recommend AsyncLocalStorage based manager when possible. | ||
// `@opentelemetry/context-zone` is also available for other runtimes. | ||
// Pass `false` to disable context manager usage. | ||
contextManager: new AsyncLocalStorageContextManager(), | ||
|
||
traces: { | ||
// Define your exporter, most of the time the OTLP HTTP one. Traces are batched by default. | ||
exporter: new OTLPTraceExporter({ url: process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT']! }), | ||
// You can easily enable a console exporter for quick debug | ||
console: process.env['DEBUG_TRACES'] === '1', | ||
}, | ||
}); | ||
if (process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT'] || process.env['HIVE_TRACING_ACCESS_TOKEN']) { | ||
hiveTracingSetup({ | ||
contextManager: new AsyncLocalStorageContextManager(), | ||
processor: new MultiSpanProcessor([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this impact performance at all, such that we shouldn't add it if only one of the exporters is used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably minimal, but yes it always adds a minimal impact. When nothing is configured, OTEL uses a no-op |
||
...(process.env['HIVE_TRACING_ACCESS_TOKEN'] | ||
? [ | ||
new BatchSpanProcessor( | ||
new OTLPTraceExporter({ | ||
url: process.env['HIVE_TRACING_ENDPOINT'], | ||
headers: { | ||
Authorization: `Bearer ${process.env['HIVE_TRACING_ACCESS_TOKEN']}`, | ||
'X-Hive-Target-Ref': process.env.HIVE_TRACING_TARGET!, | ||
}, | ||
}), | ||
), | ||
] | ||
: []), | ||
...(process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT'] | ||
? [ | ||
new BatchSpanProcessor( | ||
new OTLPTraceExporter({ | ||
url: process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT']!, | ||
}), | ||
), | ||
] | ||
: []), | ||
]), | ||
}); | ||
} | ||
|
||
const defaultQuery = `# | ||
# Welcome to the Hive Console GraphQL API. | ||
|
@@ -50,11 +67,13 @@ export const gatewayConfig = defineConfig({ | |
}, | ||
disableWebsockets: true, | ||
prometheus: true, | ||
openTelemetry: process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT'] | ||
? { | ||
serviceName: 'public-graphql-api-gateway', | ||
} | ||
: false, | ||
openTelemetry: | ||
process.env['OPENTELEMETRY_COLLECTOR_ENDPOINT'] || process.env['HIVE_TRACING_ACCESS_TOKEN'] | ||
? { | ||
traces: true, | ||
serviceName: 'public-graphql-api-gateway', | ||
} | ||
: undefined, | ||
demandControl: { | ||
maxCost: 1000, | ||
includeExtensionMetadata: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently not exported (see open-telemetry/opentelemetry-js#6007)