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

Micrometer histos #3854

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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 @@ -201,7 +201,7 @@ private static boolean serializeTimer(JsonWriter jw, HistogramSnapshot histogram
serializeValue(id, ".count", count, jw, replaceBuilder, dedotMetricName);
jw.writeByte(JsonWriter.COMMA);
serializeValue(id, ".sum.us", totalTime, jw, replaceBuilder, dedotMetricName);
if (histogramSnapshot != null && histogramSnapshot.histogramCounts().length > 0) {
if (histogramSnapshot != null && logHistoLength(histogramSnapshot.histogramCounts().length) > 0) {
jw.writeByte(JsonWriter.COMMA);
serializeHistogram(id, histogramSnapshot, jw, replaceBuilder, dedotMetricName);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ private static boolean serializeDistributionSummary(JsonWriter jw, HistogramSnap
serializeValue(id, ".count", count, jw, replaceBuilder, dedotMetricName);
jw.writeByte(JsonWriter.COMMA);
serializeValue(id, ".sum", totalAmount, jw, replaceBuilder, dedotMetricName);
if (histogramSnapshot != null && histogramSnapshot.histogramCounts().length > 0) {
if (histogramSnapshot != null && logHistoLength(histogramSnapshot.histogramCounts().length) > 0) {
jw.writeByte(JsonWriter.COMMA);
serializeHistogram(id, histogramSnapshot, jw, replaceBuilder, dedotMetricName);
}
Expand All @@ -238,12 +238,21 @@ private static boolean serializeDistributionSummary(JsonWriter jw, HistogramSnap
return hasValue;
}

private static int logHistoLength(int length){
logger.debug("Histogram length1: {}", length);
return length;
}

private static void serializeHistogram(Meter.Id id, HistogramSnapshot histogramSnapshot, JsonWriter jw, StringBuilder replaceBuilder, boolean dedotMetricName) {
if (histogramSnapshot == null) {
return;
}
String suffix = ".histogram";
CountAtBucket[] bucket = histogramSnapshot.histogramCounts();
logger.debug("Histogram length2: {}", bucket.length);
if (bucket.length == 0) {
return;
}
serializeObjectStart(id.getName(), "values", suffix, jw, replaceBuilder, dedotMetricName);
jw.writeByte(JsonWriter.ARRAY_START);
if (bucket.length > 0) {
Expand Down