scoutapp / scout_apm_node

ScoutAPM Agent for NodeJS. Supports Express and other frameworks
https://scoutapm.com
Other
8 stars 9 forks source link

TypeError: this.logFn is not a function #275

Open andresespinosapc opened 3 years ago

andresespinosapc commented 3 years ago

I'm getting the error TypeError: this.logFn is not a function. I think it's because of this line:

https://github.com/scoutapp/scout_apm_node/blob/a1894e4d7d9c11d39afedc0af4b47087d858916d/lib/scout/index.ts#L758

fborie commented 3 years ago

were you able to solve it @andresespinosapc ? 👀 I am facing the same issue in an express setup with typescript. Each time I hit an endpoint I get that noisy error

muayKenny commented 2 years ago

me too! hit that same error.

import API from "@scout_apm/scout-apm"; const scout = API;

scout.install({ allowShutdown: true, // allow shutting down spawned scout-agent processes from this program monitor: true, // enable monitoring name: process.env.SCOUT_NAME, key: process.env.SCOUT_KEY, });

server.use(scout.expressMiddleware());

my installation

yaronlevi commented 2 years ago

Happens here also? Any ideas?

Tsirovasilis-I commented 1 year ago

Hello, do we have any news on this?

fidel-ruiz commented 1 year ago

The way to fix this is by implementing that function when initializing scout as explained in https://github.com/scoutapp/scout_apm_node/blob/master/docs/integrations/express.md

Example code:


await scout.install({
  monitor: true,
  name: "<your name>",
  key: "<key>",
}, {
  logFn: (message, level) => {
    console.log(message, level)
  }
}).then(() => {
  console.log("scout initialized");
})

With the code above it produces the output for scout logs

023-05-30T22:53:44.640727+00:00 app[web.1]: [scout] Creating request for instrumentation warn
2023-05-30T22:53:44.654445+00:00 app[web.1]: failed to clear async namespace debug
2023-05-30T22:53:44.654514+00:00 app[web.1]: failed to clear async namespace debug
2023-05-30T22:54:04.648705+00:00 app[web.1]: [scout] Creating request for instrumentation warn
2023-05-30T22:54:04.662112+00:00 app[web.1]: failed to clear async namespace debug
2023-05-30T22:54:04.662134+00:00 app[web.1]: failed to clear async namespace debug
2023-05-30T22:54:24.658401+00:00 app[web.1]: [scout] Creating request for instrumentation warn