Skip to content

Commit

Permalink
fix(#18): corrected thresholds and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
novoj committed May 26, 2024
1 parent e0aeb42 commit 98c1673
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
@Name(AbstractQueryEvent.PACKAGE_NAME + ".Finished")
@Description("Event that is fired when a query is finished.")
@Label("Catalog finished")
@HistogramSettings(factor = 1.26, count = 40)
@ExportInvocationMetric(label = "Query finished")
@ExportDurationMetric(label = "Query duration in milliseconds")
@Getter
Expand All @@ -55,23 +56,25 @@ public class FinishedEvent extends AbstractQueryEvent {

@Label("Query planning duration in milliseconds")
@ExportMetric(metricType = MetricType.HISTOGRAM)
@HistogramSettings(factor = 1.9)
private long planDurationMilliseconds;

@Label("Query execution duration in milliseconds")
@ExportMetric(metricType = MetricType.HISTOGRAM)
@HistogramSettings(factor = 1.9)
private long executionDurationMilliseconds;

@Label("Prefetched vs. non-prefetched query")
@ExportMetricLabel
private String prefetched;

@Label("Records scanned total")
@HistogramSettings(unit = "records", factor = 2.5)
@HistogramSettings(unit = "records", factor = 4)
@ExportMetric(metricType = MetricType.HISTOGRAM)
private int recordsScanned;

@Label("Records returned total")
@HistogramSettings(unit = "records", factor = 2.5)
@HistogramSettings(unit = "records", factor = 1.9)
@ExportMetric(metricType = MetricType.HISTOGRAM)
private int recordsReturned;

Expand All @@ -81,7 +84,7 @@ public class FinishedEvent extends AbstractQueryEvent {
private int recordsFound;

@Label("Records fetched total")
@HistogramSettings(unit = "records", factor = 2.5)
@HistogramSettings(unit = "records", factor = 1.9)
@ExportMetric(metricType = MetricType.HISTOGRAM)
private int recordsFetched;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.evitadb.api.observability.annotation.ExportDurationMetric;
import io.evitadb.api.observability.annotation.ExportInvocationMetric;
import io.evitadb.api.observability.annotation.ExportMetric;
import io.evitadb.api.observability.annotation.HistogramSettings;
import jdk.jfr.Description;
import jdk.jfr.Label;
import jdk.jfr.Name;
Expand All @@ -42,16 +43,19 @@
@Name(AbstractSessionEvent.PACKAGE_NAME + ".SessionClosed")
@Description("Event that is fired when a session is closed.")
@ExportInvocationMetric(label = "Sessions closed")
@HistogramSettings(factor = 2.6, count = 20)
@ExportDurationMetric(label = "Session lifespan duration in milliseconds")
@Label("Session closed")
@Getter
public class ClosedEvent extends AbstractSessionEvent {
@Label("Number of queries performed in session")
@HistogramSettings(unit = "")
@ExportMetric(metricType = MetricType.HISTOGRAM)
private int queries;

@Label("Number of mutation calls performed in session")
@ExportMetric(metricType = MetricType.HISTOGRAM)
@HistogramSettings(unit = "")
private int mutations;

@Label("Oldest session timestamp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,15 @@ private static Metric buildAndRegisterMetric(@Nonnull LoggedMetric metric, @Nonn
final Builder builder = Histogram.builder()
.name(name);
ofNullable(metric.histogramSettings())
.ifPresent(settings -> {
builder.classicExponentialUpperBounds(settings.start(), settings.factor(), settings.count())
.unit(new Unit(settings.unit()));
});
.ifPresentOrElse(
settings -> {
builder.classicExponentialUpperBounds(settings.start(), settings.factor(), settings.count());
if (!settings.unit().isBlank()) {
builder.unit(new Unit(settings.unit()));
}
},
() -> builder.classicExponentialUpperBounds(1, 2.0, 14)
.unit(new Unit("milliseconds")));
yield builder
.labelNames(metric.labels())
.help(metric.helpMessage())
Expand Down

0 comments on commit 98c1673

Please sign in to comment.