Search in sources :

Example 6 with Gauge

use of org.opennms.newts.api.Gauge in project opennms by OpenNMS.

the class NewtsConverter method toSample.

protected static Sample toSample(AbstractDS ds, Resource resource, Timestamp timestamp, double value) {
    final String metric = ds.getName();
    final MetricType type = ds.isCounter() ? MetricType.COUNTER : MetricType.GAUGE;
    final ValueType<?> valueType = ds.isCounter() ? new Counter(UnsignedLong.valueOf(BigDecimal.valueOf(value).toBigInteger())) : new Gauge(value);
    return new Sample(timestamp, resource, metric, type, valueType);
}
Also used : Counter(org.opennms.newts.api.Counter) Sample(org.opennms.newts.api.Sample) MetricType(org.opennms.newts.api.MetricType) Gauge(org.opennms.newts.api.Gauge)

Aggregations

Gauge (org.opennms.newts.api.Gauge)6 Sample (org.opennms.newts.api.Sample)6 Test (org.junit.Test)3 Resource (org.opennms.newts.api.Resource)3 Timestamp (org.opennms.newts.api.Timestamp)3 Counter (org.opennms.newts.api.Counter)2 Row (org.opennms.newts.api.Results.Row)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 BoundStatement (com.datastax.driver.core.BoundStatement)1 PreparedStatement (com.datastax.driver.core.PreparedStatement)1 RegularStatement (com.datastax.driver.core.RegularStatement)1 ResultSetFuture (com.datastax.driver.core.ResultSetFuture)1 Statement (com.datastax.driver.core.Statement)1 Date (java.util.Date)1 Rate (org.opennms.newts.aggregate.Rate)1 Duration (org.opennms.newts.api.Duration)1 MetricType (org.opennms.newts.api.MetricType)1 Results (org.opennms.newts.api.Results)1 CassandraSession (org.opennms.newts.cassandra.CassandraSession)1 ContextConfigurations (org.opennms.newts.cassandra.ContextConfigurations)1