-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from LGouellec/feature/197
Feature/197 - Caching state store
- Loading branch information
Showing
128 changed files
with
5,453 additions
and
708 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using Streamiz.Kafka.Net.Processors.Internal; | ||
|
||
namespace Streamiz.Kafka.Net.Metrics.Internal | ||
{ | ||
internal class CachingMetrics | ||
{ | ||
internal static string CACHE_SIZE_BYTES_TOTAL = "cache-size-bytes-total"; | ||
private static string CACHE_SIZE_BYTES_TOTAL_DESCRIPTION = "The total size in bytes of this cache state store."; | ||
|
||
internal static string HIT_RATIO = "hit-ratio"; | ||
private static string HIT_RATIO_DESCRIPTION = "The hit ratio defined as the ratio of cache read hits over the total cache read requests."; | ||
private static string HIT_RATIO_AVG_DESCRIPTION = "The average cache hit ratio"; | ||
private static string HIT_RATIO_MIN_DESCRIPTION = "The minimum cache hit ratio"; | ||
private static string HIT_RATIO_MAX_DESCRIPTION = "The maximum cache hit ratio"; | ||
|
||
public static Sensor HitRatioSensor( | ||
TaskId taskId, | ||
string storeType, | ||
string storeName, | ||
StreamMetricsRegistry streamsMetrics) { | ||
|
||
Sensor sensor; | ||
string hitMetricName = HIT_RATIO; | ||
IDictionary<string, string> tags = | ||
streamsMetrics.StoreLevelTags(GetThreadId(), taskId.ToString(), storeName, storeType); | ||
|
||
sensor = streamsMetrics.StoreLevelSensor(GetThreadId(), taskId, storeName, hitMetricName, HIT_RATIO_DESCRIPTION, MetricsRecordingLevel.DEBUG); | ||
|
||
SensorHelper.AddAvgAndMinAndMaxToSensor( | ||
sensor, | ||
StreamMetricsRegistry.STATE_STORE_LEVEL_GROUP, | ||
tags, | ||
hitMetricName, | ||
HIT_RATIO_AVG_DESCRIPTION, | ||
HIT_RATIO_MAX_DESCRIPTION, | ||
HIT_RATIO_MIN_DESCRIPTION); | ||
|
||
return sensor; | ||
} | ||
|
||
public static Sensor TotalCacheSizeBytesSensor( | ||
TaskId taskId, | ||
string storeType, | ||
string storeName, | ||
StreamMetricsRegistry streamsMetrics) { | ||
|
||
Sensor sensor; | ||
string totalCacheMetricName = CACHE_SIZE_BYTES_TOTAL; | ||
IDictionary<string, string> tags = | ||
streamsMetrics.StoreLevelTags(GetThreadId(), taskId.ToString(), storeName, storeType); | ||
|
||
sensor = streamsMetrics.StoreLevelSensor(GetThreadId(), taskId, storeName, totalCacheMetricName, CACHE_SIZE_BYTES_TOTAL_DESCRIPTION, MetricsRecordingLevel.DEBUG); | ||
|
||
SensorHelper.AddValueMetricToSensor( | ||
sensor, | ||
StreamMetricsRegistry.STATE_STORE_LEVEL_GROUP, | ||
tags, | ||
totalCacheMetricName, | ||
CACHE_SIZE_BYTES_TOTAL_DESCRIPTION); | ||
|
||
return sensor; | ||
} | ||
|
||
private static string GetThreadId() => Thread.CurrentThread.Name; | ||
} | ||
} |
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
Oops, something went wrong.