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

com.lightstep.tracer.metrics.Metric Maven / Gradle / Ivy

package com.lightstep.tracer.metrics;

import java.util.Objects;

abstract class Metric {
  private final ValueAdapter adapter;
  private final String name;
  private final long factor;

  Metric(final String name, final Class type, final long factor) {
    this.name = name;
    this.factor = factor;
    this.adapter = Objects.requireNonNull(ValueAdapter.get(type), type.getName());
  }

  final ValueAdapter getAdapter() {
    return this.adapter;
  }

  final String getName() {
    return this.name;
  }

  abstract V compute(long current, long previous);

  final double getValue(final long current, final long previous) {
    return compute(current, previous).doubleValue() / factor;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy