com.github.marschall.micrometer.jfr.TimerGaugeEventFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micrometer-jfr Show documentation
Show all versions of micrometer-jfr Show documentation
A Micrometer meter registry that generates JFR events
The newest version!
package com.github.marschall.micrometer.jfr;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.micrometer.core.instrument.Meter.Id;
import jdk.jfr.AnnotationElement;
import jdk.jfr.Description;
import jdk.jfr.EventFactory;
import jdk.jfr.Label;
import jdk.jfr.Timespan;
import jdk.jfr.ValueDescriptor;
final class TimerGaugeEventFactory extends AbstractMeterEventFactory {
TimerGaugeEventFactory(Id id, TimeUnit baseTimeUnit) {
super(id, baseTimeUnit);
}
@Override
protected List getAdditionalValueDescriptors() {
List valueAnnotations = List.of(
new AnnotationElement(Label.class, "Value"),
new AnnotationElement(Description.class, "The current value of the gauge in " + this.baseTimeUnit),
new AnnotationElement(Timespan.class, this.getTimespanOfBaseTimeUnit()));
ValueDescriptor valueDescriptor = new ValueDescriptor(double.class, "value", valueAnnotations);
return List.of(valueDescriptor);
}
@Override
JfrTimerGaugeEvent newEmptyEvent(EventFactory eventFactory) {
return new JfrTimerGaugeEvent(this.id, eventFactory.newEvent());
}
}