Skip to content

Commit

Permalink
Merge branch 'master' into add-resolved-expected-artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmcintosh authored Dec 11, 2024
2 parents 4ea5fe1 + 8e1ec6d commit 74147ef
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.spinnaker.orca.qos

import com.netflix.spectator.api.Registry
import com.netflix.spectator.api.patterns.PolledMeter
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import com.netflix.spinnaker.orca.annotations.Sync
import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.BUFFERED
Expand All @@ -29,6 +30,7 @@ import net.logstash.logback.argument.StructuredArguments.value
import org.slf4j.LoggerFactory
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component
import java.util.concurrent.atomic.AtomicLong

/**
* Determines if an execution should be buffered.
Expand All @@ -50,6 +52,11 @@ class ExecutionBufferActuator(
private val enqueuedId = registry.createId("qos.executionsEnqueued")
private val elapsedTimeId = registry.createId("qos.actuator.elapsedTime")

// have to use PolledMeter because an ordinary metric is deleted by Garbage Collector
private val bufferingEnabled = PolledMeter.using(registry)
.withId(bufferingId)
.monitorValue(AtomicLong(0))

@Sync
@EventListener(BeforeInitialExecutionPersist::class)
fun beforeInitialPersist(event: BeforeInitialExecutionPersist) {
Expand All @@ -61,7 +68,7 @@ class ExecutionBufferActuator(

val supplierName = bufferStateSupplier.javaClass.simpleName
if (bufferStateSupplier.get() == ACTIVE) {
registry.gauge(bufferingId).set(1.0)
bufferingEnabled.set(1)

val execution = event.execution
withActionDecision(execution) {
Expand All @@ -83,7 +90,7 @@ class ExecutionBufferActuator(
}
}
} else {
registry.gauge(bufferingId).set(0.0)
bufferingEnabled.set(0)
}
}

Expand Down

0 comments on commit 74147ef

Please sign in to comment.