Use automatic Gradle daemon instrumentation with CI Visibility instead of manual test tasks instrumentation#1804
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #1804 +/- ##
===========================================
+ Coverage 83.31% 83.48% +0.17%
===========================================
Files 466 466
Lines 16365 16374 +9
Branches 2453 2455 +2
===========================================
+ Hits 13633 13669 +36
+ Misses 2056 2039 -17
+ Partials 676 666 -10 |
1221ba6 to
44138b1
Compare
There was a problem hiding this comment.
Not sure why the agent Jar was stored directly in the repo - I updated the Docker image to download the agent from Maven. If there's a reason it had to be done that particular way, I'm happy to revert this part of the changes
| script: | ||
| - rm -rf ~/.gradle/daemon/ | ||
| - export DD_AGENT_HOST="$BUILDENV_HOST_IP" | ||
| - GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestDebug --stacktrace --no-daemon --build-cache --gradle-user-home cache/ |
There was a problem hiding this comment.
I added DD_ENV, DD_TAGS and other config params as agent properties rather than env vars because previously they were only set for the test tasks. The idea was to err on the side of caution, since I was not sure what the implications of setting them for the entire pipeline will be.
If there are no other jobs that need their own DD_ENV and DD_TAGS, then I'd rather move these settings to the variables section.
| RUN npm install -g @datadog/datadog-ci | ||
|
|
||
| # Install Datadog Java tracer | ||
| ENV DD_TRACER_FOLDER $PWD/dd-java-tracer |
There was a problem hiding this comment.
To not make a confusion here with the dd-java-tracer module that we are using for APM in our code now I would change the name of this folder to dd-hava-agent. What do you think @0xnm
There was a problem hiding this comment.
I'm fine with any, it won't be inside a project folder anyway (it will be inside the entry directory of the docker container).
| DD_ENV_TESTS: "ci" | ||
| DD_INTEGRATION_JUNIT_5_ENABLED: "true" | ||
| DD_CIVISIBILITY_ENABLED: "true" | ||
| DD_INSIDE_CI: "true" |
There was a problem hiding this comment.
I would propose to remove only DD_INTEGRATION_JUNIT_5_ENABLED variable, other two seems not to be related to the change made.
There was a problem hiding this comment.
Sure, reverted the extra changes
| - rm -rf ~/.gradle/daemon/ | ||
| - export DD_AGENT_HOST="$BUILDENV_HOST_IP" | ||
| - GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestDebug --stacktrace --no-daemon --build-cache --gradle-user-home cache/ | ||
| - GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestDebug --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=dd.env=ci,dd.trace.enabled=false,dd.jmx.fetch.enabled=false,dd.tags=test.configuration.variant:debug |
There was a problem hiding this comment.
maybe we can extract the common part of agent arguments inside a variable to be stored in the variables section do avoid the repetition. Ex. DD_COMMON_AGENT_CONFIG="-Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=dd.env=ci,dd.trace.enabled=false,dd.jmx.fetch.enabled=false", so that the line looks like:
| - GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestDebug --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=dd.env=ci,dd.trace.enabled=false,dd.jmx.fetch.enabled=false,dd.tags=test.configuration.variant:debug | |
| - GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestDebug --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -D$DD_COMMON_AGENT_CONFIG -Ddd.tags=test.configuration.variant:debug |
There was a problem hiding this comment.
Makes sense, done
There was a problem hiding this comment.
That didn't seem to work, I think because of referencing an env var defined inside the Docker image from an env var defined inside the pipeline. So I had to change it slightly, to only have the actual agent args inside the "common config" variable.
| RUN npm install -g @datadog/datadog-ci | ||
|
|
||
| # Install Datadog Java tracer | ||
| ENV DD_TRACER_FOLDER $PWD/dd-java-tracer |
There was a problem hiding this comment.
I'm fine with any, it won't be inside a project folder anyway (it will be inside the entry directory of the docker container).
| # Install Datadog Java tracer | ||
| ENV DD_TRACER_FOLDER $PWD/dd-java-tracer | ||
| RUN mkdir -p $DD_TRACER_FOLDER | ||
| RUN wget -O $DD_TRACER_FOLDER/dd-java-agent.jar 'https://repo1.maven.org/maven2/com/datadoghq/dd-java-agent/1.26.1/dd-java-agent-1.26.1.jar' |
There was a problem hiding this comment.
Can you please extract the version of the agent inside the env variable in the block above (around L27-L32)? So that we have a single place to manage the versions.
There was a problem hiding this comment.
Extracted
44138b1 to
880c266
Compare
| // set the `env` tag for the test spans | ||
| environment("DD_ENV", "ci") | ||
| // add custom tags based on the module and variant (debug/release, flavors, …) | ||
| environment("DD_TAGS", "test.module:$moduleName,test.variant:$variant") |
There was a problem hiding this comment.
It seems that we are losing these tags? I can see that test.configuration.variant was added in the gitlab-ci.yml file, but the name of the tag is different, and test.module tag is completely missing. Are these 2 added automatically by the agent by some chance?
There was a problem hiding this comment.
Yes, the module tag is added automatically, its value is slightly different though (the path of the Gradle task).
I changed the name of the variant tag to make it a part of the test configuration - that way the same test executed via a different task will be considered a different test case in the CI Vis backend. I wasn't exactly sure if this is a possible case - if not, I can revert the tag to its original name.
There was a problem hiding this comment.
ok, clear enough, let's try to have these changes then.
|
/merge |
|
🚂 MergeQueue This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals. you can cancel this operation by commenting your pull request with |
…d of manual test tasks instrumentation
a20e6fd to
afe5bd6
Compare
|
🚂 MergeQueue Added to the queue. This build is going to start soon! (estimated merge in less than 0s) you can cancel this operation by commenting your pull request with |
What does this PR do?
Updates CI Visibility instrumentation: rather than configuring each test task to fork a JVM with the DD Java tracer injected, now the tracer is injected into the Gradle daemon that runs the build.
Motivation
Instrumenting the Gradle daemon has the following advantages:
Additional Notes
Review checklist (to be filled by reviewers)