use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class CountDownLatchService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor root = descriptor.withPrefix("cp.countdownlatch");
for (CPGroupId groupId : getGroupIdSet()) {
CountDownLatchRegistry registry = getRegistryOrNull(groupId);
for (CountDownLatch latch : registry.getAllLatches()) {
MetricDescriptor desc = root.copy().withDiscriminator("id", latch.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, latch.getName()).withTag("group", groupId.getName());
context.collect(desc.copy().withMetric("round"), latch.getRound());
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("count"), latch.getCount());
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("remaining"), latch.getRemainingCount());
}
}
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class LockService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor root = descriptor.withPrefix("cp.lock");
for (CPGroupId groupId : getGroupIdSet()) {
LockRegistry registry = getRegistryOrNull(groupId);
for (Lock lock : registry.getAllLocks()) {
MetricDescriptor desc = root.copy().withDiscriminator("id", lock.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, lock.getName()).withTag("group", groupId.getName());
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("acquireLimit"), lock.lockCountLimit());
LockInvocationKey owner = lock.owner();
int lockCount = lock.lockCount();
// We may observe a partial update.
if (owner != null && lockCount > 0) {
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("lockCount"), lockCount);
context.collect(desc.copy().withMetric("ownerSessionId"), owner.sessionId());
context.collect(desc.copy().withTag("owner", owner.callerAddress().toString()).withMetric("owner"), 0);
} else {
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("lockCount"), 0);
}
}
}
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class RaftSessionService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor root = descriptor.withPrefix("cp.session");
for (RaftSessionRegistry registry : registries.values()) {
CPGroupId groupId = registry.groupId();
for (CPSession session : registry.getSessions()) {
MetricDescriptor desc = root.copy().withDiscriminator("id", session.id() + "@" + groupId.getName()).withTag("sessionId", String.valueOf(session.id())).withTag("group", groupId.getName());
context.collect(desc.copy().withTag("endpoint", session.endpoint().toString()).withMetric("endpoint"), 0);
context.collect(desc.copy().withTag("endpointType", session.endpointType().toString()).withMetric("endpointType"), 0);
context.collect(desc.copy().withMetric("version"), session.version());
context.collect(desc.copy().withUnit(ProbeUnit.MS).withMetric("creationTime"), session.creationTime());
context.collect(desc.copy().withUnit(ProbeUnit.MS).withMetric("expirationTime"), session.expirationTime());
}
}
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MethodProbe method register.
void register(MetricsRegistryImpl metricsRegistry, Object source, String namePrefix) {
MetricDescriptor descriptor = metricsRegistry.newMetricDescriptor().withPrefix(namePrefix).withMetric(getProbeName());
metricsRegistry.registerInternal(source, descriptor, probe.level(), this);
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MetricsCompressor method writeDescriptor.
@SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:NPathComplexity" })
private void writeDescriptor(MetricDescriptor originalDescriptor) throws IOException, LongWordException {
MetricDescriptor descriptor = prepareDescriptor(originalDescriptor);
int mask = calculateDescriptorMask(descriptor);
tmpDos.writeByte(mask);
if ((mask & MASK_PREFIX) == 0) {
tmpDos.writeInt(getDictionaryId(descriptor.prefix()));
}
if ((mask & MASK_METRIC) == 0) {
tmpDos.writeInt(getDictionaryId(descriptor.metric()));
}
if ((mask & MASK_DISCRIMINATOR) == 0) {
tmpDos.writeInt(getDictionaryId(descriptor.discriminator()));
}
if ((mask & MASK_DISCRIMINATOR_VALUE) == 0) {
tmpDos.writeInt(getDictionaryId(descriptor.discriminatorValue()));
}
if ((mask & MASK_UNIT) == 0) {
ProbeUnit unit = descriptor.unit();
if (unit != null) {
tmpDos.writeByte(unit.ordinal());
} else {
tmpDos.writeByte(NULL_UNIT);
}
}
if ((mask & MASK_EXCLUDED_TARGETS) == 0) {
tmpDos.writeByte(MetricTarget.bitset(descriptor.excludedTargets()));
}
if ((mask & MASK_TAG_COUNT) == 0) {
tmpDos.writeByte(descriptor.tagCount());
}
// further compression is possible by writing only the different tags
for (int i = 0; i < descriptor.tagCount(); i++) {
String tag = descriptor.tag(i);
String tagValue = descriptor.tagValue(i);
tmpDos.writeInt(getDictionaryId(tag));
tmpDos.writeInt(getDictionaryId(tagValue));
}
count++;
lastDescriptor = copyDescriptor(descriptor, lastDescriptor);
}
Aggregations