Skip to content
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

feat: add entity count distribution #107

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
public class MonitoringConfig {
record TimerConfig(List<Double> percentiles, Integer minBucketMs, Integer maxBucketMs) {}

record EntityCountDistributionConfig(List<Double> percentiles, Integer maxExpectedCount) {}

private TimerConfig timer;
private EntityCountDistributionConfig entityCountDistribution;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.caraml.store.protobuf.serving.ServingServiceProto.GetOnlineFeaturesRequest;
import io.grpc.Status;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.DistributionSummary;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import java.time.Duration;
Expand Down Expand Up @@ -61,6 +62,24 @@ private List<Counter> newEntityCounters(GetOnlineFeaturesRequest featureRequest)
.toList();
}

private List<DistributionSummary> newEntityCountHistograms(
GetOnlineFeaturesRequest featureRequest) {
return featureRequest.getFeaturesList().stream()
.map(FeatureReference::getFeatureTable)
.distinct()
.map(
table ->
DistributionSummary.builder("caraml_serving_entity_count_histogram")
.tag("project", featureRequest.getProject())
.tag("feature_table", table)
.publishPercentiles(
config.getEntityCountDistribution().percentiles().stream()
.mapToDouble(Double::doubleValue)
.toArray())
.register(registry))
.toList();
}

private Counter newKeyRetrievalCounter(String project) {
return Counter.builder("caraml_serving_key_retrieval_count")
.tag("project", project)
Expand All @@ -75,6 +94,8 @@ public void onRequestReceived(ReqT requestMessage) {
newKeyRetrievalCounter(project).increment(featureRequest.getEntityRowsCount());
newEntityCounters(featureRequest)
.forEach(counter -> counter.increment(featureRequest.getEntityRowsCount()));
newEntityCountHistograms(featureRequest)
.forEach(histogram -> histogram.record(featureRequest.getEntityRowsCount()));
}
}

Expand Down
8 changes: 8 additions & 0 deletions caraml-store-serving/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ caraml:
minBucketMs: 1
# Maximum expected latency
maxBucketMs: 200
entityCountDistribution:
# Published percentiles
percentiles:
- 0.5
- 0.95
- 0.99
# Maximum expected entity count
maxExpectedCount: 150

store:
# Active store. Possible values: [redisCluster, redis, bigtable]
Expand Down