You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(bun): Add ESM/CJS and Bun-specific OTel docs (#14594)
## DESCRIBE YOUR PR
This adds OTel documentation for bun. First, I added CJS/ESM snippets
for all snippets to make it more inclusive.
For Bun, the biggest difference are the imports (`@sentry/bun`) and this
snippet:
```js
integrations: (integrations) =>
integrations
// Filter out the BunServer integration to avoid emitting spans from there
.filter((i) => i.name !== "Http" && i.name !== "BunServer")
// Add the httpIntegration again and disable emitting spans
.concat(Sentry.httpIntegration({ spans: false }))
```
closesgetsentry/sentry-javascript#16969
## IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE -->
- [ ] Other deadline: <!-- ENTER DATE HERE -->
- [ ] None: Not urgent, can wait up to 1 week+
## SLA
- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!
## PRE-MERGE CHECKLIST
*Make sure you've checked the following before merging your changes:*
- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
@@ -145,13 +104,27 @@ _Available since SDK version 8.35.0_
145
104
146
105
You can add your own `@opentelemetry/instrumentation-http` instance in your OpenTelemetry setup. However, in this case, you need to disable span creation in Sentry's `httpIntegration`:
// Also filter out the BunServer integration to avoid emitting duplicated spans from Sentry AND your custom OTel instrumentation
124
+
integrations.filter((i) =>i.name!=="BunServer")
153
125
});
154
126
```
127
+
</PlatformSection>
155
128
156
129
It's important that `httpIntegration` is still registered this way to ensure that the Sentry SDK can correctly isolate requests, for example when capturing errors.
157
130
@@ -163,69 +136,7 @@ If tracing is disabled, the Node Fetch instrumentation will not emit any spans.
163
136
164
137
While you can use your own sampler, we recommend that you use the `SentrySampler`. This will ensure that the correct subset of traces will be sent to Sentry, based on your `tracesSampleRate`. It will also ensure that all other Sentry features like trace propagation work as expected. If you do need to use your own sampler, make sure to wrap your `SamplingResult` with our `wrapSamplingDecision` method like in the example below:
// omit this if you do not want any performance integrations to be added
201
-
tracesSampleRate:0,
202
-
});
203
-
204
-
constprovider=newNodeTracerProvider({
205
-
sampler:newCustomSampler(),
206
-
});
207
-
208
-
// ...rest of your setup
209
-
210
-
// Validate that the setup is correct
211
-
Sentry.validateOpenTelemetrySetup();
212
-
```
213
-
214
-
## ESM Loaders
215
-
216
-
If your application is running in ESM (`import`/`export` syntax), OpenTelemetry requires you to set up _ESM loader hooks_.
217
-
218
-
The Sentry SDK will automatically register ESM loader hooks by default.
219
-
However, if you have your own OpenTelemetry setup, it is recommended to configure the Sentry SDK to not register these hooks and instead register them yourself.
220
-
You can do so by setting `registerEsmLoaderHooks` to `false` and [setting up ESM loader hooks](https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md#instrumentation-hook-required-for-esm):
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/opentelemetry/using-opentelemetry-apis.mdx
+48-4Lines changed: 48 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ supported:
6
6
- javascript.node
7
7
- javascript.aws-lambda
8
8
- javascript.azure-functions
9
+
- javascript.bun
9
10
- javascript.connect
10
11
- javascript.express
11
12
- javascript.fastify
@@ -32,7 +33,23 @@ Sentry supports OpenTelemetry APIs out of the box. Any spans started using OpenT
32
33
33
34
While the Sentry SDK includes some OpenTelemetry instrumentation out of the box, you may want to add additional instrumentation to your application. This can be done by registering the instrumentation through OpenTelemetry like the example below:
0 commit comments