Skip to content

Commit a68b447

Browse files
authored
Support to customize the collect period of JVM relative metrics. (#428)
1 parent cd84ba2 commit a68b447

5 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Release Notes.
2020
* Add tags `mq.message.keys` and `mq.message.tags` for RocketMQ producer span
2121
* Clean the trace context which injected into Pulsar MessageImpl after the instance recycled
2222
* Fix In the higher version of mysql-connector-java 8x, there is an error in the value of db.instance.
23-
* Add support for KafkaClients 3.2.x
23+
* Add support for KafkaClients 3.x.
24+
* Support to customize the collect period of JVM relative metrics.
2425

2526
#### Documentation
2627

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ public static class Jvm {
273273
* The buffer size of collected JVM info.
274274
*/
275275
public static int BUFFER_SIZE = 60 * 10;
276+
/**
277+
* The period in seconds of JVM metrics collection.
278+
*/
279+
public static int METRICS_COLLECT_PERIOD = 1;
276280
}
277281

278282
public static class Log {

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor;
2626
import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
2727
import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
28+
import org.apache.skywalking.apm.agent.core.conf.Config;
2829
import org.apache.skywalking.apm.agent.core.jvm.clazz.ClassProvider;
2930
import org.apache.skywalking.apm.agent.core.jvm.cpu.CPUProvider;
3031
import org.apache.skywalking.apm.agent.core.jvm.gc.GCProvider;
@@ -66,7 +67,7 @@ public void handle(Throwable t) {
6667
LOGGER.error("JVMService produces metrics failure.", t);
6768
}
6869
}
69-
), 0, 1, TimeUnit.SECONDS);
70+
), 0, Config.Jvm.METRICS_COLLECT_PERIOD, TimeUnit.SECONDS);
7071
sendMetricFuture = Executors.newSingleThreadScheduledExecutor(
7172
new DefaultNamedThreadFactory("JVMService-consume"))
7273
.scheduleAtFixedRate(new RunnableWithExceptionProtection(

apm-sniffer/config/agent.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ correlation.value_max_length=${SW_CORRELATION_VALUE_MAX_LENGTH:128}
150150
correlation.auto_tag_keys=${SW_CORRELATION_AUTO_TAG_KEYS:}
151151
# The buffer size of collected JVM info.
152152
jvm.buffer_size=${SW_JVM_BUFFER_SIZE:600}
153+
# The period in seconds of JVM metrics collection. Unit is second.
154+
jvm.metrics_collect_period=${SW_JVM_METRICS_COLLECT_PERIOD:1}
153155
# The buffer channel size.
154156
buffer.channel_size=${SW_BUFFER_CHANNEL_SIZE:5}
155157
# The buffer size.

docs/en/setup/service-agent/java-agent/configurations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This is the properties list supported in `agent/config/agent.config`.
4747
| `correlation.value_max_length` | Max value length of each element. | SW_CORRELATION_VALUE_MAX_LENGTH | `128` |
4848
| `correlation.auto_tag_keys` | Tag the span by the key/value in the correlation context, when the keys listed here exist. | SW_CORRELATION_AUTO_TAG_KEYS | `""` |
4949
| `jvm.buffer_size` | The buffer size of collected JVM info. | SW_JVM_BUFFER_SIZE | `60 * 10` |
50+
| `jvm.metrics_collect_period` | The period in seconds of JVM metrics collection. Unit is second. | SW_JVM_METRICS_COLLECT_PERIOD | `1` |
5051
| `buffer.channel_size` | The buffer channel size. | SW_BUFFER_CHANNEL_SIZE | `5` |
5152
| `buffer.buffer_size` | The buffer size. | SW_BUFFER_BUFFER_SIZE | `300` |
5253
| `profile.active` | If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile. | SW_AGENT_PROFILE_ACTIVE | `true` |

0 commit comments

Comments
 (0)