Skip to content

Commit

Permalink
[#11267] Use micrometer metric as default
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed Aug 14, 2024
1 parent 9ddc23a commit 9c6cd77
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

package com.navercorp.pinpoint.collector.config;

import com.navercorp.pinpoint.collector.dao.hbase.BulkOperationReporter;
import com.navercorp.pinpoint.collector.manage.HBaseManager;
import com.navercorp.pinpoint.collector.monitor.dropwizard.BulkOperationMetrics;
import com.navercorp.pinpoint.collector.monitor.dropwizard.HBaseAsyncOperationMetrics;
import com.navercorp.pinpoint.common.hbase.async.HBaseTableMultiplexerFactory;
import com.navercorp.pinpoint.common.hbase.async.HbasePutWriter;
import com.navercorp.pinpoint.common.hbase.async.LoggingHbasePutWriter;
Expand All @@ -38,8 +35,6 @@
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;

import java.util.List;

@Configuration
@Import({
CommonCacheManagerConfiguration.class,
Expand All @@ -54,11 +49,6 @@ public HbaseBatchPerformanceCounter batchPerformanceCounter() {
return new HbaseBatchPerformanceCounter();
}

@Bean
public HBaseAsyncOperationMetrics asyncOperationMetrics(List<HBaseBatchPerformance> hBaseAsyncOperationList) {
return new HBaseAsyncOperationMetrics(hBaseAsyncOperationList);
}

@Configuration
@ConditionalOnProperty(name = "hbase.client.put-writer", havingValue = "tableMultiplexer")
public static class TableMultiplexerConfig {
Expand All @@ -81,8 +71,8 @@ public HbasePutWriter hbasePutWriter(@Qualifier("batchConnectionFactory") Connec

@Bean
public HbasePutWriter spanPutWriter(@Qualifier("batchConnectionFactory") Connection connection,
HbaseBatchPerformanceCounter counter,
HbaseMultiplexerProperties properties) throws Exception {
HbaseBatchPerformanceCounter counter,
HbaseMultiplexerProperties properties) throws Exception {
HbasePutWriter writer = newPutWriter(connection, counter, properties);
logger.info("HbaseSpanPutWriter:{}", writer);
return writer;
Expand All @@ -98,16 +88,9 @@ private HbasePutWriter newPutWriter(Connection connection, HbaseBatchPerformance

}


@Bean
public BulkOperationMetrics cachedStatisticsDaoMetrics(List<BulkOperationReporter> bulkOperationReporters) {
return new BulkOperationMetrics(bulkOperationReporters);
}

@Bean
public HBaseManager hBaseManager(@Qualifier("batchPerformanceCounter") HBaseBatchPerformance hBaseAsyncOperation) {
return new HBaseManager(hBaseAsyncOperation);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.navercorp.pinpoint.collector.grpc;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.grpc.channelz.ChannelzConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcAgentConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcAgentReceiverConfiguration;
Expand All @@ -28,17 +27,10 @@
import com.navercorp.pinpoint.collector.grpc.config.GrpcStatConfiguration;
import com.navercorp.pinpoint.collector.grpc.config.GrpcStatReceiverConfiguration;
import com.navercorp.pinpoint.collector.monitor.MonitoredThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.monitor.config.DropwizardConfiguration;
import com.navercorp.pinpoint.collector.monitor.config.MicrometerConfiguration;
import com.navercorp.pinpoint.collector.monitor.dropwizard.DropwizardThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.monitor.micrometer.MicrometerThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.common.server.executor.ExecutorCustomizer;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
Expand All @@ -60,7 +52,6 @@

GrpcKeepAliveScheduler.class,

DropwizardConfiguration.class,
MicrometerConfiguration.class,

ChannelzConfiguration.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@

package com.navercorp.pinpoint.collector.grpc.config;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.monitor.MonitoredThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.monitor.dropwizard.DropwizardThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import com.navercorp.pinpoint.grpc.server.ServerOption;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@

package com.navercorp.pinpoint.collector.grpc.config;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.monitor.MonitoredThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.monitor.dropwizard.DropwizardThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import com.navercorp.pinpoint.grpc.server.ServerOption;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@

package com.navercorp.pinpoint.collector.grpc.config;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.monitor.MonitoredThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.monitor.MonitoringExecutors;
import com.navercorp.pinpoint.collector.monitor.dropwizard.DropwizardThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.receiver.BindAddress;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import com.navercorp.pinpoint.common.server.util.CallerUtils;
import com.navercorp.pinpoint.grpc.server.ServerOption;
import jakarta.inject.Provider;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
*/
package com.navercorp.pinpoint.collector.monitor;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.monitor.dropwizard.DropwizardThreadPoolExecutorFactory;
import com.navercorp.pinpoint.collector.monitor.micrometer.MicrometerThreadPoolExecutorFactory;
import com.navercorp.pinpoint.common.server.thread.MonitoringExecutorProperties;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Autowired;

/**
* @author intr3p1d
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@
*/
package com.navercorp.pinpoint.collector.monitor.config;

import com.navercorp.pinpoint.collector.dao.hbase.BulkOperationReporter;
import com.navercorp.pinpoint.collector.monitor.MonitoredThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.collector.monitor.micrometer.BulkOperationMetrics;
import com.navercorp.pinpoint.collector.monitor.micrometer.HBaseAsyncOperationMetrics;
import com.navercorp.pinpoint.collector.monitor.micrometer.MicrometerThreadPoolExecutorFactoryProvider;
import com.navercorp.pinpoint.common.hbase.counter.HBaseBatchPerformance;
import io.grpc.ServerInterceptor;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor;
import io.micrometer.core.instrument.binder.logging.Log4j2Metrics;
import io.micrometer.core.instrument.binder.netty4.NettyAllocatorMetrics;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufAllocatorMetricProvider;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.EventLoopGroup;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
* @author intr3p1d
*/
@Configuration
@ConditionalOnProperty(
value = "pinpoint.modules.collector.monitor.metric",
havingValue = "micrometer"
)
public class MicrometerConfiguration {
private final Logger logger = LogManager.getLogger(MicrometerConfiguration.class);
private static final String GRPC_INTERCEPTOR_TAG_KEY = "service";
Expand All @@ -54,10 +55,12 @@ public MicrometerConfiguration() {
}

@Bean
@ConditionalOnProperty(
value = "pinpoint.modules.collector.monitor.metric",
havingValue = "micrometer"
)
@ConditionalOnMissingBean(MeterRegistry.class)
public MeterRegistry simpleMeterRegistry() {
return new SimpleMeterRegistry();

Check warning on line 60 in collector/src/main/java/com/navercorp/pinpoint/collector/monitor/config/MicrometerConfiguration.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/monitor/config/MicrometerConfiguration.java#L60

Added line #L60 was not covered by tests
}

@Bean
public MonitoredThreadPoolExecutorFactoryProvider micrometerMonitoredThreadPoolExecutorFactoryProvider(
MeterRegistry meterRegistry
) {
Expand Down Expand Up @@ -112,11 +115,28 @@ private Timer.Builder addTimerTag(Timer.Builder builder, String tagValue) {

@Bean
@Qualifier("monitoredByteBufAllocator")
public ByteBufAllocator monitoredByteBufAllocator(MeterRegistry meterRegistry){
public ByteBufAllocator monitoredByteBufAllocator(MeterRegistry meterRegistry) {
ByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;
if (allocator != null) {
new NettyAllocatorMetrics((ByteBufAllocatorMetricProvider) allocator).bindTo(meterRegistry);
}
return allocator;
}

@Bean
public BulkOperationMetrics cachedStatisticsDaoMetrics(
List<BulkOperationReporter> bulkOperationReporters,
MeterRegistry meterRegistry
) {
return new BulkOperationMetrics(bulkOperationReporters, meterRegistry);

Check warning on line 131 in collector/src/main/java/com/navercorp/pinpoint/collector/monitor/config/MicrometerConfiguration.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/monitor/config/MicrometerConfiguration.java#L131

Added line #L131 was not covered by tests
}

@Bean
public HBaseAsyncOperationMetrics asyncOperationMetrics(
List<HBaseBatchPerformance> hBaseAsyncOperationList,
MeterRegistry meterRegistry
) {
return new HBaseAsyncOperationMetrics(hBaseAsyncOperationList, meterRegistry);

Check warning on line 139 in collector/src/main/java/com/navercorp/pinpoint/collector/monitor/config/MicrometerConfiguration.java

View check run for this annotation

Codecov / codecov/patch

collector/src/main/java/com/navercorp/pinpoint/collector/monitor/config/MicrometerConfiguration.java#L139

Added line #L139 was not covered by tests
}

}
Loading

0 comments on commit 9c6cd77

Please sign in to comment.