Skip to content

Commit

Permalink
feat: revert pre-hook and just allow for disabling default archivers …
Browse files Browse the repository at this point in the history
…so that extentions can just override them (#839)
  • Loading branch information
fieldju authored Mar 20, 2021
1 parent f02ff27 commit 7a7acb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.common.collect.ImmutableList;
import com.netflix.kayenta.atlas.config.KayentaSerializationConfigurationProperties;
import com.netflix.kayenta.canary.CanaryMetricSetQueryConfig;
import com.netflix.kayenta.events.CanaryExecutionCompletedEvent;
import com.netflix.kayenta.metrics.MapBackedMetricsServiceRepository;
import com.netflix.kayenta.metrics.MetricSetMixerService;
import com.netflix.kayenta.metrics.MetricsRetryConfigurationProperties;
Expand All @@ -40,10 +39,8 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down Expand Up @@ -73,12 +70,6 @@ AccountCredentialsRepository accountCredentialsRepository() {
return new MapBackedAccountCredentialsRepository();
}

@Bean
@Qualifier("pre-canary-execution-archive-hook")
Consumer<CanaryExecutionCompletedEvent> preCanaryArchiveHook() {
return (event) -> log.debug("no-op pre-canary execution archive hook");
}

@Bean
@ConditionalOnMissingBean(MetricsServiceRepository.class)
MetricsServiceRepository metricsServiceRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ import com.netflix.kayenta.security.AccountCredentials
import com.netflix.kayenta.security.AccountCredentialsRepository
import com.netflix.kayenta.storage.ObjectType
import com.netflix.kayenta.storage.StorageServiceRepository
import java.util.function.Consumer
import org.slf4j.Logger
import org.slf4j.LoggerFactory.getLogger
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component

@ConditionalOnProperty(name = ["kayenta.default-archivers.enabled"], havingValue = "true", matchIfMissing = true)
@Component
class ExecutionArchivalListener(
private val accountCredentialsRepository: AccountCredentialsRepository,
private val storageServiceRepository: StorageServiceRepository,
@Qualifier("pre-canary-execution-archive-hook")
private val preCanaryArchiveHook: Consumer<CanaryExecutionCompletedEvent>
private val storageServiceRepository: StorageServiceRepository
) {

init {
Expand All @@ -42,7 +40,6 @@ class ExecutionArchivalListener(

@EventListener
fun onApplicationEvent(event: CanaryExecutionCompletedEvent) {
preCanaryArchiveHook.accept(event)
val response = event.canaryExecutionStatusResponse
val storageAccountName = response.storageAccountName
if (storageAccountName != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,13 @@

package com.netflix.kayenta.standalonecanaryanalysis.config;

import com.netflix.kayenta.standalonecanaryanalysis.event.StandaloneCanaryAnalysisExecutionCompletedEvent;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty("kayenta.standalone-canary-analysis.enabled")
@ComponentScan({"com.netflix.kayenta.standalonecanaryanalysis"})
@Slf4j
public class StandaloneCanaryAnalysisModuleConfiguration {
@Bean
@Qualifier("pre-scape-archive-hook")
Consumer<StandaloneCanaryAnalysisExecutionCompletedEvent> preScapeArchiveHook() {
return (event) -> log.debug("no-op pre-SCAPE archive hook");
}
}
public class StandaloneCanaryAnalysisModuleConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,33 @@
import com.netflix.kayenta.standalonecanaryanalysis.storage.StandaloneCanaryAnalysisObjectType;
import com.netflix.kayenta.storage.StorageServiceRepository;
import java.util.Optional;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@ConditionalOnProperty(
name = "kayenta.default-archivers.enabled",
havingValue = "true",
matchIfMissing = true)
public class StandaloneCanaryAnalysisExecutionArchivalListener {

private final AccountCredentialsRepository accountCredentialsRepository;
private final StorageServiceRepository storageServiceRepository;
private final Consumer<StandaloneCanaryAnalysisExecutionCompletedEvent> preScapeArchiveHook;

@Autowired
public StandaloneCanaryAnalysisExecutionArchivalListener(
AccountCredentialsRepository accountCredentialsRepository,
StorageServiceRepository storageServiceRepository,
@Qualifier("pre-scape-archive-hook")
Consumer<StandaloneCanaryAnalysisExecutionCompletedEvent> preScapeArchiveHook) {
StorageServiceRepository storageServiceRepository) {
this.accountCredentialsRepository = accountCredentialsRepository;
this.storageServiceRepository = storageServiceRepository;
this.preScapeArchiveHook = preScapeArchiveHook;
}

@EventListener
public void onApplicationEvent(StandaloneCanaryAnalysisExecutionCompletedEvent event) {
preScapeArchiveHook.accept(event);
var response = event.getCanaryAnalysisExecutionStatusResponse();

Optional.ofNullable(response.getStorageAccountName())
Expand Down

0 comments on commit 7a7acb0

Please sign in to comment.