Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
The pull request must only fix one issue at the time.
The pull request must update the test suite to demonstrate the changed functionality.
After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.
What does this PR do?
Adds support for injecting Datadog APM Tracers into Jenkins builds transparently to the user.
"Enable Datadog Test Visibility" checkbox should be set in job configuration UI in order to enable tracer injection for a specific job.
Description of the Change
A new JobProperty is added that stores tracer injection settings.
An EnvironmentContributor (for freestyle projects) and a StepContributor (for pipelines) are added as well.
If Java tracer injection is enabled one of the contributors downloads the tracer JAR (the JAR is downloaded to the node where the build is running) and augments job environment with MAVEN_OPTS/GRADLE_OPTS and Datadog environment variables.
Tracer JAR is stored inside the job workspace. By default it is downloaded only if no JAR has been downloaded previously, or if previous JAR is older than 12 hours (TTL is configurable).
Injection for other languages works similarly (a combination of installing the tracer and injecting it via environment variables).
Alternate Designs
Configuring tracer injection centrally in Datadog plugin settings - rejected, as this is too coarse grained, customer might not want to run ALL of their jobs with the tracer, but likely only a subset of them.
Adding custom a job/pipeline step - rejected, as this would require customer to alter their job/pipeline definitions, and is not likely to bring additional value (it is very unlikely that the customer might want to trigger multiple Maven/Gradle builds in the same job and only instrument some of them. Even in such situations the accepted design allows this by modifying the injected env variables).
Using BuildWrapper instead of EnvironmentContributor - rejected, as using a build wrapper requires a dedicated UI control in addition to job property that is already there
Possible Drawbacks
Tracer injection will not work if a job starts Maven/Gradle build inside a container.
In this case customer can fallback to manual tracer configuration, the way this is done at the moment.
Verification Process
Verified manually using a dockerized Jenkins instance.
Checked the following scenarios:
freestyle build executed on master node
freestyle build executed on agent node
pipeline build executed on master node
pipeline build executed on agent node
Both Maven and Gradle builds were verified.
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
[ ] Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
[ ] PR title must be written as a CHANGELOG entry (see why)
[ ] Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
[ ] PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
[ ] PR should not have do-not-merge/ label attached.
[ ] If Applicable, issue must have kind/ and severity/ labels attached at least.
Requirements for Contributing to this repository
What does this PR do?
Adds support for injecting Datadog APM Tracers into Jenkins builds transparently to the user. "Enable Datadog Test Visibility" checkbox should be set in job configuration UI in order to enable tracer injection for a specific job.
Description of the Change
A new
JobProperty
is added that stores tracer injection settings. AnEnvironmentContributor
(for freestyle projects) and aStepContributor
(for pipelines) are added as well.If Java tracer injection is enabled one of the contributors downloads the tracer JAR (the JAR is downloaded to the node where the build is running) and augments job environment with
MAVEN_OPTS
/GRADLE_OPTS
and Datadog environment variables. Tracer JAR is stored inside the job workspace. By default it is downloaded only if no JAR has been downloaded previously, or if previous JAR is older than 12 hours (TTL is configurable).Injection for other languages works similarly (a combination of installing the tracer and injecting it via environment variables).
Alternate Designs
BuildWrapper
instead ofEnvironmentContributor
- rejected, as using a build wrapper requires a dedicated UI control in addition to job property that is already therePossible Drawbacks
Tracer injection will not work if a job starts Maven/Gradle build inside a container. In this case customer can fallback to manual tracer configuration, the way this is done at the moment.
Verification Process
Verified manually using a dockerized Jenkins instance. Checked the following scenarios:
Both Maven and Gradle builds were verified.
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/
label attached. If applicable it should have thebackward-incompatible
label attached.do-not-merge/
label attached.kind/
andseverity/
labels attached at least.