Skip to content

docs(bun): Add ESM/CJS and Bun-specific OTel docs #14594

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

Merged
merged 6 commits into from
Aug 13, 2025
Merged

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Aug 8, 2025

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:

  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 }))

closes getsentry/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.):
  • Other deadline:
  • 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

Copy link

vercel bot commented Aug 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
sentry-docs Ready Preview Comment Aug 12, 2025 1:43pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
develop-docs ⬜️ Ignored Preview Aug 12, 2025 1:43pm

@s1gr1d s1gr1d changed the title Sig/add bun otel docs docs(bun): Add ESM/CJS and Bun-specific OTel docs Aug 8, 2025
@s1gr1d s1gr1d requested review from mydea and Lms24 August 8, 2025 13:27
cursor[bot]

This comment was marked as outdated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The javascript.mdx files are just copied from the general docs page.

I only added some missing imports (BatchSpanProcessor and OTLPTraceExporter) and added the ESM version of it.

Copy link

codecov bot commented Aug 8, 2025

Bundle Report

Changes will increase total bundle size by 4.19kB (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-client-array-push 9.85MB -6 bytes (-0.0%) ⬇️
sentry-docs-server-cjs 12.38MB 4.19kB (0.03%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 882.71kB -0.0%
static/chunks/8321-*.js -3 bytes 425.87kB -0.0%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
server/middleware-*.js -5.55kB 1.0kB -84.74%
static/oD0H_cmvm3qkbE9K4DzWN/_buildManifest.js (New) 684 bytes 684 bytes 100.0% 🚀
static/oD0H_cmvm3qkbE9K4DzWN/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/J11oGDy1aB2DDuIWnLIzP/_buildManifest.js (Deleted) -684 bytes 0 bytes -100.0% 🗑️
static/J11oGDy1aB2DDuIWnLIzP/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.77MB -0.0%
../instrumentation.js -3 bytes 1.1MB -0.0%
9523.js -3 bytes 1.08MB -0.0%
../app/[[...path]]/page.js.nft.json 1.4kB 745.6kB 0.19%
../app/platform-redirect/page.js.nft.json 1.4kB 745.51kB 0.19%
../app/sitemap.xml/route.js.nft.json 1.4kB 742.98kB 0.19%

Comment on lines 124 to 126
// Also filter out the BunServer integration to avoid emitting duplicated spans from Sentry AND your custom OTel instrumentation
.filter((i) => i.name !== "Http" && i.name !== "BunServer")
.concat(Sentry.httpIntegration({ spans: false })),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: I thought we just have to filter out the bun integration, isn't spans: false already covered by skipOpenTelemetrySetup: true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted it to align with the already existing docs (here) and they mention setting this option as well.

I'm not sure myself either how we should handle documenting this. I think it's fine writing it like this explicitly as it also supports older versions, where this was not yet the default.

@Lms24 @mydea what do you think of this here? This covers both the Node and Bun examples.

Comment on lines 20 to 23
// 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 }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

// This leads to tracing being disabled

// Disable emitting of spans in the httpIntegration
integrations: [Sentry.httpIntegration({ spans: false })],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines 63 to 64
// Disable emitting of spans in the httpIntegration
integrations: [Sentry.httpIntegration({ spans: false })],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@@ -41,6 +41,8 @@ Sentry.validateOpenTelemetrySetup();

```javascript {tabTitle: NodeSDK}
const Sentry = require("@sentry/node");

const { NodeSDK } = require("@opentelemetry/sdk-node")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, it's already imported on #L48

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@s1gr1d s1gr1d merged commit 4cf4fea into master Aug 13, 2025
13 checks passed
@s1gr1d s1gr1d deleted the sig/add-bun-otel-docs branch August 13, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to setup custom OpenTelemetry with @sentry/bun. Docs are lacking info
3 participants