Search in sources :

Example 6 with MetricId

use of com.datastax.oss.driver.internal.core.metrics.MetricId in project java-driver by datastax.

the class MicroProfileMetricsIT method nodeMetricIds.

private List<MetricID> nodeMetricIds(InternalDriverContext context, Node node) {
    List<MetricID> ids = new ArrayList<>();
    for (DefaultNodeMetric metric : ENABLED_NODE_METRICS) {
        MetricId id = context.getMetricIdGenerator().nodeMetricId(node, metric);
        ids.add(new MetricID(id.getName(), MicroProfileTags.toMicroProfileTags(id.getTags())));
    }
    return ids;
}
Also used : MetricID(org.eclipse.microprofile.metrics.MetricID) MetricId(com.datastax.oss.driver.internal.core.metrics.MetricId) ArrayList(java.util.ArrayList) DefaultNodeMetric(com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)

Example 7 with MetricId

use of com.datastax.oss.driver.internal.core.metrics.MetricId in project java-driver by datastax.

the class MicrometerMetricUpdater method initializeGauge.

protected void initializeGauge(MetricT metric, DriverExecutionProfile profile, Supplier<Number> supplier) {
    if (isEnabled(metric, profile.getName())) {
        metrics.computeIfAbsent(metric, m -> {
            MetricId id = getMetricId(m);
            Iterable<Tag> tags = MicrometerTags.toMicrometerTags(id.getTags());
            return Gauge.builder(id.getName(), supplier).tags(tags).register(registry);
        });
    }
}
Also used : MetricId(com.datastax.oss.driver.internal.core.metrics.MetricId) Tag(io.micrometer.core.instrument.Tag)

Example 8 with MetricId

use of com.datastax.oss.driver.internal.core.metrics.MetricId in project java-driver by datastax.

the class MicroProfileMetricUpdater method clearMetrics.

@Override
protected void clearMetrics() {
    for (MetricT metric : metrics.keySet()) {
        MetricId id = getMetricId(metric);
        Tag[] tags = MicroProfileTags.toMicroProfileTags(id.getTags());
        registry.remove(new MetricID(id.getName(), tags));
    }
    metrics.clear();
}
Also used : MetricId(com.datastax.oss.driver.internal.core.metrics.MetricId) MetricID(org.eclipse.microprofile.metrics.MetricID) Tag(org.eclipse.microprofile.metrics.Tag)

Example 9 with MetricId

use of com.datastax.oss.driver.internal.core.metrics.MetricId in project java-driver by datastax.

the class MicroProfileMetricUpdater method initializeGauge.

protected void initializeGauge(MetricT metric, DriverExecutionProfile profile, Gauge<Number> supplier) {
    if (isEnabled(metric, profile.getName())) {
        metrics.computeIfAbsent(metric, m -> {
            MetricId id = getMetricId(m);
            String name = id.getName();
            Tag[] tags = MicroProfileTags.toMicroProfileTags(id.getTags());
            Metadata metadata = Metadata.builder().withName(name).withType(MetricType.GAUGE).build();
            return registry.register(metadata, supplier, tags);
        });
    }
}
Also used : MetricId(com.datastax.oss.driver.internal.core.metrics.MetricId) Metadata(org.eclipse.microprofile.metrics.Metadata) Tag(org.eclipse.microprofile.metrics.Tag)

Example 10 with MetricId

use of com.datastax.oss.driver.internal.core.metrics.MetricId in project java-driver by datastax.

the class DropwizardMetricsIT method nodeMetricIds.

private List<String> nodeMetricIds(InternalDriverContext context, Node node) {
    List<String> ids = new ArrayList<>();
    for (DefaultNodeMetric metric : ENABLED_NODE_METRICS) {
        MetricId id = context.getMetricIdGenerator().nodeMetricId(node, metric);
        ids.add(id.getName());
    }
    return ids;
}
Also used : MetricId(com.datastax.oss.driver.internal.core.metrics.MetricId) ArrayList(java.util.ArrayList) DefaultNodeMetric(com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)

Aggregations

MetricId (com.datastax.oss.driver.internal.core.metrics.MetricId)10 DefaultNodeMetric (com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)7 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)5 MetricIdGenerator (com.datastax.oss.driver.internal.core.metrics.MetricIdGenerator)5 Tag (io.micrometer.core.instrument.Tag)4 Node (com.datastax.oss.driver.api.core.metadata.Node)3 DefaultSessionMetric (com.datastax.oss.driver.api.core.metrics.DefaultSessionMetric)3 Meter (io.micrometer.core.instrument.Meter)3 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)3 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)3 MetricID (org.eclipse.microprofile.metrics.MetricID)3 Tag (org.eclipse.microprofile.metrics.Tag)3 ArrayList (java.util.ArrayList)2 Counter (com.codahale.metrics.Counter)1 Meter (com.codahale.metrics.Meter)1 Metric (com.codahale.metrics.Metric)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Timer (com.codahale.metrics.Timer)1 Metrics (com.datastax.oss.driver.api.core.metrics.Metrics)1 Counter (io.micrometer.core.instrument.Counter)1