-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor error budget to use factory (#1393)
commit-id:cc3ae706
- Loading branch information
1 parent
443a627
commit acc89d5
Showing
10 changed files
with
68 additions
and
94 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
deploy-service/common/src/main/java/com/pinterest/deployservice/metrics/MeterConstants.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...al/src/main/java/com/pinterest/teletraan/universal/metrics/ErrorBudgetCounterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.pinterest.teletraan.universal.metrics; | ||
|
||
import static com.pinterest.teletraan.universal.metrics.micrometer.PinStatsNamingConvention.CUSTOM_NAME_PREFIX; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
|
||
public class ErrorBudgetCounterFactory { | ||
|
||
public final static String ERROR_BUDGET_METRIC_NAME = CUSTOM_NAME_PREFIX + "error-budget.counters"; | ||
public final static String ERROR_BUDGET_TAG_NAME_METHOD_NAME = "method_name"; | ||
public final static String ERROR_BUDGET_TAG_NAME_RESPONSE_TYPE = "response_type"; | ||
public final static String ERROR_BUDGET_TAG_VALUE_RESPONSE_TYPE_SUCCESS = "success"; | ||
public final static String ERROR_BUDGET_TAG_VALUE_RESPONSE_TYPE_FAILURE = "failure"; | ||
|
||
private ErrorBudgetCounterFactory() {} | ||
|
||
public static Counter createCounter(MeterRegistry registry, String methodName, boolean success) { | ||
return Counter.builder(ERROR_BUDGET_METRIC_NAME) | ||
.tag( | ||
ERROR_BUDGET_TAG_NAME_RESPONSE_TYPE, | ||
success | ||
? ERROR_BUDGET_TAG_VALUE_RESPONSE_TYPE_SUCCESS | ||
: ERROR_BUDGET_TAG_VALUE_RESPONSE_TYPE_FAILURE) | ||
.tag(ERROR_BUDGET_TAG_NAME_METHOD_NAME, methodName) | ||
.register(registry); | ||
} | ||
|
||
public static Counter createSuccessCounter(String methodName) { | ||
return createCounter(io.micrometer.core.instrument.Metrics.globalRegistry, methodName, true); | ||
} | ||
|
||
public static Counter createFailureCounter(String methodName) { | ||
return createCounter(io.micrometer.core.instrument.Metrics.globalRegistry, methodName, false); | ||
} | ||
} |