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;
}
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();
}
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;
}
}
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));
}
}
Aggregations