-
Notifications
You must be signed in to change notification settings - Fork 525
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
[Bug] HStore JRaft Timer Metrics Error #2601
Comments
To address the issue of not serializing all Timer metrics correctly, you need to ensure that the Here is the private static class TimerSerializer extends StdSerializer<Timer> {
private static final long serialVersionUID = 6283520188524929099L;
private final String rateUnit;
private final double rateFactor;
private final String durationUnit;
private final double durationFactor;
private final boolean showSamples;
private TimerSerializer(TimeUnit rateUnit, TimeUnit durationUnit,
boolean showSamples) {
super(Timer.class);
this.rateUnit = calculateRateUnit(rateUnit, "calls");
this.rateFactor = rateUnit.toSeconds(1);
this.durationUnit = durationUnit.toString().toLowerCase(Locale.US);
this.durationFactor = 1.0 / durationUnit.toNanos(1);
this.showSamples = showSamples;
}
@Override
public void serialize(Timer timer, JsonGenerator json,
SerializerProvider provider) throws IOException {
json.writeStartObject();
final Snapshot snapshot = timer.getSnapshot();
json.writeNumberField("count", timer.getCount());
json.writeNumberField("min", snapshot.getMin() * this.durationFactor);
json.writeNumberField("mean", snapshot.getMean() * this.durationFactor);
json.writeNumberField("max", snapshot.getMax() * this.durationFactor);
json.writeNumberField("stddev", snapshot.getStdDev() * this.durationFactor);
json.writeNumberField("p50", snapshot.getMedian() * this.durationFactor);
json.writeNumberField("p75", snapshot.get75thPercentile() * this.durationFactor);
json.writeNumberField("p95", snapshot.get95thPercentile() * this.durationFactor);
json.writeNumberField("p98", snapshot.get98thPercentile() * this.durationFactor);
json.writeNumberField("p99", snapshot.get99thPercentile() * this.durationFactor);
json.writeNumberField("p999", snapshot.get999thPercentile() * this.durationFactor);
json.writeStringField("duration_unit", this.durationUnit);
if (this.showSamples) {
final long[] values = snapshot.getValues();
final double[] scaledValues = new double[values.length];
for (int i = 0; i < values.length; i++) {
scaledValues[i] = values[i] * this.durationFactor;
}
json.writeObjectField("values", scaledValues);
}
json.writeNumberField("mean_rate", timer.getMeanRate() * this.rateFactor);
json.writeNumberField("m15_rate", timer.getFifteenMinuteRate() * this.rateFactor);
json.writeNumberField("m5_rate", timer.getFiveMinuteRate() * this.rateFactor);
json.writeNumberField("m1_rate", timer.getOneMinuteRate() * this.rateFactor);
json.writeStringField("rate_unit", this.rateUnit);
json.writeEndObject();
}
} To integrate this with Spring Actuator, ensure that your Spring configuration includes this custom serializer for Timer metrics. This can be done by registering the Additionally, make sure your management:
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
exposure:
include: "*" This setup will ensure that all Timer metrics are serialized correctly and can be retrieved via the Spring Actuator interface [1][2]. |
Bug Type (问题类型)
None
Before submit
Environment (环境信息)
Expected & Actual behavior (期望与实际表现)
当前问题
指标处理存在BUG,代码如下,没有将Timer 类型的所有指标序列化
期望结果
通过Spring Actuator 接口获取正确的JRaft 监控指标
curl http://ip:8620/actuator/prometheus
指标详情
具体指标
Vertex/Edge example (问题点 / 边数据举例)
No response
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
No response
The text was updated successfully, but these errors were encountered: