-
Notifications
You must be signed in to change notification settings - Fork 643
Addition of metrics to track when self-healing started/ended #2268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ShubhamRwt
wants to merge
3
commits into
linkedin:main
Choose a base branch
from
ShubhamRwt:newMetrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| package com.linkedin.kafka.cruisecontrol.detector; | ||
|
|
||
| import com.codahale.metrics.Counter; | ||
| import com.codahale.metrics.Gauge; | ||
| import com.codahale.metrics.Meter; | ||
| import com.codahale.metrics.MetricRegistry; | ||
|
|
@@ -81,6 +82,8 @@ public class AnomalyDetectorState { | |
| private double _balancednessScore; | ||
| private boolean _hasUnfixableGoals; | ||
| private final Map<AnomalyType, Timer> _anomalyDetectToFixCompleteTimer; | ||
| private final Map<AnomalyType, Counter> _numSelfHealingStartedPerAnomaly; | ||
| private final Map<AnomalyType, Counter> _numSelfHealingEndedPerAnomaly; | ||
|
|
||
| public AnomalyDetectorState(Time time, | ||
| AnomalyNotifier anomalyNotifier, | ||
|
|
@@ -105,6 +108,8 @@ protected boolean removeEldestEntry(Map.Entry<String, AnomalyState> eldest) { | |
| _ongoingAnomalyDurationSumForAverageMs = 0; | ||
| _numSelfHealingStarted = new AtomicLong(0L); | ||
| _numSelfHealingFailedToStart = new AtomicLong(0L); | ||
| _numSelfHealingStartedPerAnomaly = new HashMap<>(); | ||
| _numSelfHealingEndedPerAnomaly = new HashMap<>(); | ||
|
|
||
| Map<AnomalyType, Double> meanTimeBetweenAnomaliesMs = new HashMap<>(); | ||
| for (AnomalyType anomalyType : KafkaAnomalyType.cachedValues()) { | ||
|
|
@@ -141,6 +146,14 @@ protected boolean removeEldestEntry(Map.Entry<String, AnomalyState> eldest) { | |
| Timer timer = dropwizardMetricRegistry.timer( | ||
| MetricRegistry.name(ANOMALY_DETECTOR_SENSOR, String.format("%s-detect-to-fix-complete-timer", anomalyType.toString().toLowerCase()))); | ||
| _anomalyDetectToFixCompleteTimer.put(anomalyType, timer); | ||
|
|
||
| Counter counter = dropwizardMetricRegistry.counter( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these Same with |
||
| MetricRegistry.name(ANOMALY_DETECTOR_SENSOR, String.format("num-of-self-healing-started-for-%s", anomalyType.toString().toLowerCase()))); | ||
| _numSelfHealingStartedPerAnomaly.put(anomalyType, counter); | ||
|
|
||
| Counter counter1 = dropwizardMetricRegistry.counter( | ||
| MetricRegistry.name(ANOMALY_DETECTOR_SENSOR, String.format("num-of-self-healing-ended-for-%s", anomalyType.toString().toLowerCase()))); | ||
| _numSelfHealingEndedPerAnomaly.put(anomalyType, counter1); | ||
| } | ||
| } else { | ||
| _anomalyRateByType = new HashMap<>(); | ||
|
|
@@ -259,9 +272,21 @@ long numSelfHealingStarted() { | |
|
|
||
| /** | ||
| * Increment the number of self healing actions started successfully. | ||
| * | ||
| * @param anomalyType Type of anomaly | ||
| */ | ||
| void incrementNumSelfHealingStarted() { | ||
| void incrementNumSelfHealingStarted(AnomalyType anomalyType) { | ||
| _numSelfHealingStarted.incrementAndGet(); | ||
| _numSelfHealingStartedPerAnomaly.get(anomalyType).inc(); | ||
| } | ||
|
|
||
| /** | ||
| * Increment the number of self healing actions ended successfully per anomaly. | ||
| * | ||
| * @param anomalyType Type of anomaly | ||
| */ | ||
| void incrementNumSelfHealingEndedPerAnomaly(AnomalyType anomalyType) { | ||
| _numSelfHealingEndedPerAnomaly.get(anomalyType).inc(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -309,6 +334,7 @@ public synchronized void markSelfHealingFinished(String anomalyId, boolean compl | |
| // Time the duration if the self-healing is completed successfully. | ||
| // completeWithError is true if the proposal execution is interrupted (receive stop signal) or encountered exception. | ||
| // execution-stopped metrics track the number of stopped execution. | ||
| incrementNumSelfHealingEndedPerAnomaly(_ongoingSelfHealingAnomaly.anomalyType()); | ||
| _anomalyDetectToFixCompleteTimer.get(_ongoingSelfHealingAnomaly.anomalyType()).update(totalTime, TimeUnit.MILLISECONDS); | ||
| } | ||
| _ongoingSelfHealingAnomaly = null; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to do anything in the
refreshMetricsmethod to reset these maps? There seems to be anumSelfHealingStarted()call in there as part of creating a newAnomalyMetricsinstance.I don't know if that is relevant but you should check if these maps need to be reset.