Skip to content
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

@sentry/bun not reporting any span data #12705

Open
3 tasks done
nzapponi opened this issue Jun 30, 2024 · 8 comments
Open
3 tasks done

@sentry/bun not reporting any span data #12705

nzapponi opened this issue Jun 30, 2024 · 8 comments
Assignees
Labels
Package: bun Issues related to the Sentry Bun SDK Type: Bug

Comments

@nzapponi
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/bun

SDK Version

8.13.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup/Reproduction Example

Entrypoint line 1:

import "./sentry.ts"

sentry.ts

import { SocketIoInstrumentation } from "@opentelemetry/instrumentation-socket.io";
import * as Sentry from "@sentry/bun";
import data from "../../../package.json";
import { SENTRY_DSN, SENTRY_ENVIRONMENT } from "./const";

Sentry.init({
  dsn: SENTRY_DSN,
  tracesSampleRate: 1.0,
  environment: SENTRY_ENVIRONMENT,
  release: data.version,
});

Sentry.addOpenTelemetryInstrumentation(new SocketIoInstrumentation());

Steps to Reproduce

  1. Start the bun server (which uses Express)
  2. Make an API call from the client (or curl) to the server

Expected Result

A trace of the API call from request to response, including all the middleware calls, database queries (I'm using pg), etc.

Actual Result

I get a trace, but every transaction just says "Empty - Transaction did not report any span data"
This also happens on server-side events that I instrumented using await Sentry.startSpan(...): I get a trace that the span is there, but no data within it.

Screenshot 2024-06-30 at 16 05 21

@github-actions github-actions bot added the Package: bun Issues related to the Sentry Bun SDK label Jun 30, 2024
@nzapponi nzapponi changed the title @sentry/bun or reporting any span data @sentry/bun not reporting any span data Jun 30, 2024
@andreiborza
Copy link
Member

Hi, thank you for reporting this. Could you please add debug: true to your sentry options and paste some output?

@nzapponi
Copy link
Author

nzapponi commented Jul 1, 2024

Thanks @andreiborza !

Here it is:

$ bun run --hot src/server.ts
Sentry Logger [log]: Initializing Sentry: process: 72557, thread: main.
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: NodeFetch
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: BunServer
Sentry Logger [log]: Running in CommonJS mode.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for diag v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for trace v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for context v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for propagation v1.9.0.
Sentry Logger [warn]: @opentelemetry/instrumentation-socket.io Module socket.io has been loaded before @opentelemetry/instrumentation-socket.io so it might not work, please initialize it before requiring socket.io
Sentry Logger [warn]: @opentelemetry/instrumentation-socket.io Module socket.io has been loaded before @opentelemetry/instrumentation-socket.io so it might not work, please initialize it before requiring socket.io
  server:app Registered data model +0ms
[Sentry] express is not instrumented. This is likely because you required/imported express before calling `Sentry.init()`.
  server:app Bootstrapping services +0ms
  server:pg Initializing database +0ms
  server:pg Running migrations +0ms
  server:app Listening on port 28001... +0ms

@nzapponi
Copy link
Author

nzapponi commented Jul 1, 2024

Weird that it says Running in CommonJS mode... isn't it?

@lforst
Copy link
Member

lforst commented Jul 2, 2024

@nzapponi The logic for that log message basically just checks whether require is in the global namespace. This is a bit weird in bun, because it maximizes compatibility.

Could you provide a reproduction of where this is not working? Thanks! It's a bit hard to gauge things from looking afar.

@nzapponi
Copy link
Author

nzapponi commented Jul 2, 2024

Here is a sample repo to reproduce: https://github.com/nzapponi/bun-sentry-repro
I keep getting no span data.

Thanks!

Screenshot 2024-07-02 at 11 53 10

@chargome
Copy link
Member

chargome commented Jul 2, 2024

Thank you @nzapponi, we'll look into it!

@chargome
Copy link
Member

chargome commented Jul 2, 2024

@nzapponi it seems that there are issues regarding the auto-instrumentation with express and bun.

I keep getting no span data.

For now, although you do not receive auto-generated span data you can still make use of custom instrumentation and error monitoring for your app with your current setup.

We'll reference this issue once we have a fix.

@nzapponi
Copy link
Author

nzapponi commented Jul 2, 2024

Ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: bun Issues related to the Sentry Bun SDK Type: Bug
Projects
Status: No status
Development

No branches or pull requests

4 participants