Commit 264b4f7
fix(node): Register tracer provider when OTel API global pre-exists with a different version (#22374)
## What
When the OTel API global registry
(`Symbol.for('opentelemetry.js.api.1')`) pre-exists with a different
`@opentelemetry/api` version, the SDK now replaces it and registers its
tracer provider instead of silently disabling tracing.
- Retry registration after replacing the registry, only when its `trace`
slot is empty
- Debug warning when the registry is replaced, pointing to
`skipOpenTelemetrySetup`
- Applies to both the default `SentryTracerProvider` and the
`BasicTracerProvider` path
## Why
Host runtimes like Neon Functions pre-create the registry with their own
api version. OTel's `registerGlobal` requires an exact version match, so
every registration is rejected and all spans (including
`Sentry.startSpan()`) are non-recording, with no signal outside debug
builds. Node flavor of the Deno issue fixed in #19723.
The empty-`trace`-slot condition keeps existing behavior when a real
provider is already registered (second `Sentry.init()`, user-managed
OTel): those still back off as before, so no working setup gets
clobbered.
Closes: #22338
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 237956e commit 264b4f7
2 files changed
Lines changed: 127 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
29 | 85 | | |
30 | 86 | | |
31 | 87 | | |
| |||
118 | 174 | | |
119 | 175 | | |
120 | 176 | | |
121 | | - | |
| 177 | + | |
122 | 178 | | |
123 | 179 | | |
124 | 180 | | |
| |||
132 | 188 | | |
133 | 189 | | |
134 | 190 | | |
135 | | - | |
| 191 | + | |
136 | 192 | | |
137 | 193 | | |
138 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
234 | 303 | | |
235 | 304 | | |
236 | 305 | | |
| |||
0 commit comments