-
Notifications
You must be signed in to change notification settings - Fork 224
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
integrate with Nuxtjs but cannot see any transaction in APM #4143
Comments
@cwhsu1984 Hi. Thanks for the issue. There are a few things to note here, but ultimately, this APM agent is not currently able to instrument NuxtJS 3 apps. instrumenting the dev server (somewhat)I created a basic Nuxt 3 app using the getting started doc: https://nuxt.com/docs/getting-started/introduction I was able to get some tracing data for HTTP requests to the server when using the dev server:
Then I would get traces something like the following (this is a text-based summary of traces rather than showing screenshots from Kibana):
These transactions and spans are coming from automatic instrumentation of the This tracing is, of course, limited because the APM agent ( No tracing for the production serverWhen I build and run the production (non-dev) server:
This does not work. Ideally we would be able to get some instrumentation of the ESM code by using the additional
This partially works. For example, when manually making a call to just the added "/api/hello" endpoint in my small Nuxt app:
I successfully get a trace from the APM agent:
However, when loading the full app in a browser (http://localhost:3000), I get a 500 error in the browser and this in the app log:
This is almost certainly a bug in the underlying library that the APM agent is using to hook into ES module imports. That hooking is breaking the BundlingFinally, if I understand correctly, the built server code uses a bundler (esbuild?). Currently this APM agent does not support instrumenting libraries used in bundled code. Node.js core libraries (like If you are mainly interested in HTTP incoming and outgoing spans, then this may be fine for you. optionsI have not tried this, but perhaps the Nuxt tsconfig could be changed to build a CommonJS server, rather than ESM code. Then that might allow the built server to be instrumented without the |
I would like to thank you for the very detailed response to the thread. |
Okay, thanks. I'll close this issue now. Please feel free to re-open, or create a new one if you have other questions. I'm sorry this doesn't work out of the box for you. |
Actually this exact issue was just recently fixed in import-in-the-middle: nodejs/import-in-the-middle#139
|
It looks like that particular crash will be fixed when we have a release with this update: #4162 |
I'm not sure exactly how I should apply this, so this is what I did.
Still the same error.
|
@cwhsu1984 Sorry to imply that we had a release with that fix. We do not yet have a release of this APM agent with the update to the import-in-the-middle library that you need. |
Is there a timeline or schedule date for the next release? |
This should fix the issue being hit here: #4143 (comment)
This should fix the issue being hit here: #4143 (comment)
This should fix the issue being hit here: #4143 (comment)
@cwhsu1984 There is now a v4.7.3 release that has a fix for that particular issue from #4143 (comment) (Note again, to set expectations, that instrumentation of a Nuxtjs app possibly using ESM and bundling, will be limited. Of course the APM agent should never cause the app to crash.) |
Thanks for the info again.
|
This should fix the issue being hit here: elastic#4143 (comment)
This is how I init apm in Dockerfile.
CMD node -r ./server/node_modules/elastic-apm-node/start.js ./server/index.mjs
This is the env config, and we run containers in kubernetes.
I check the service in APM, but there is no data.
But If I look at Metrics tab, the cpu and memory related info is collected
![image](https://private-user-images.githubusercontent.com/1912413/349941754-64c9aa5d-0e5c-49b9-9a04-79370452a053.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU2Nzk4NjMsIm5iZiI6MTcyNTY3OTU2MywicGF0aCI6Ii8xOTEyNDEzLzM0OTk0MTc1NC02NGM5YWE1ZC0wZTVjLTQ5YjktOWEwNC03OTM3MDQ1MmEwNTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MDdUMDMyNjAzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mzc4YjIyZTEzYWIxMGMxOWQwNzVjMTNmZDU2ZWJlNDQ1NGNmNzkxNTZiYTY2ZDk3ZDk3MzgwMzM0NTZkMDllNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.b3FK9AaCwe9_nFn66ikmk-RssokPlr-R48vSgN4yl7k)
Below is the container log. And I suspect it's due to the message "no active transaction found - cannot build new span".
I already try to adjust ELASTIC_APM_TRACE_CONTINUATION_STRATEGY into different settings, but still no luck.
What is the possible cause of this?
Any suggestion on how to debug this?
The text was updated successfully, but these errors were encountered: