-
Notifications
You must be signed in to change notification settings - Fork 225
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
Questions re ESM support for MikroOrm / knex, Node v20, & OIDC #3870
Comments
That is referring to the
Yes, ESM instrumentation is supported versions of Node.js v20 greater than or equal to v20.2.0 -- but only as of the latest v4.4.1 release: Node v20.0.0 and v20.1.0 are not supported because there was a Node.js core bug.
A few things here:
Typically if the APM agent instruments a particular package A, and some package B uses package A, then that usage would also be instrumented. A good example is the Regarding your case:
So, IIUC, you are effectively requesting an enhancement that this APM agent support instrumenting If
Perhaps configure your usage of MikroOrm to register handlers for Lifecycle Hooks or subscribe to its events -- see https://mikro-orm.io/docs/events -- and then add manual span-creation tracing (e.g. https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-start-span) there?
Nothing specific to OIDC, currently, no. |
Hi Trent, Thanks for the quick & detailed reply on this! It's much appreciated.
That's great - I had missed that update.
Also glad to hear this! Regarding knex instrumentation & behaviour, I understand that it is only enabled when Still, I'm surprised it crashes in this way. I'll check if there's a resource spike but I don't think so - it's possible this behaviour is due to some implementation detail in the code - if I have time I'll try to repro this in a shareable way.
As it happens, it now turns out we have to migrate to MySQL as Azure is dropping managed MariaDB. So we can un-request MariaDB support, but consider this a +1 for ESM/MySQL support :) - I took a look at the Project page and I guess there's no ETA there?
Thanks for this tip! I guess the big thing I wanted to verify is that fact that manual instrumentation is still possible with TypeScript/ESM apps, and if I understand correctly it is. For now I will go modify things to use MySQL and try to add some manual instrumentation.
This is great practical info! Maybe it's basic/assumed stuff for seasoned JS devs, but I think this paragraph would be helpful in the docs & give users a better intuition of how APM works. Finally, thanks for the answer re OIDC. I presume we could manually instrument these calls also, right? As they tend to be simple enough, along the lines of |
Correct. Unfortunately I don't have an ETA.
Yes, I believe so. I haven't worked with OIDC libraries myself, so I can't be sure. |
Is your feature request related to a problem? Please describe.
This is more of a question thread, but relates to problems auto-instrumenting ECMAScript / ESM modules.
Describe the solution you'd like
Auto-instrumentation of MikroOrm module, and OIDC flows if possible
Describe alternatives you've considered
Considered manual instrumentation but unsure how to proceed there.
Additional context
Stacktrace provided below.
Hello Team!
My company is an Elastic Cloud customer happily running a search application in production.
I'm an SRE with one of the software teams, and we are also trying to get APM set up for observability.
We've been trying to get ECMAScript / ESM auto-instrumentation set up for a service for some time with limited success. We are running it via package.json using:
node -r dotenv/config \ -r elastic-apm-node/start.js \ --experimental-loader=elastic-apm-node/loader.mjs \ --env-file .env \ dist/server.js"
It works in that some transactions / metrics are sent to our APM server, however it doesn't know about dependencies or databases.
Our service uses MikroOrm for database calls, and out of the box APM doesn't capture spans. When I enable the
ELASTIC_APM_SPAN_STACK_TRACE_MIN_DURATION
env var, it seems to prevent the DB client from initialising:I initially thought this was supported as MikroOrm uses knex under the hood, but now I see in the docs that the supported versions of knex are:
knex
Could someone advise what pg@8 refers to here? Not PostGres v8 surely?
Knex standalone is currently at 3.1.0, and I'm not exactly sure how MikroOrm invokes it. They apparently also use some 'monkey-patching' (their words) to apply some compatibility fixes to knex.
Also, our service has just been upgraded to node v20. I can see in Supported Node Versions that
>=20.2.0
is listed, however there is an draft PR open for enable ESM support for Node v20. Could someone provide some clarity on what is / isn't supported in v20+?Assuming I can't find a way to make auto instrumentation work with our project, do you think manual instrumentation might be possible in this kind of scenario?
For reference, here are the main components of our stack:
Our service is also using
oidc-provider
for authentication. As a side note, it would be amazing if APM could (now or at some point in the future) somehow instrument OIDC flows, but for the moment some observability on DB interactions are what we need the most.So, to summarise my questions:
Auto-instrumentation:
Manual instrumentation:
Bonus: OIDC
The text was updated successfully, but these errors were encountered: