Fixes for Jenkins pipelines traces tags#119
Conversation
953114f to
ec6f4f5
Compare
| final long endTimeMicros = buildData.getEndTime(0L) * 1000; | ||
| buildSpan.setTag(DDTags.SERVICE_NAME, "jenkins"); | ||
| buildSpan.setTag(DDTags.RESOURCE_NAME, buildData.getJobName(null)); | ||
| buildSpan.setTag(DDTags.RESOURCE_NAME, removeBranchSuffix(buildData.getJobName(null))); |
There was a problem hiding this comment.
For context, what is this tag for, why does the job name contains the branch in it, and are we sure this method will not remove important information?
There was a problem hiding this comment.
When the user triggers a multibranch pipeline, the job name contains a suffix with the branch. This suffix needs to be removed to treat all pipeline executions related to the same pipeline item as the same resources in Datadog (and not per branch)
There was a problem hiding this comment.
The issue with Jenkins though is that plugins have a lof of freedom. The multibranch plugin will create one "Project/Job" per branch in the repo and indeed will add the name of the branch to the Job name.
We're here tackling an specific behavior of one specific plugin. But other plugins can do similar things that won't be handled by this change.
I think a best bet would be limit this specific behavior to cases where we are sure that the Job comes from a multibranch pipeline. I'm sure there's a way to tell that without depending on the multibranch plugin either. Maybe check the list of action and check if one of the action's class name matches a multibranch action?
There was a problem hiding this comment.
This function will simply remove anything after the first /.
If a non multibranch project has a / in the name, the suffix will get removed unintentionally
There was a problem hiding this comment.
I'm going to remove this specific logic from this PR. As you mention, more things need to be considered and it will be adjusted in other specific PR.
11b3ca1 to
9e25ca1
Compare
9e25ca1 to
3cebef5
Compare
DISCLAIMER
This PR adds an experimental feature in alpha state.
Internal use only.
Requirements for Contributing to this repository
What does this PR do?
This PR contains the following changes in the tags for Jenkins pipelines spans:
Start of pipelinespan fromci.pipeline.*toci.job.*ci.job.numbertag.ci.pipeline.nameandresource.nameci.job.urlto<pipeline_url>/execution/node/<job_id>/Description of the Change
Alternate Designs
Possible Drawbacks
Verification Process
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.