All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.marschall.micrometer.jfr.GaugeEventFactory Maven / Gradle / Ivy

There is a newer version: 1.13.0
Show newest version
package com.github.marschall.micrometer.jfr;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

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.ValueDescriptor;

final class GaugeEventFactory extends AbstractMeterEventFactory {

  GaugeEventFactory(Id id) {
    super(id);
  }

  @Override
  protected List getAdditionalValueDescriptors() {
    List valueAnnotations = new ArrayList<>(3);
    valueAnnotations.add(new AnnotationElement(Label.class, "Value"));
    valueAnnotations.add(new AnnotationElement(Description.class, "The current value of the gauge."));
    Optional baseUnitAnnotation = this.getAnnotationElementOfBaseUnit();
    if (baseUnitAnnotation.isPresent()) {
      valueAnnotations.add(baseUnitAnnotation.get());
    }
   ValueDescriptor valueDescriptor = new ValueDescriptor(double.class, "value", valueAnnotations);

    return List.of(valueDescriptor);
  }

  @Override
  JfrGaugeEvent newEmptyEvent(EventFactory eventFactory) {
    return new JfrGaugeEvent(this.id, eventFactory.newEvent());
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy