|
7 rokov pred | |
---|---|---|
.. | ||
gradle | 7 rokov pred | |
src | 7 rokov pred | |
README.md | 7 rokov pred | |
apm.png | 7 rokov pred | |
dropwizard-mongo-client.gradle | 7 rokov pred | |
gradlew | 7 rokov pred | |
gradlew.bat | 7 rokov pred |
This project aims at demonstrating how to instrument legacy code based on:
We also demonstrate user cross-process tracing through the TracedClient
example.
localhost
, port: 27017
).If you're using Docker, you can run a mongo instance as follow:
docker run -it --rm -p 27017:27017 --name mongo -d mongo
If you want to enable tracing you have to launch the application with the Datadog java agent. First, get the latest version of the dd-java-agent:
NOTE: While in beta, the latest version is best found on the Snapshot Repo.
# download the latest published version:
wget -O dd-java-agent.jar 'https://search.maven.org/remote_content?g=com.datadoghq&a=dd-java-agent&v=LATEST'
Then, build the app add the agent to the JVM. That can be done as follow:
cd path/to/dd-trace-examples/dropwizard-mongo-client
./gradlew clean shadowJar
java -javaagent:/path/to/dd-java-agent.jar -jar build/libs/dropwizard-mongo-client-demo-all.jar server
Once the application runs. Go to the following url:
Then get back to Datadog and wait a bit to see a trace coming.
TracedClient
classRuns the TracedClient
class with the java agent as explained above.
In that case, we instrument the OkHttpClient
and you then observe a similar trace as the example just above but with the client as the originating root span.
Cross process tracing is working thanks to headers injected on the client side that are extracted on the server. If you want to understand more you can refer to the opentracing documentation.
A trace example
To run the distributed example, first start the dropwizard app, the mongo db and finally run the main
from com.example.helloworld.client.TracedClient
dd-trace-agent
The instrumentation is entirely done by the datadog agent which embed a set of rules that automatically recognizes & instruments:
@Trace
annotationThe Datadog agent embeds the open tracing java agent. We strongly recommend you to refer to the Datadog Agent documentation if you want to dig deeper.