-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally include pipeline build span attributes in related step spans #811
Comments
The The following filter in discover will return all the pipeline steps of a pipeline, notice that we filter the logs events that are also related to the same
|
Please take a look at my PR, it might have what you are looking for: with it you can write String trimSuffix(String original, String suffix) {
if (original.endsWith(suffix)) {
return original.substring(0, original.length() - suffix.length());
}
return original;
}
String trimWithDefault(String original, String suffix, String _default) {
String trimmed = trimSuffix(original, suffix);
return trimmed.length()==0 ? _default : trimSuffix(trimmed, "/");
}
pipeline {
options {
// set these attributes on the root span / trace and (almost) all child spans
withSpanAttributes([
spanAttribute(key: "custom.pipeline.job.group", value: trimWithDefault(env.JOB_NAME, env.JOB_BASE_NAME, "-"), target: 'PIPELINE_ROOT_SPAN'), // useful for filtering with multibranch jobs
spanAttribute(key: "custom.pipeline.job.name", value: env.JOB_NAME, target: 'PIPELINE_ROOT_SPAN'),
spanAttribute(key: "custom.pipeline.job.id", value: env.BUILD_NUMBER, target: 'PIPELINE_ROOT_SPAN'),
spanAttribute(key: "custom.pipeline.job.url", value: env.BUILD_URL, target: 'PIPELINE_ROOT_SPAN')
// at this point in time env.GIT_COMMIT is not yet defined
])
}
stages {
stage('build') {
// additionally set this attribute only on the root span
setSpanAttributes([spanAttribute(key: "custom.pipeline.job.commit", value: env.GIT_COMMIT, target: 'PIPELINE_ROOT_SPAN')])
// ...
withSpanAttributes([
spanAttribute(key: "custom.step.tag", value: "xyz")
]) { // set this custom attribute only on the 'sh' span below
sh '...'
}
}
}
} |
the latest versions has the |
What feature do you want to see added?
We are currently using this plugin within our Jenkins and we have multiple steps or stages that share the same name. We would like the ability to track information such as the # of times called or duration of the stages based on the associated pipeline. We are currently unable to do this because step spans do not include the
ci.pipeline.name
orci.pipeline.id
.Is it possible to allow some of these to carry on into the step spans? Or is there another solution to link Root Build spans and stage spans together? I've tried doing something like this but haven't had luck with it:
https://github.com/jenkinsci/opentelemetry-plugin/blob/main/docs/job-traces.md
Upstream changes
No response
Are you interested in contributing this feature?
No response
The text was updated successfully, but these errors were encountered: