Class MethodFaultToleranceMetrics

    • Constructor Detail

      • MethodFaultToleranceMetrics

        public MethodFaultToleranceMetrics​(org.eclipse.microprofile.metrics.MetricRegistry registry,
                                           String canonicalMethodName)
    • Method Detail

      • boundTo

        public FaultToleranceMetrics boundTo​(FaultToleranceMethodContext context,
                                             FaultTolerancePolicy policy)
        The first thread calling creates the metrics all thread calling the same method work with. Other threads have to wait until these metrics actually exist. The easiest to make that happen was to make this method synchronised. The registered is still an AtomicBoolean so that a state change affects other MethodFaultToleranceMetrics instances for the same method that were created in the meantime as well.
        Specified by:
        boundTo in interface FaultToleranceMetrics
        Returns:
        a instance on the basis of this FaultToleranceMetrics that is properly adopted to the provided context and policy. This can be the same instance if no change is required or a new one if a change of internal state is required. As part of binding to the context and policy this method also should register all metrics that make sense for the provided policy in case this has not been done already.
      • register

        public void register​(org.eclipse.microprofile.metrics.MetricType type,
                             String metric,
                             String[]... tagsPermutations)
        Description copied from interface: FaultToleranceMetrics
        Registration: Registers a metric for each permutation of the tags. Infers unit from type.
        Specified by:
        register in interface FaultToleranceMetrics
        Parameters:
        type - MetricType.COUNTER (assumes no unit) or MetricType.HISTOGRAM (assumes MetricUnits.NANOSECONDS)
        metric - name of the metric(s)
        tagsPermutations - tag name and possible values
      • register

        public void register​(String metric,
                             String unit,
                             LongSupplier gauge,
                             String... tag)
        Description copied from interface: FaultToleranceMetrics
        Gauge registration:
        Specified by:
        register in interface FaultToleranceMetrics
        Parameters:
        metric - name of the gauge metric
        unit - unit of the gauge metric (null is MetricUnits.NONE)
        gauge - a supplier function for the gauge
        tag - tag name and value if the gauge uses a tag
      • incrementCounter

        public void incrementCounter​(String metric,
                                     org.eclipse.microprofile.metrics.Tag... tags)
        Description copied from interface: FaultToleranceMetrics
        Counters:
        Specified by:
        incrementCounter in interface FaultToleranceMetrics
        Parameters:
        metric - full name of the metric with %s used as placeholder for the method name
        tags - all tags to add for the metric except the method tag (which is added later internally)
      • addToHistogram

        public void addToHistogram​(String metric,
                                   long duration,
                                   org.eclipse.microprofile.metrics.Tag... tags)
        Description copied from interface: FaultToleranceMetrics
        Histogram:
        Specified by:
        addToHistogram in interface FaultToleranceMetrics
        Parameters:
        metric - full name of the metric with %s used as placeholder for the method name
        duration - amount of nanoseconds to add to the histogram (>= 0)
        tags - all tags to add for the metric except the method tag (which is added later internally)