Coder Social home page Coder Social logo

Issues with mysql2/promise about dd-trace-js HOT 6 CLOSED

datadog avatar datadog commented on May 20, 2024
Issues with mysql2/promise

from dd-trace-js.

Comments (6)

rochdev avatar rochdev commented on May 20, 2024

@derN3rd This is definitely an oversight as mysql2/promise is not supported at the moment. For now the safest would be to disable plugins and individually enable the plugins you need (except mysql2 until this is fixed). See the API docs for an example.

from dd-trace-js.

derN3rd avatar derN3rd commented on May 20, 2024

@rochdev Thanks for your quick reply. I already got it to work with mysql2 plugin disabled, but wasn't sure if I did something wrong.

I will wait for mysql2/promise support then 😄

from dd-trace-js.

rochdev avatar rochdev commented on May 20, 2024

It seems this bug actually affects even the callback based version. It doesn't happen when mysql2 is required before the plugin however, so that could be a temporary workaround.

For example:

require('mysql2/promise') // require before to work around the bug
const tracer = require('dd-trace').init()
const mysql2 = require('mysql2/promise') // require again to apply patching

from dd-trace-js.

derN3rd avatar derN3rd commented on May 20, 2024

It doesn't crash now, but I also get no traces of my mysql2 queries.
Can this be because I have all queries in a external module?
If so, how can I patch the dependencies of this module too?

from dd-trace-js.

rochdev avatar rochdev commented on May 20, 2024

@derN3rd It should still be instrumented in external modules if the external module is required after the tracer is initialized.

Could you try something like this:

require('mysql2') // require callback version to avoid race condition with promise patch
const tracer = require('dd-trace').init()
const externalModule = require('external-module')

Also make sure you have re-enabled the plugin.

from dd-trace-js.

derN3rd avatar derN3rd commented on May 20, 2024

@rochdev Thanks man.
Got it to work. I have to do require('mysql2') first, then initialize dd-trace. Afterwards I can use mysql2 OR mysql2/promise without any problems (Like your example).
I tried to require('mysql2/promise') first, but that doesn't work.

Thanks for the help

from dd-trace-js.

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.