Skip to content
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

Expose helpers to make manual instrumentation easier for supported modules #560

Open
mrtnzlml opened this issue May 9, 2019 · 7 comments

Comments

Projects
None yet
2 participants
@mrtnzlml
Copy link

commented May 9, 2019

I was trying to make dd-trace work according to documentation but seems like it only works for Node.js native modules. In our case, it doesn't work for NPM modules like GraphQL. So I started to dig into the source code and seems like this library requires not only package.json but also node_modules folder. And we don't have either of this in production. So my questions are:

  1. What are the requirements for automatic instrumentation? Seems like it's not documented.
  2. How to do manual instrumentation? For example, I know we use GraphQL so I'd like to force it without package.json and other magic stuff.

Thank you very much for your answers.

@rochdev

This comment has been minimized.

Copy link
Member

commented May 9, 2019

The only reason automatic instrumentation depends on node_modules is to match the path in the instrumented module folder. We can probably adjust that for other folders. Where do you store the modules if not in node_modules?

@mrtnzlml

This comment has been minimized.

Copy link
Author

commented May 9, 2019

We are deploying from monorepo and it's not so simple to just take the repo, transpile it and deploy it. So we bundle all our Node.js code into a single file and just execute it. It simplifies many things and we are quite happy with this setup. But it means there are not package.json or `node_modules.

It would be great if I had the ability to manually instrument some modules. I understand that automatic instrumentation is great for quick starts but I'd like to have this more under control (especially in this situation when the automatic way doesn't work).

Thanks for any advice on how to make it work.

@rochdev

This comment has been minimized.

Copy link
Member

commented May 9, 2019

In that case you will indeed have to rely on manual instrumentation. You can find documentation here. There is also a new API that is simpler to use but not yet documented that you can find here.

What do you use to bundle the code together? Do you think it would make sense to support bundlers to get automatic instrumentation for use case like yours? We're also thinking of exposing module specific APIs eventually to make it easier to do manual instrumentation on supported modules when automatic instrumentation is not possible or wanted.

@mrtnzlml

This comment has been minimized.

Copy link
Author

commented May 9, 2019

Thanks! It would be really great to be able to reuse some parts of GraphQL tracer like function wrap{Execute|Parse|Validate} for example.

Do you think it would make sense to support bundlers to get automatic instrumentation for use case like yours?

Honestly, I don't think so. We currently use Webpack because it makes our life so much easier. But we could eventually change it to something else, why not. It's a bit weird to use Webpack on a server, I know. :) Automatic instrumentation is good for most of the projects but I wouldn't try to catch every use-case. It's better to be able to easily opt-out from it.

@rochdev

This comment has been minimized.

Copy link
Member

commented May 9, 2019

Ok, so for now I would say to use the manual instrumentation and feel free to update this thread with any question or pain point. This will also help us to design these module specific APIs.

@rochdev rochdev changed the title What are the requirements for automatic instrumentation? Expose helpers to make manual instrumentation easier for supported modules May 9, 2019

@mrtnzlml

This comment has been minimized.

Copy link
Author

commented May 9, 2019

There is also a new API that is simpler to use but not yet documented that you can find here.

@rochdev Do you maybe have some example of how to use it correctly?

@rochdev

This comment has been minimized.

Copy link
Member

commented May 10, 2019

There are a few examples in #457, mostly showing the equivalent code using the low level API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.