Skip to content

Commit

Permalink
[pinpoint-apm#11267] Add micrometer for monitoring collector
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed Aug 1, 2024
1 parent 0e3fd4e commit eec0ce2
Show file tree
Hide file tree
Showing 27 changed files with 571 additions and 139 deletions.
23 changes: 18 additions & 5 deletions collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,16 @@
<version>8.13.1</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-actuator</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down Expand Up @@ -280,6 +285,14 @@
<artifactId>jakarta.servlet-api</artifactId>
</dependency>

<!-- serving performance metrics with micrometer -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>



<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-rpc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import com.navercorp.pinpoint.collector.config.CollectorCommonConfiguration;
import com.navercorp.pinpoint.collector.config.CollectorConfiguration;
import com.navercorp.pinpoint.collector.config.FlinkContextModule;
import com.navercorp.pinpoint.collector.config.MetricConfiguration;
import com.navercorp.pinpoint.collector.config.MicrometerConfiguration;
import com.navercorp.pinpoint.collector.config.DropwizardConfiguration;
import com.navercorp.pinpoint.collector.grpc.CollectorGrpcConfiguration;
import com.navercorp.pinpoint.collector.grpc.ssl.GrpcSslModule;
import com.navercorp.pinpoint.collector.manage.CollectorAdminConfiguration;
Expand Down Expand Up @@ -35,7 +36,8 @@

ClusterModule.class,

MetricConfiguration.class,
DropwizardConfiguration.class,
MicrometerConfiguration.class,

GrpcSslModule.class,

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.navercorp.pinpoint.collector.config;

import com.codahale.metrics.MetricRegistry;
import com.navercorp.pinpoint.collector.monitor.dropwizard.BulkOperationMetrics;
import com.navercorp.pinpoint.collector.monitor.dropwizard.CollectorMetric;
import com.navercorp.pinpoint.collector.monitor.dropwizard.HBaseAsyncOperationMetrics;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
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.Configuration;

import java.util.Optional;

@Configuration
// FIXME: The MetricRegistry is currently used in other parts
// so it cannot be removed at this time.
// It needs to be separated in the future.
//@ConditionalOnProperty(
// value = "pinpoint.modules.collector.monitor.metric",
// havingValue = "dropwizard", matchIfMissing = true
//)
public class DropwizardConfiguration {
private final Logger logger = LogManager.getLogger(DropwizardConfiguration.class);

public DropwizardConfiguration() {
logger.info("Install {}", DropwizardConfiguration.class.getSimpleName());
}

@Bean
public MetricRegistry metricRegistry() {
return new MetricRegistry();
}


@Bean
public CollectorMetric collectorMetric(
CollectorProperties collectorProperties,
MetricRegistry metricRegistry,
Optional<HBaseAsyncOperationMetrics> hBaseAsyncOperationMetrics,
Optional<BulkOperationMetrics> cachedStatisticsDaoMetrics
) {
return new CollectorMetric(collectorProperties, metricRegistry, hBaseAsyncOperationMetrics, cachedStatisticsDaoMetrics);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import com.navercorp.pinpoint.collector.dao.hbase.BulkOperationReporter;
import com.navercorp.pinpoint.collector.manage.HBaseManager;
import com.navercorp.pinpoint.collector.monitor.BulkOperationMetrics;
import com.navercorp.pinpoint.collector.monitor.HBaseAsyncOperationMetrics;
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 Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.collector.config;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;

/**
* @author intr3p1d
*/
@Configuration
@ConditionalOnProperty(
value = "pinpoint.modules.collector.monitor.metric",
havingValue = "micrometer"
)
public class MicrometerConfiguration {
private final Logger logger = LogManager.getLogger(MicrometerConfiguration.class);

public MicrometerConfiguration() {
logger.info("Install {}", MicrometerConfiguration.class.getSimpleName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@
import com.navercorp.pinpoint.collector.grpc.config.GrpcSpanReceiverConfiguration;
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.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 Down Expand Up @@ -62,8 +68,30 @@ public class CollectorGrpcConfiguration {
@Bean
public MonitoringExecutors monitoringExecutors(
@Qualifier("collectorExecutorCustomizer") ExecutorCustomizer<ThreadPoolExecutorFactoryBean> customizer,
@Autowired(required = false) MetricRegistry metricRegistry) {
return new MonitoringExecutors(customizer, metricRegistry);
MonitoredThreadPoolExecutorFactoryProvider monitoredThreadPoolExecutorFactoryProvider
) {
return new MonitoringExecutors(customizer, monitoredThreadPoolExecutorFactoryProvider);
}

@Bean
@ConditionalOnProperty(
value = "pinpoint.modules.collector.monitor.metric",
havingValue = "dropwizard", matchIfMissing = true
)
public MonitoredThreadPoolExecutorFactoryProvider dropwizardMonitoredThreadPoolExecutorFactoryProvider(
@Autowired(required = false) MetricRegistry metricRegistry
) {
return new DropwizardThreadPoolExecutorFactoryProvider(metricRegistry);
}

@Bean
@ConditionalOnProperty(
value = "pinpoint.modules.collector.monitor.metric",
havingValue = "micrometer"
)
public MonitoredThreadPoolExecutorFactoryProvider micrometerMonitoredThreadPoolExecutorFactoryProvider(
@Autowired(required = false) MeterRegistry meterRegistry
) {
return new MicrometerThreadPoolExecutorFactoryProvider(meterRegistry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

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 Expand Up @@ -108,4 +112,11 @@ public FactoryBean<ExecutorService> grpcAgentServerCallExecutor(MonitoringExecut
properties.setLogRate(1);
return executors.newExecutorFactoryBean(properties, beanName);
}

@Bean
public MonitoredThreadPoolExecutorFactoryProvider dropwizardMonitoredThreadPoolExecutorFactoryProvider(
@Autowired(required = false) MetricRegistry metricRegistry
) {
return new DropwizardThreadPoolExecutorFactoryProvider(metricRegistry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

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 Expand Up @@ -110,4 +114,10 @@ public FactoryBean<ExecutorService> grpcSpanServerExecutor(MonitoringExecutors e
return executors.newExecutorFactoryBean(properties, beanName);
}

@Bean
public MonitoredThreadPoolExecutorFactoryProvider dropwizardMonitoredThreadPoolExecutorFactoryProvider(
@Autowired(required = false) MetricRegistry metricRegistry
) {
return new DropwizardThreadPoolExecutorFactoryProvider(metricRegistry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@

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 Expand Up @@ -106,4 +110,11 @@ public FactoryBean<ExecutorService> grpcStatServerExecutor(MonitoringExecutors e
return executors.newExecutorFactoryBean(properties, beanName);
}

@Bean
public MonitoredThreadPoolExecutorFactoryProvider dropwizardMonitoredThreadPoolExecutorFactoryProvider(
@Autowired(required = false) MetricRegistry metricRegistry
) {
return new DropwizardThreadPoolExecutorFactoryProvider(metricRegistry);
}

}
Loading

0 comments on commit eec0ce2

Please sign in to comment.