dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

Mock dd-trace implementation to be used for testing dd-trace integration?

Open jrnail23 opened this issue 3 years ago • 1 comments

As I'm working on integrating dd-trace into my nodejs app, I'm thinking this would be a hell of a lot easier if there was a mock implementation available that would work in Jest, so I wouldn't need to actually run/restart my app, manually hit the resources I'm interested in, then wait 30 seconds to see what gets recorded in DataDog APM. Is there anything like that currently available? I accidentally stumbled across the mocktracer package, which appears to be the Go version of what I'm looking for.

jrnail23 avatar Jun 24 '22 02:06 jrnail23

Hi @jrnail23. In our own tests in this repository, we use a Node.js mock agent. That being said, this isn't very well documented, or particularly suitable for usage outside this repository. It should be straightforward to adapt it for your purposes though. The protocol between the tracer and agent is fairly straightforward.

Adjacent teams at Datadog use https://github.com/DataDog/dd-apm-test-agent, which is also published as a docker image, for easy use in CI environments. This is probably your best path forward. cc @Kyle-Verhoog who created that tool.

Both of these solutions are a little more heavyweight than what you're looking for, but I'd recommend using the full tracing library in your test suite to verify that our real tracing code interacts safely with your code.

bengl avatar Jun 24 '22 12:06 bengl

It looks like Bryan was able to provide a solution to this issue so I'll close it for now. Feel free to reopen if it's still relevant!

tlhunter avatar Dec 18 '23 22:12 tlhunter