Code Monkey home page Code Monkey logo

Comments (7)

mohd-akram avatar mohd-akram commented on June 18, 2024 1

It does not seem to make a difference. The full log:

Sentry Logger [log]: Initializing Sentry: process: 90697, 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: LocalVariablesAsync
Sentry Logger [log]: Integration installed: Context
Sentry Logger [debug]: @opentelemetry/api: Registered a global for diag v1.8.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for trace v1.8.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for context v1.8.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for propagation v1.8.0.
Sentry Logger [debug]: @opentelemetry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'http' }
Sentry Logger [debug]: @opentelemetry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'https' }
[Sentry] Fastify is not instrumented. This is likely because you required/imported fastify before calling `Sentry.init()`.

from sentry-javascript.

andreiborza avatar andreiborza commented on June 18, 2024 1

From my testing, the issue with your sample code is two-fold. One is the named export not being instrumented properly by otel. The other is that you do not have tracesSampleRate set up in your Sentry.init call, which is why nothing's instrumented.

The messaging around that is definitely confusing though and leads users down the wrong path. I'll raise it with the team.

from sentry-javascript.

mohd-akram avatar mohd-akram commented on June 18, 2024 1

Ah, that explains it. Yes, the following works:

// app.mjs
import * as Sentry from "@sentry/node";
import fastify from "fastify";
const app = fastify();
Sentry.setupFastifyErrorHandler(app);
const address = await app.listen();
console.info(`server listening on ${address}`);
// instrument.mjs
import * as Sentry from "@sentry/node";
Sentry.init({
  dsn: process.env.SENTRY_DSN,
  debug: true,
  tracesSampleRate: 0.05,
});

from sentry-javascript.

hornta avatar hornta commented on June 18, 2024

I'm also getting the same issue. I followed this page: https://docs.sentry.io/platforms/javascript/guides/fastify/.

I also double checked that I import Sentry before importing anything from fastify.

I'm running node v22.1.0 and sentry v8.2.1

from sentry-javascript.

andreiborza avatar andreiborza commented on June 18, 2024

Hi, thank you for filing this.

It looks like open-telemetry doesn't properly instrument the named export of fastify. As a workaround, could you change your code to use the default export and report back please?

import fastify from 'fastify'

We are looking into raising this upstream with open-telemetry in the meantime.

from sentry-javascript.

andreiborza avatar andreiborza commented on June 18, 2024

Which node version are you running?

from sentry-javascript.

mohd-akram avatar mohd-akram commented on June 18, 2024

I'm running v20.13.1. Weirdly, making that change actually works in my production code. There, I have a bin/server in CJS that await imports fastify and the ESM app and sets up the server. I'll try to see what exactly is causing it to work or not.

from sentry-javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.