Skip to content

Commit

Permalink
Update judge results (#46)
Browse files Browse the repository at this point in the history
Return more than a float. Add scala framework for Netflix judge.
  • Loading branch information
Michael Graff committed Jun 28, 2017
1 parent 900deb9 commit e13bb5e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@

package com.netflix.kayenta.canary;

import com.netflix.kayenta.canary.results.CanaryJudgeResult;
import com.netflix.kayenta.metrics.MetricSetPair;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Random;

@Component
// TODO(duftler): Make the canary judge a pluggable component.
public class CanaryJudge {
private Random random = new Random();

public float judge(CanaryConfig canaryConfig, List<MetricSetPair> metricSetPairList) {
// TODO: "You're the judge; so judge!"
return random.nextFloat() * 100;
}
public interface CanaryJudge {
CanaryJudgeResult judge(CanaryConfig canaryConfig, List<MetricSetPair> metricSetPairList);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2017 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.kayenta.canary;

import com.netflix.kayenta.canary.results.CanaryJudgeResult;
import com.netflix.kayenta.canary.results.CanaryJudgeScore;
import com.netflix.kayenta.metrics.MetricSetPair;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Random;

@Component
// TODO(duftler): Make the canary judge a pluggable component.
// TODO(mgraff, or duftler): move to its own subproject once it's pluggable.
public class CanaryJudgeDummy implements CanaryJudge {
private Random random = new Random();

@Override
public CanaryJudgeResult judge(CanaryConfig canaryConfig, List<MetricSetPair> metricSetPairList) {
// TODO: "You're the judge; so judge!"

CanaryJudgeScore score = CanaryJudgeScore.builder().score(random.nextDouble() * 100).build();
CanaryJudgeResult result = CanaryJudgeResult.builder().score(score).build();
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.netflix.kayenta.canary.CanaryConfig;
import com.netflix.kayenta.canary.CanaryJudge;
import com.netflix.kayenta.canary.results.CanaryJudgeResult;
import com.netflix.kayenta.metrics.MetricSetPair;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
Expand Down Expand Up @@ -77,8 +78,8 @@ public TaskResult execute(Stage stage) {

CanaryConfig canaryConfig = storageService.loadObject(resolvedAccountName, ObjectType.CANARY_CONFIG, canaryConfigId.toLowerCase());
List<MetricSetPair> metricSetPairList = storageService.loadObject(resolvedAccountName, ObjectType.METRIC_SET_PAIR_LIST, metricSetPairListId);
float canaryScore = canaryJudge.judge(canaryConfig, metricSetPairList);
Map outputs = Collections.singletonMap("canaryScore", canaryScore);
CanaryJudgeResult result = canaryJudge.judge(canaryConfig, metricSetPairList);
Map<String, CanaryJudgeResult> outputs = Collections.singletonMap("result", result);

return new TaskResult(ExecutionStatus.SUCCEEDED, outputs);
}
Expand Down
8 changes: 8 additions & 0 deletions kayenta-judge-netflix/kayenta-judge-netflix.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
apply plugin: 'scala'

dependencies {
compile project(":kayenta-core")

// compile spinnaker.dependency('lombok')
compile "org.projectlombok:lombok:1.16.10"

// scala support
compile 'org.scala-lang:scala-library-all:2.12.2'
compile 'org.scala-lang:scala-reflect:2.12.2'
compile 'com.typesafe.scala-logging:scala-logging_2.12:3.5.0'
testCompile 'org.scalatest:scalatest_2.12'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2017 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.kayenta.judge.netflix

import java.util

import com.netflix.kayenta.canary.results.CanaryJudgeResult
import com.netflix.kayenta.canary.{CanaryConfig, CanaryJudge}
import com.netflix.kayenta.metrics.MetricSetPair

class NetflixJudge extends CanaryJudge {
override def judge(canaryConfig: CanaryConfig, metricSetPairList: util.List[MetricSetPair]): CanaryJudgeResult = {
val result = CanaryJudgeResult.builder().build()
result
}
}

0 comments on commit e13bb5e

Please sign in to comment.