Skip to content

Commit

Permalink
Merge pull request #240 from GetFeedback/fix/rename-metric-prefix
Browse files Browse the repository at this point in the history
Rename metric prefix
  • Loading branch information
Stefano Guerrini authored Oct 24, 2022
2 parents eefb4c6 + fa09531 commit d0ced42
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class StepMetricUtils {

private static final String KAHPP_METRIC_PREFIX = "kahppMetricPrefix";
private static final String KAHPP_METRIC_PREFIX = "kahpp";
private static final String METRIC_TAG_STEP_CLASS = "step";
private static final String METRIC_TAG_STEP_NAME = "step_name";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void assertKahppFilterEvaluationMetric(double actual, boolean forwarded)
assertThat(actual)
.isEqualTo(
meterRegistry
.get("kahppMetricPrefix.filter")
.get("kahpp.filter")
.tag("step", "FilterValue")
.tag("step_name", "keepUnsupportedProducts")
.tag("forwarded", Boolean.toString(forwarded))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void assertKahppFilterEvaluationMetric(double actual, boolean forwarded)
assertThat(actual)
.isEqualTo(
meterRegistry
.get("kahppMetricPrefix.filter")
.get("kahpp.filter")
.tag("step", "FilterValue")
.tag("step_name", "getSupportedProducts")
.tag("forwarded", Boolean.toString(forwarded))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void trueEvaluationForFilterResultsInNoRecordsProduced() {
private void assertFilterTombstoneMetric(double expected, boolean forwarded) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.filter")
.get("kahpp.filter")
.tag("step", "FilterTombstone")
.tag("step_name", "dropTombstoneRecords")
.tag("forwarded", Boolean.toString(forwarded))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void httpDurationMetricsWithSuccessfulTagAreCreated() {
private void assertTimeMetric(boolean successful, long expected) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.http.duration")
.get("kahpp.http.duration")
.tag("step", "OkOrProduceError")
.tag("step_name", "doAnAPICall")
.tag("successful", Boolean.toString(successful))
Expand All @@ -92,7 +92,7 @@ private void assertTimeMetric(boolean successful, long expected) {
private void assertStepMetricsCount(double expected, boolean successful) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.http.status")
.get("kahpp.http.status")
.tag("step", "OkOrProduceError")
.tag("step_name", "doAnAPICall")
.tag("successful", Boolean.toString(successful))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

final class MeterTest extends AbstractKaHPPTest {

private static final String METRIC_COLLECTION_PER_CHANNEL =
"kahppMetricPrefix.collectionPerChannel";
private static final String METRIC_COLLECTION_PER_CHANNEL = "kahpp.collectionPerChannel";

@Autowired private transient MeterRegistry meterRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void testTimerMetric() {

private Double getProduceCountOnTopic(String topic) {
return meterRegistry
.get("kahppMetricPrefix.produce")
.get("kahpp.produce")
.tag("step_name", STEP_NAME)
.tag("topic", topic)
.counter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private KaHPPRecord createRecord(int delayMillis, boolean success) {

private Timer getTimerMetric(boolean successful) {
return meterRegistry
.get("kahppMetricPrefix.http.duration")
.get("kahpp.http.duration")
.tag("step", HTTP_STEP_CLASS)
.tag("step_name", HTTP_STEP_NAME)
.tag("successful", Boolean.toString(successful))
Expand All @@ -161,7 +161,7 @@ private Timer getTimerMetric(boolean successful) {

private DistributionSummary getDistributionSummary() {
return meterRegistry
.get("kahppMetricPrefix.http.response_time_ms")
.get("kahpp.http.response_time_ms")
.tag("step", HTTP_STEP_CLASS)
.tag("step_name", HTTP_STEP_NAME)
.tag("successful", Boolean.toString(true))
Expand All @@ -182,7 +182,7 @@ private void assertDistributionSummaryBucket(double requestTimeMillis, double ex
private void assertCountStatus(double expected, boolean successful) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.http.status")
.get("kahpp.http.status")
.tag("step", HTTP_STEP_CLASS)
.tag("step_name", HTTP_STEP_NAME)
.tag("successful", Boolean.toString(successful))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void forwardCountShouldIncrementAccordingToRecordOutcome() {
private void assertCountForward(int expected, boolean forwarded) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.forward")
.get("kahpp.forward")
.tag(STEP_NAME, "SimpleStep")
.tag("step_name", STEP_NAME)
.tag("forwarded", Boolean.toString(forwarded))
Expand Down Expand Up @@ -133,7 +133,7 @@ void produceCountShouldIncrementWhenForwardToProduceStepIsCalled() {
private void assertCountProduce(int expected) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.produce")
.get("kahpp.produce")
.tag(STEP_NAME, "SimpleProduceStep")
.tag("step_name", STEP_NAME)
.tag("topic", "mock")
Expand Down Expand Up @@ -206,7 +206,7 @@ void shouldTerminateWhenConditionIsSatisfied() {
private void assertCountConditional(int expected) {
assertThat(
meterRegistry
.get("kahppMetricPrefix.conditional_skip")
.get("kahpp.conditional_skip")
.tag(STEP_NAME, "SimpleConditional")
.tag("step_name", STEP_NAME)
.counters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ public boolean shouldForwardRecordOnError() {

@Test
void formatMetricName() {
assertThat(StepMetricUtils.formatMetricName("awesome")).isEqualTo("kahppMetricPrefix.awesome");
assertThat(StepMetricUtils.formatMetricName("awesome")).isEqualTo("kahpp.awesome");

assertThat(StepMetricUtils.formatMetricName(httpCall)).isEqualTo("kahppMetricPrefix.http");
assertThat(StepMetricUtils.formatMetricName(predicateBranch))
.isEqualTo("kahppMetricPrefix.filter");
assertThat(StepMetricUtils.formatMetricName(httpCall)).isEqualTo("kahpp.http");
assertThat(StepMetricUtils.formatMetricName(predicateBranch)).isEqualTo("kahpp.filter");

assertThat(StepMetricUtils.formatMetricName(httpCall, "last"))
.isEqualTo("kahppMetricPrefix.http.last");
assertThat(StepMetricUtils.formatMetricName(httpCall, "last")).isEqualTo("kahpp.http.last");
assertThat(StepMetricUtils.formatMetricName(predicateBranch, "last"))
.isEqualTo("kahppMetricPrefix.filter.last");
.isEqualTo("kahpp.filter.last");

assertThatThrownBy(() -> StepMetricUtils.formatMetricName(() -> "notMapped"))
.isInstanceOf(RuntimeException.class);
Expand Down

0 comments on commit d0ced42

Please sign in to comment.