Class GaugeAnnotationHandler

java.lang.Object
io.quarkus.micrometer.deployment.binder.mpmetrics.GaugeAnnotationHandler

public class GaugeAnnotationHandler extends Object
Create beans to handle @Gauge annotations. This is a static utility class, it stores no state. It is ok to import and use classes that reference MP Metrics classes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    createClass(org.jboss.jandex.IndexView index, io.quarkus.gizmo.ClassOutput classOutput, String generatedClassName, org.jboss.jandex.AnnotationInstance annotation, org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.ClassInfo classInfo, org.jboss.jandex.MethodInfo methodInfo)
    Given this Widget class:
    (package private) static void
    processAnnotatedGauges(org.jboss.jandex.IndexView index, io.quarkus.gizmo.ClassOutput classOutput)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GaugeAnnotationHandler

      public GaugeAnnotationHandler()
  • Method Details

    • processAnnotatedGauges

      static void processAnnotatedGauges(org.jboss.jandex.IndexView index, io.quarkus.gizmo.ClassOutput classOutput)
    • createClass

      static void createClass(org.jboss.jandex.IndexView index, io.quarkus.gizmo.ClassOutput classOutput, String generatedClassName, org.jboss.jandex.AnnotationInstance annotation, org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.ClassInfo classInfo, org.jboss.jandex.MethodInfo methodInfo)
      Given this Widget class:
       public class Widget  {
           private LongAccumulator highestValue = new LongAccumulator(Long::max, 0);
      
           // ... some other things that change the value in the accumulator ...
      
           @Gauge(name = "highestValue", unit = MetricUnits.NONE, description = "Highest observed value.")
           public Long highestValue() {
               return highestValue.get();
           }
       }
       
      
       This method will generate a GaugeAdapter to call the annotated method:
      
       
       public class Widget_GaugeAdapter extends GaugeAdapter.GaugeAdapterImpl implements GaugeAdapter {
      
           @Inject
           Widget target;
      
           public Widget_GaugeAdapter() {
               // name, description, and tags are created from annotation attributes
               // init is a method on the superclass
               super(name, description, tags);
           }
      
           Number getValue() {
               return target.highestValue;
           }
      
           Object getValue() {
               return getValue();
           }
       }