-
Notifications
You must be signed in to change notification settings - Fork 227
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
disableSend env var also disables automatic traces and transactions creation #2318
Comments
@angelos3lex Thanks. A couple things:
If you are able to provide a small repro script/repo with webpack build steps that would be immensely helpful as I don't have much experience with webpack.
This sounds suspicious. Almost like the |
Thanks for your reply. From what i understand, is that even if the |
@trentm So, here is the link to the repo. If we hit Things i noticed:
|
@angelos3lex Thanks very much for the repo. This is just what I need. I've made some progress, but I don't have an answer yet. |
Thanks so much for putting the repo together. Okay, wow, there are a number of things going on here. Ultimately, the news isn't great: tracing of webpack-bundled modules will not work. What output you were getting is a combination of limited tracing and some misleading info. The general advice for webpack + APM usage (not just for Elastic's APM, but for others as well) is to use the webpack-node-externals package to exclude everything under diff --git a/webpack.config.js b/webpack.config.js
index dddae8a..e741a32 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,5 +1,6 @@
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
+const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: path.join(__dirname, '/app.ts'),
@@ -22,8 +23,9 @@ module.exports = {
new CleanWebpackPlugin()
],
target: 'node',
+ externals: [nodeExternals()],
node: {
__dirname: true,
__filename: false, and then I was able get tracing and log correlation with or without I hope to (after I am able to finish up some current work) get to improving our agent docs on this. detailsFirst, with both:
Having two Agents in play generally will break things because it necessarily makes changes to Node's global state and two of them will conflict, or have surprising results. With your repo, unchanged, what is happening is (you can better see what is going on with
I believe what is happening here is that
In this case "Agent A", as above, successfully can instrument unbundled modules, like the core "http" module. A transaction is created and sent to APM server. However, the bundled
In this case "Agent B" is started, but its hooks into I haven't dug into the "either ..., or" issue because, ultimately getting tracing to work properly requires not bundling modules to be traced (as mentioned above), or someone getting deeply involved into webpack internals to see if it is possible to hook into |
#1967 Is the issue in which I'm going attempt to improve docs (and perhaps agent internals tohelp somewhat). The tl;dr is still going to be "use 'externals' in webpack.config.js to unbundle deps that one needs traced". |
@angelos3lex I'm closing this issue now. Please feel free to re-open if you still have questions or if I've missed something. Hopefully using webpack "externals" config is sufficient for your case. |
I have an express nodejs server, and as I'm using webpack, I can't use the
require("elastic-apm-node").start
in the runtime code, due to the way webpack traverses the row of the imports.So, I'm setting env var:
ELASTIC_APM_DISABLE_SEND=true
.I'm starting the agent using
node -r elastic-apm-node/start --unhandled-rejections=strict ./dist/app.js
The communication with apm server stops as expected, but the traces and transactions that were previously automatically generated are no longer generated and i loose log correlation.
Expected behavior
I expect the traces and transactions ids to be generated as well, as mentioned in the API docs.
Environment (please complete the following information)
Just in case its helpful, I'm using
winston
,express-winston
and@elastic/ecs-winston-format
)How are you starting the agent? (please tick one of the boxes)
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
)elastic-apm-node/start
from within the source code-r elastic-apm-node/start
Also, something weird that may has to do with the problem, is that to make it work, i start node using
node with -r elastic-apm-node/start
but also on the top of the file, I have:require("elastic-apm-node/start");
. If i remove this line from the top of my entry file executable, the apm automatic traces/transactions etc isn't working even when i remove the disableSend env var, like it's never started.The text was updated successfully, but these errors were encountered: