Skip to content

Commit 060d71a

Browse files
committed
[pinpoint-apm#12244] Add MetricCollectorProperties for configurable cache size
1 parent b25c4a7 commit 060d71a

File tree

6 files changed

+61
-3
lines changed

6 files changed

+61
-3
lines changed

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/collector/MetricAppPropertySources.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
*/
2525

2626
@PropertySources({
27-
@PropertySource(name = "MetricAppPropertySources-KAFKA", value = { MetricAppPropertySources.KAFKA_TOPIC}),
27+
@PropertySource(name = "MetricAppPropertySources-CONFIG", value = { MetricAppPropertySources.KAFKA_TOPIC, MetricAppPropertySources.COLLECTOR_CONFIG}),
2828
})
2929
public class MetricAppPropertySources {
3030
public static final String KAFKA_TOPIC = "classpath:pinot-collector/kafka-topic.properties";
3131

32+
public static final String COLLECTOR_CONFIG = "classpath:pinot-collector/profiles/${pinpoint.profiles.active:release}/collector-metric.properties";
33+
3234
}

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/collector/MetricCollectorApp.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.navercorp.pinpoint.metric.collector;
22

33
import com.navercorp.pinpoint.metric.collector.cache.MetricCacheConfiguration;
4+
import com.navercorp.pinpoint.metric.collector.config.MetricCollectorProperties;
45
import com.navercorp.pinpoint.metric.collector.config.MetricKafkaConfiguration;
56
import com.navercorp.pinpoint.metric.common.config.MetricCollectorPinotDaoConfiguration;
67
import com.navercorp.pinpoint.pinot.config.PinotConfiguration;
@@ -35,7 +36,9 @@
3536
MetricCacheConfiguration.class,
3637
PinotConfiguration.class,
3738
MetricCollectorPinotDaoConfiguration.class,
38-
MetricKafkaConfiguration.class
39+
MetricKafkaConfiguration.class,
40+
MetricCollectorProperties.class
41+
3942
})
4043
@Profile("metric")
4144
public class MetricCollectorApp {

metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/collector/cache/MetricCacheConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.navercorp.pinpoint.metric.collector.cache;
1818

1919
import com.github.benmanes.caffeine.cache.Caffeine;
20+
import com.navercorp.pinpoint.metric.collector.config.MetricCollectorProperties;
2021
import org.springframework.cache.CacheManager;
2122
import org.springframework.cache.annotation.EnableCaching;
2223
import org.springframework.cache.caffeine.CaffeineCacheManager;
@@ -48,7 +49,7 @@ public CacheManager cacheManager() {
4849
}
4950

5051
@Bean
51-
public CacheManager metricTagCollection() {
52+
public CacheManager metricTagCollection(MetricCollectorProperties metricCollectorProperties) {
5253
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager(METRIC_TAG_COLLECTION_CACHE_NAME);
5354
caffeineCacheManager.setCaffeine(Caffeine.newBuilder()
5455
.expireAfterWrite(86400, TimeUnit.SECONDS)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2025 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.navercorp.pinpoint.metric.collector.config;
18+
19+
import com.navercorp.pinpoint.common.server.config.AnnotationVisitor;
20+
import com.navercorp.pinpoint.common.server.config.LoggingEvent;
21+
import jakarta.annotation.PostConstruct;
22+
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
24+
import org.springframework.beans.factory.annotation.Value;
25+
import org.springframework.stereotype.Component;
26+
27+
/**
28+
* @author minwoo-jung
29+
*/
30+
@Component
31+
public class MetricCollectorProperties {
32+
33+
private final Logger logger = LogManager.getLogger(MetricCollectorProperties.class);
34+
35+
@Value("${metric.cache.size.tag:10000}")
36+
private int metricTagCacheSize;
37+
38+
public int getMetricTagCacheSize() {
39+
return metricTagCacheSize;
40+
}
41+
42+
43+
@PostConstruct
44+
public void log() {
45+
logger.info("{}", this);
46+
AnnotationVisitor<Value> annotationVisitor = new AnnotationVisitor<>(Value.class);
47+
annotationVisitor.visit(this, new LoggingEvent(this.logger));
48+
}
49+
50+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
metric.cache.size.tag=10000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
metric.cache.size.tag=10000

0 commit comments

Comments
 (0)