Skip to content

Commit

Permalink
feat(instrumentation): Gate - Echo Events Metrics and Logging
Browse files Browse the repository at this point in the history
Wire up metrics around before and after manual pipeline execution events sent to Echo.
Enable debug logging of specific event ids sent to Echo.
  • Loading branch information
dbyron-sf authored and kirangodishala committed Aug 30, 2024
1 parent c5fee72 commit d47a98f
Showing 1 changed file with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.netflix.spinnaker.gate.services

import com.netflix.spectator.api.Registry
import com.netflix.spectator.api.histogram.PercentileTimer
import com.netflix.spectator.api.patterns.IntervalCounter;
import com.netflix.spinnaker.gate.services.internal.EchoService
import com.netflix.spinnaker.gate.services.internal.Front50Service
import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector
Expand All @@ -27,6 +30,9 @@ import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

import javax.annotation.PostConstruct
import java.util.concurrent.TimeUnit

@Component
@Slf4j
class PipelineService {
Expand All @@ -48,6 +54,27 @@ class PipelineService {

private final RetrySupport retrySupport = new RetrySupport()

@Autowired
Registry registry

// Echo Event Metrics
private IntervalCounter echoEventsIntervalCounter;
private PercentileTimer echoEventsPercentileTimer;
private IntervalCounter echoEventsErrorIntervalCounter;

@PostConstruct
public void postConstruct() {
// Metrics for Echo Event handling.
final String idPrefix = "echo.events";

this.echoEventsIntervalCounter =
IntervalCounter.get(this.registry, this.registry.createId(idPrefix + ".count"));
this.echoEventsPercentileTimer =
PercentileTimer.get(this.registry, this.registry.createId(idPrefix + ".duration"));
this.echoEventsErrorIntervalCounter =
IntervalCounter.get(this.registry, this.registry.createId(idPrefix + ".error"));
}

void deleteForApplication(String applicationName, String pipelineName) {
front50Service.deletePipelineConfig(applicationName, pipelineName)
}
Expand Down Expand Up @@ -112,7 +139,26 @@ class PipelineService {
],
eventId: eventId
]
echoService.postEvent(eventMap)

final long startTimeNanos = registry.clock().monotonicTime();

try {
echoService.postEvent(eventMap)
} catch (Exception e) {
echoEventsErrorIntervalCounter.increment();
log.error("Event processing failure: eventId={}, event={}", eventId, eventMap, e);
throw(e)
}

// Echo Event Metrics
final long durationInNanos = registry.clock().monotonicTime() - startTimeNanos;
echoEventsIntervalCounter.increment();
echoEventsPercentileTimer.record(durationInNanos, TimeUnit.NANOSECONDS);

log.debug(
"Event processing success: durationInNanos={}, eventId={}",
durationInNanos, eventId);

return [
eventId: eventId,
ref : String.format("/pipelines/%s", executionId)
Expand Down

0 comments on commit d47a98f

Please sign in to comment.