Closed xBis7 closed 3 weeks ago
@kuisathaverat @cyrille-leclerc Can you take a look at this PR?
It's related to this issue https://github.com/jenkinsci/opentelemetry-plugin/issues/90
@kuisathaverat Did you get a chance to take a look?
Sorry for not getting back to you sooner, but I did not find time to perform the manual test needed to verify that there are no regressions. Also, I want to make a huge pipeline test to verify there are no leaks or performance issues.
@kuisathaverat Is there something I can do to help? Run some test? I've run manual tests but my use-cases might not match yours.
I need more time. I have compared two "similar" pipelines to see if the memory usage grows, and it does.
A pipeline with 500 steps uses about 450MB of RAM and does not increase memory usage after it is finished. I executed it 10 times.
pipeline {
agent any
stages {
stage('prepare') {
steps {
bunchOfSteps(0)
}
}
}
}
def bunchOfSteps(level) {
if (level < 100) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
A pipeline with 500 steps and the new step to create spans uses about 850MB of RAM and increases the memory usage after it finishes about 350MB. I executed it one time.
pipeline {
agent any
stages {
stage('prepare') {
steps {
bunchOfSteps(0)
}
}
}
}
def bunchOfSteps(level) {
if (level < 500) {
withNewSpan(label: 'custom-build-span-' + level, attributes: ([
spanAttribute(key: 'level', value: level),
]), setAttributesOnlyOnParent: true) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
}
It would be interesting to compare the RAM usage between
pipeline {
agent any
stages {
stage('prepare') {
steps {
bunchOfSteps(0)
}
}
}
}
def bunchOfSteps(level) {
if (level < 500) {
withSpanAttributes([
spanAttribute(key: 'level', value: level),
]) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
}
pipeline {
agent any
stages {
stage('prepare') {
steps {
bunchOfSteps(0)
}
}
}
}
def bunchOfSteps(level) {
if (level < 500) {
withNewSpan(label: 'custom-build-span-' + level, attributes: ([
spanAttribute(key: 'level', value: level),
]), setAttributesOnlyOnParent: true) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
}
withSpanAttributes
might also increase the RAM usage afterwards.
this one directly crash after 250 steps, but I not see the memory change after several executions
def bunchOfSteps(level) {
if (level < 500) {
withSpanAttributes([
spanAttribute(key: 'level', value: level),
]) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
}
I am going to test this one too
def bunchOfSteps(level) {
if (level < 500) {
withNewSpan(label: 'custom-build-span-' + level, setAttributesOnlyOnParent: true) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
}
I am going to change the approach recursivity 500 it is a lite too much for a pipeline
pipeline {
agent any
stages {
stage('prepare') {
steps {
bunchOfSteps(0)
}
}
}
}
def bunchOfSteps(level) {
if (level < 10) {
recursiveSteps(0)
bunchOfSteps(level + 1)
}
}
def recursiveSteps(level){
if (level < 50) {
withNewSpan(label: 'custom-build-span-' + level, attributes: ([
spanAttribute(key: 'level', value: level),
]), setAttributesOnlyOnParent: true) {
sh "echo level ${level}"
recursiveSteps(level + 1)
}
}
}
I am also testing
pipeline {
agent any
stages {
stage('prepare') {
steps {
withNewSpan(label: 'custom-build-span', attributes: ([
spanAttribute(key: 'level', value: 'foo'),
]), setAttributesOnlyOnParent: false) {
bunchOfSteps(0)
}
}
}
}
}
def bunchOfSteps(level) {
if (level < 500) {
sh "echo level ${level}"
bunchOfSteps(level + 1)
}
}
I need to grab some head dumps and verify there is nothing weird.
The memory issue was a snowflake. I cannot replicate it anymore, but I do not see any issue, so we can merge.
@kuisathaverat Thanks for the review and the help!
@kuisathaverat Thanks for merging it. Regarding using the change, should we wait for a new release, or is there some other way?
When we merge a change with labels bug or enhancement a new release is trigger, IIRC it takes 6 hours or so to be in the Jenkins update center https://github.com/jenkinsci/opentelemetry-plugin/releases/tag/3.1419.v3b_27ca_911066
@kuisathaverat Thanks!
opentelemetry-plugin
issue: https://github.com/jenkinsci/opentelemetry-plugin/issues/90This PR is based on the work done on PR https://github.com/jenkinsci/opentelemetry-plugin/pull/84.
The patch is adding a new step
withNewSpan
which allows users to create their own spans.The option accepts 3 parameters
label
attributes
withSpanAttributes
setAttributesOnlyOnParent
From the above 3 parameters, only the
label
is required and everything else is optional.Example usage
or
or
withNewSpan
to be consistent with the naming of other steps likewithSpanAttributes
SpanAttributeStepExecution
was reusedTesting done
MonitorPipelineListener
Screenshot from manual testing
Submitter checklist