Search in sources :

Example 1 with MetricTarget

use of com.hazelcast.internal.metrics.MetricTarget in project hazelcast by hazelcast.

the class SourceMetadata method getTypeExcludedTarget.

private Collection<MetricTarget> getTypeExcludedTarget(Class clazz) {
    Collection<MetricTarget> typeExclusions;
    ExcludedMetricTargets targetsAnnotation = (ExcludedMetricTargets) clazz.getAnnotation(ExcludedMetricTargets.class);
    if (targetsAnnotation != null) {
        typeExclusions = unmodifiableList(asList(targetsAnnotation.value()));
    } else {
        typeExclusions = emptyList();
    }
    return typeExclusions;
}
Also used : MetricTarget(com.hazelcast.internal.metrics.MetricTarget) ExcludedMetricTargets(com.hazelcast.internal.metrics.ExcludedMetricTargets)

Example 2 with MetricTarget

use of com.hazelcast.internal.metrics.MetricTarget in project hazelcast by hazelcast.

the class MetricDescriptorImpl method buildMetricString.

private String buildMetricString(boolean includeExcludedTargets) {
    StringBuilder sb = new StringBuilder(INITIAL_STRING_CAPACITY).append('[');
    if (discriminatorValue != null) {
        sb.append(discriminator).append('=').append(discriminatorValue).append(',');
    }
    if (unit != null) {
        sb.append("unit=").append(lowerCaseInternal(unit.name())).append(',');
    }
    if (metric != null) {
        sb.append("metric=");
        if (prefix != null) {
            sb.append(prefix).append('.');
        }
        sb.append(metric);
        sb.append(',');
    }
    for (int i = 0; i < tagPtr; i += 2) {
        String tag = tags[i];
        String tagValue = tags[i + 1];
        sb.append(tag).append('=').append(tagValue).append(',');
    }
    if (includeExcludedTargets) {
        sb.append("excludedTargets={");
        if (excludedTargets.isEmpty()) {
            sb.append('}');
        } else {
            for (MetricTarget target : excludedTargets) {
                sb.append(target.name()).append(',');
            }
            sb.setCharAt(sb.length() - 1, '}');
        }
        sb.append(',');
    }
    if (sb.length() > 1) {
        sb.setCharAt(sb.length() - 1, ']');
    } else {
        sb.append(']');
    }
    return sb.toString();
}
Also used : MetricTarget(com.hazelcast.internal.metrics.MetricTarget)

Example 3 with MetricTarget

use of com.hazelcast.internal.metrics.MetricTarget in project hazelcast by hazelcast.

the class MetricsUtil method extractExcludedTargets.

private static Collection<MetricTarget> extractExcludedTargets(CachedProbe probe, SourceMetadata sourceMetadata) {
    ProbeLevel level = probe.level();
    Collection<MetricTarget> excludedTargetsClass = sourceMetadata.excludedTargetsClass();
    Set<MetricTarget> excludedTargetsProbe = asSet(probe.excludedTargets());
    Set<MetricTarget> excludedTargetsUnion = MetricTarget.union(excludedTargetsClass, excludedTargetsProbe);
    if (DEBUG != level) {
        return excludedTargetsUnion;
    } else if (excludedTargetsUnion.contains(DIAGNOSTICS)) {
        return ALL_TARGETS;
    } else {
        return ALL_TARGETS_BUT_DIAGNOSTICS;
    }
}
Also used : MetricTarget(com.hazelcast.internal.metrics.MetricTarget) ProbeLevel(com.hazelcast.internal.metrics.ProbeLevel)

Example 4 with MetricTarget

use of com.hazelcast.internal.metrics.MetricTarget in project hazelcast by hazelcast.

the class MetricDescriptorImplTest method testTargetExclusion.

@Test
public void testTargetExclusion() {
    MetricDescriptorImpl original = new MetricDescriptorImpl(mock(Supplier.class)).withExcludedTarget(MANAGEMENT_CENTER).withExcludedTarget(JMX);
    assertTrue(original.isTargetExcluded(MANAGEMENT_CENTER));
    assertTrue(original.isTargetExcluded(JMX));
    EnumSet<MetricTarget> expectedIncludedTargets = EnumSet.complementOf(EnumSet.of(MANAGEMENT_CENTER, JMX));
    for (MetricTarget metricTarget : expectedIncludedTargets) {
        assertFalse(original.isTargetExcluded(metricTarget));
    }
}
Also used : MetricTarget(com.hazelcast.internal.metrics.MetricTarget) Supplier(java.util.function.Supplier) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MetricTarget (com.hazelcast.internal.metrics.MetricTarget)4 ExcludedMetricTargets (com.hazelcast.internal.metrics.ExcludedMetricTargets)1 ProbeLevel (com.hazelcast.internal.metrics.ProbeLevel)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Supplier (java.util.function.Supplier)1 Test (org.junit.Test)1