Skip to content

Commit c9519b9

Browse files
authored
docs(opentelemetry): fix import of openTelemetrySetup (#7195)
1 parent cc6cd28 commit c9519b9

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

packages/web/docs/src/content/gateway/monitoring-tracing.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ We recommend to place your OpenTelemetry setup in a `telemetry.ts` file that wil
136136
import in your `gateway.config.ts` file. This allow instrumentations to be registered (if any)
137137
before any other packages are imported.
138138

139-
For ease of configuration, we provide a `openTelemetrySetup` function from
140-
`@graphql-hive/plugin-opentelemetry/setup` module, with sensible default and straightforward API
141-
compatible with all runtimes.
139+
For ease of configuration, we provide a `openTelemetrySetup` function, with sensible default and
140+
straightforward API compatible with all runtimes.
142141

143142
But this utility is not mandatory, you can use any setup relevant to your specific use case and
144143
infrastructure.
@@ -168,8 +167,18 @@ supports `AsyncLocalStorage` API), and a trace exporter depending on your traces
168167
npm i @opentelemetry/context-async-hooks @opentelemetry/exporter-trace-otlp-http
169168
```
170169

170+
Depending on your usage, you will have to import `openTelemetrySetup` from a different module:
171+
172+
- CLI usage: `@graphql-hive/gateway/opentelemetry/setup`
173+
- Programmatic usage : `@graphql-hive/plugin-opentelemetry/setup`
174+
171175
```ts filename="telemetry.ts"
176+
// For CLI usage
172177
import { openTelemetrySetup } from '@graphql-hive/gateway/opentelemetry/setup'
178+
179+
// For Programmatic usage
180+
import { openTelemetrySetup } from '@graphql-hive/plugin-opentelemetry/setup'
181+
173182
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'
174183
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
175184

@@ -2100,9 +2109,9 @@ to get the proper context.
21002109

21012110
```ts filename="gateway.config.ts"
21022111
import { defineConfig } from '@graphql-hive/gateway'
2103-
import { openTelemetrySetup } from '@graphql-hive/plugin-opentelemetry/setup'
2112+
import { openTelemetrySetup } from '@graphql-hive/gateway/opentelemetry/setup'
21042113
// This package re-export official @opentelemetry/api package for ease of use
2105-
import { trace, hive } from '@graphql-hive/plugin-opentelemetry/api'
2114+
import { trace, hive } from '@graphql-hive/gateway/opentelemetry/api'
21062115

21072116
openTelemetrySetup({
21082117
contextManager: null, // Don't register any context manager
@@ -2184,11 +2193,15 @@ environment variable on your gateway process/runtime.
21842193

21852194
In addition, you can use the stdout exporter to log the traces to the console:
21862195

2187-
<Tabs items={["CLI", 'Programmatic Usage']}>
2196+
<Tabs items={[<div>Hive Gateway <code>openTelemetrySetup()</code> (recommended)</div>, <div>OpenTelemetry <code>NodeSDK</code></div>]}>
21882197

21892198
<Tabs.Tab>
21902199

21912200
```ts filename="telemetry.ts"
2201+
// For CLI usage
2202+
import { openTelemetrySetup } from '@graphql-hive/plugin-opentelemetry/setup'
2203+
2204+
// For Programmatic usage
21922205
import { openTelemetrySetup } from '@graphql-hive/plugin-opentelemetry/setup'
21932206
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'
21942207

0 commit comments

Comments
 (0)