use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MetricsCollectionCycle method extractAndCollectDynamicMetrics.
private void extractAndCollectDynamicMetrics(MetricDescriptor descriptor, Object source) {
SourceMetadata metadata = lookupMetadataFn.apply(source.getClass());
for (MethodProbe methodProbe : metadata.methods()) {
if (methodProbe.probe.level().isEnabled(minimumLevel)) {
MetricDescriptor descriptorCopy = descriptor.copy().withUnit(methodProbe.probe.unit()).withMetric(methodProbe.getProbeName()).withExcludedTargets(extractExcludedTargets(methodProbe));
lookupMetricValueCatcher(descriptorCopy).catchMetricValue(collectionId, source, methodProbe);
collect(descriptorCopy, source, methodProbe);
}
}
for (FieldProbe fieldProbe : metadata.fields()) {
if (fieldProbe.probe.level().isEnabled(minimumLevel)) {
MetricDescriptor descriptorCopy = descriptor.copy().withUnit(fieldProbe.probe.unit()).withMetric(fieldProbe.getProbeName()).withExcludedTargets(extractExcludedTargets(fieldProbe));
lookupMetricValueCatcher(descriptorCopy).catchMetricValue(collectionId, source, fieldProbe);
collect(descriptorCopy, source, fieldProbe);
}
}
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class NioNetworking method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
for (Channel channel : channels) {
String pipelineId = channel.localSocketAddress() + "->" + channel.remoteSocketAddress();
MetricDescriptor descriptorIn = descriptor.copy().withPrefix(TCP_PREFIX_CONNECTION_IN).withDiscriminator(TCP_DISCRIMINATOR_PIPELINEID, pipelineId);
context.collect(descriptorIn, channel.inboundPipeline());
MetricDescriptor descriptorOut = descriptor.copy().withPrefix(TCP_PREFIX_CONNECTION_OUT).withDiscriminator(TCP_DISCRIMINATOR_PIPELINEID, pipelineId);
context.collect(descriptorOut, channel.outboundPipeline());
}
NioThread[] inputThreads = this.inputThreads;
if (inputThreads != null) {
for (NioThread nioThread : inputThreads) {
MetricDescriptor descriptorInThread = descriptor.copy().withPrefix(TCP_PREFIX_INPUTTHREAD).withDiscriminator(TCP_DISCRIMINATOR_THREAD, nioThread.getName());
context.collect(descriptorInThread, nioThread);
}
}
NioThread[] outputThreads = this.outputThreads;
if (outputThreads != null) {
for (NioThread nioThread : outputThreads) {
MetricDescriptor descriptorOutThread = descriptor.copy().withPrefix(TCP_PREFIX_OUTPUTTHREAD).withDiscriminator(TCP_DISCRIMINATOR_THREAD, nioThread.getName());
context.collect(descriptorOutThread, nioThread);
}
}
IOBalancer ioBalancer = this.ioBalancer;
if (ioBalancer != null) {
MetricDescriptor descriptorBalancer = descriptor.copy().withPrefix(TCP_PREFIX_BALANCER);
context.collect(descriptorBalancer, ioBalancer);
}
MetricDescriptor descriptorTcp = descriptor.copy().withPrefix(TCP_PREFIX);
context.collect(descriptorTcp, this);
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class TcpServerConnectionManager method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor rootDescriptor = descriptor.withPrefix(TCP_PREFIX_CONNECTION);
if (endpointQualifier == null) {
context.collect(rootDescriptor.copy(), this);
} else {
context.collect(rootDescriptor.copy().withDiscriminator(TCP_DISCRIMINATOR_ENDPOINT, endpointQualifier.toMetricsPrefixString()), this);
}
for (TcpServerConnection connection : connections) {
if (connection.getRemoteAddress() != null) {
context.collect(rootDescriptor.copy().withDiscriminator(TCP_DISCRIMINATOR_ENDPOINT, connection.getRemoteAddress().toString()), connection);
}
}
int clientCount = 0;
int textCount = 0;
for (Plane plane : planes) {
for (Map.Entry<UUID, TcpServerConnection> entry : plane.connections()) {
UUID uuid = entry.getKey();
TcpServerConnection connection = entry.getValue();
if (connection.isClient()) {
clientCount++;
String connectionType = connection.getConnectionType();
if (REST_CLIENT.equals(connectionType) || MEMCACHE_CLIENT.equals(connectionType)) {
textCount++;
}
}
if (connection.getRemoteAddress() != null) {
context.collect(rootDescriptor.copy().withDiscriminator(TCP_DISCRIMINATOR_BINDADDRESS, uuid.toString()).withTag(TCP_TAG_ENDPOINT, connection.getRemoteAddress().toString()), connection);
}
}
}
if (endpointConfig == null) {
context.collect(rootDescriptor.copy(), TCP_METRIC_CLIENT_COUNT, MANDATORY, COUNT, clientCount);
context.collect(rootDescriptor.copy(), TCP_METRIC_TEXT_COUNT, MANDATORY, COUNT, textCount);
}
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class MetricsCompressorTest method testLongTagValue.
@Test
public void testLongTagValue() {
DefaultMetricDescriptorSupplier supplier = new DefaultMetricDescriptorSupplier();
MetricsCompressor compressor = new MetricsCompressor();
String longPrefix = Stream.generate(() -> "a").limit(MetricsDictionary.MAX_WORD_LENGTH - 1).collect(Collectors.joining());
MetricDescriptor metric1 = supplier.get().withMetric("metricName").withTag("tag0", longPrefix + "0").withTag("tag1", longPrefix + "1");
compressor.addLong(metric1, 42);
byte[] blob = compressor.getBlobAndReset();
MetricConsumer metricConsumer = new MetricConsumer() {
@Override
public void consumeLong(MetricDescriptor descriptor, long value) {
assertEquals(42, value);
assertEquals("metricName", descriptor.metric());
assertEquals(longPrefix + "0", descriptor.tagValue("tag0"));
assertEquals(longPrefix + "1", descriptor.tagValue("tag1"));
}
@Override
public void consumeDouble(MetricDescriptor descriptor, double value) {
fail("Restored a double metric");
}
};
MetricConsumer metricConsumerSpy = spy(metricConsumer);
MetricsCompressor.extractMetrics(blob, metricConsumerSpy, supplierSpy);
}
use of com.hazelcast.internal.metrics.MetricDescriptor in project hazelcast by hazelcast.
the class DynamicMetricsCollectionTest method testDirectLongProveLevelFilters.
@Test
public void testDirectLongProveLevelFilters() {
MetricsCollector collectorMock = mock(MetricsCollector.class);
MetricsRegistry metricsRegistry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistryImpl.class), MANDATORY);
metricsRegistry.registerDynamicMetricsProvider((descriptor, context) -> context.collect(descriptor.withPrefix("test"), "someMetric", INFO, BYTES, 42));
metricsRegistry.collect(collectorMock);
MetricDescriptor expectedDescriptor = metricsRegistry.newMetricDescriptor().withPrefix("test").withUnit(BYTES).withMetric("someMetric");
verify(collectorMock, never()).collectLong(expectedDescriptor, 42);
}
Aggregations