Skip to content

Commit

Permalink
remove canaryScope and require metrics to have scope names (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Graff committed Dec 21, 2017
1 parent 3b4882b commit 563566a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,14 @@

@Data
public class CanaryExecutionRequest {
protected Map<String, CanaryScopePair> scopes;

@NotNull
protected CanaryScope experimentScope;

@NotNull
protected CanaryScope controlScope;
protected Map<String, CanaryScopePair> scopes;

protected CanaryClassifierThresholdsConfig thresholds;

public Duration calculateDuration() {
Set<Duration> durationsFound = new HashSet<>();

if (experimentScope != null) {
durationsFound.add(experimentScope.calculateDuration());
}
if (controlScope != null) {
durationsFound.add(controlScope.calculateDuration());
}
if (scopes != null) {
scopes.values().forEach(scope -> {
durationsFound.add(scope.controlScope.calculateDuration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ private CanaryScopeFactory getScopeFactoryForServiceType(String serviceType) {
}

private CanaryScope getScopeForNamedScope(CanaryExecutionRequest executionRequest, String scopeName, boolean isCanary) {
if (scopeName == null) {
return isCanary ? executionRequest.getExperimentScope() : executionRequest.getControlScope();
}

CanaryScopePair canaryScopePair = executionRequest.getScopes().get(scopeName);
CanaryScope canaryScope = isCanary ? canaryScopePair.getExperimentScope() : canaryScopePair.getControlScope();
if (canaryScope == null) {
Expand All @@ -338,6 +334,9 @@ private List<Map<String, Object>> generateFetchScopes(CanaryConfig canaryConfig,
CanaryMetricConfig metric = canaryConfig.getMetrics().get(index);
String serviceType = metric.getQuery().getServiceType();
CanaryScopeFactory canaryScopeFactory = getScopeFactoryForServiceType(serviceType);
if (metric.getScopeName() == null) {
throw new IllegalArgumentException("Canary scope for metric named '" + metric.getName() + "' is null.");
}
CanaryScope inspecificScope = getScopeForNamedScope(executionRequest, metric.getScopeName(), isCanary);
CanaryScope scopeModel = canaryScopeFactory.buildCanaryScope(inspecificScope);
String stagePrefix = (isCanary ? REFID_FETCH_EXPERIMENT_PREFIX : REFID_FETCH_CONTROL_PREFIX);
Expand Down

0 comments on commit 563566a

Please sign in to comment.