Skip to content

Commit

Permalink
reafactor(eventMonitor): create method for emitting metrics for overr…
Browse files Browse the repository at this point in the history
…iding (#251)
  • Loading branch information
emjburns committed Apr 5, 2018
1 parent c980168 commit 393f1a6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ protected Predicate<Trigger> matchTriggerFor(final TriggerEvent event, final Pip
}

@Override
protected void onMatchingPipeline(Pipeline pipeline) {
super.onMatchingPipeline(pipeline);
protected void emitMetricsOnMatchingPipeline(Pipeline pipeline) {
val id = registry.createId("pipelines.triggered")
.withTag("application", pipeline.getApplication())
.withTag("name", pipeline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ private boolean isMatchingTrigger(DockerEvent dockerEvent, Trigger trigger, fina
anyArtifactsMatchExpected(getArtifacts(dockerEvent), trigger, pipeline);
}

protected void onMatchingPipeline(Pipeline pipeline) {
super.onMatchingPipeline(pipeline);
@Override
protected void emitMetricsOnMatchingPipeline(Pipeline pipeline) {
val id = registry.createId("pipelines.triggered")
.withTag("application", pipeline.getApplication())
.withTag("name", pipeline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ protected Function<Trigger, Pipeline> buildTrigger(Pipeline pipeline, TriggerEve
}

@Override
protected void onMatchingPipeline(Pipeline pipeline) {
super.onMatchingPipeline(pipeline);
protected void emitMetricsOnMatchingPipeline(Pipeline pipeline) {
val id = registry.createId("pipelines.triggered")
.withTag("application", pipeline.getApplication())
.withTag("name", pipeline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;
import rx.Observable;
import rx.functions.Action1;

Expand Down Expand Up @@ -116,11 +113,10 @@ protected Predicate<Trigger> matchTriggerFor(final TriggerEvent event, final Pip
}

@Override
protected void onMatchingPipeline(Pipeline pipeline) {
super.onMatchingPipeline(pipeline);
protected void emitMetricsOnMatchingPipeline(Pipeline pipeline) {
val id = registry.createId("pipelines.triggered")
.withTag("application", pipeline.getApplication())
.withTag("name", pipeline.getName());
.withTag("application", pipeline.getApplication())
.withTag("name", pipeline.getName());

if (isPubsubTrigger(pipeline.getTrigger())) {
id.withTag("pubsubSystem", pipeline.getTrigger().getPubsubSystem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.netflix.spinnaker.echo.model.trigger.TriggerEvent;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.stereotype.Component;
import rx.Observable;
import rx.functions.Action1;
Expand All @@ -42,7 +41,7 @@
*/
@Component
@Slf4j
abstract class TriggerMonitor implements EchoEventListener {
public abstract class TriggerMonitor implements EchoEventListener {

protected final Action1<Pipeline> subscriber;
protected final Registry registry;
Expand Down Expand Up @@ -110,8 +109,11 @@ protected Func1<Pipeline, Optional<Pipeline>> withMatchingTrigger(final TriggerE

protected abstract boolean isValidTrigger(final Trigger trigger);

protected abstract void emitMetricsOnMatchingPipeline(Pipeline pipeline);

protected void onMatchingPipeline(Pipeline pipeline) {
log.info("Found matching pipeline {}:{}", pipeline.getApplication(), pipeline.getName());
emitMetricsOnMatchingPipeline(pipeline);
}

protected void onEventProcessed(final TriggerEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ protected Predicate<Trigger> matchTriggerFor(final TriggerEvent event, final Pip
ArtifactMatcher.anyArtifactsMatchExpected(messageArtifacts, trigger, pipeline);
}

protected void onMatchingPipeline(Pipeline pipeline) {
super.onMatchingPipeline(pipeline);
@Override
protected void emitMetricsOnMatchingPipeline(Pipeline pipeline) {
val id = registry.createId("pipelines.triggered")
.withTag("application", pipeline.getApplication())
.withTag("name", pipeline.getName());
Expand Down

0 comments on commit 393f1a6

Please sign in to comment.