diff --git a/CHANGES.md b/CHANGES.md index 0066b0a57b..67ebcbf918 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,7 +20,8 @@ Release Notes. * Add tags `mq.message.keys` and `mq.message.tags` for RocketMQ producer span * Clean the trace context which injected into Pulsar MessageImpl after the instance recycled * Fix In the higher version of mysql-connector-java 8x, there is an error in the value of db.instance. -* Add support for KafkaClients 3.2.x +* Add support for KafkaClients 3.x. +* Support to customize the collect period of JVM relative metrics. #### Documentation diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java index d9a191f427..6b87eb10a0 100755 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java @@ -273,6 +273,10 @@ public static class Jvm { * The buffer size of collected JVM info. */ public static int BUFFER_SIZE = 60 * 10; + /** + * The period in seconds of JVM metrics collection. + */ + public static int METRICS_COLLECT_PERIOD = 1; } public static class Log { diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java index beca07afa5..ff6f6234e6 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java @@ -25,6 +25,7 @@ import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor; import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory; import org.apache.skywalking.apm.agent.core.boot.ServiceManager; +import org.apache.skywalking.apm.agent.core.conf.Config; import org.apache.skywalking.apm.agent.core.jvm.clazz.ClassProvider; import org.apache.skywalking.apm.agent.core.jvm.cpu.CPUProvider; import org.apache.skywalking.apm.agent.core.jvm.gc.GCProvider; @@ -66,7 +67,7 @@ public void handle(Throwable t) { LOGGER.error("JVMService produces metrics failure.", t); } } - ), 0, 1, TimeUnit.SECONDS); + ), 0, Config.Jvm.METRICS_COLLECT_PERIOD, TimeUnit.SECONDS); sendMetricFuture = Executors.newSingleThreadScheduledExecutor( new DefaultNamedThreadFactory("JVMService-consume")) .scheduleAtFixedRate(new RunnableWithExceptionProtection( diff --git a/apm-sniffer/config/agent.config b/apm-sniffer/config/agent.config index 629f7f4ad1..3f8c535af0 100755 --- a/apm-sniffer/config/agent.config +++ b/apm-sniffer/config/agent.config @@ -150,6 +150,8 @@ correlation.value_max_length=${SW_CORRELATION_VALUE_MAX_LENGTH:128} correlation.auto_tag_keys=${SW_CORRELATION_AUTO_TAG_KEYS:} # The buffer size of collected JVM info. jvm.buffer_size=${SW_JVM_BUFFER_SIZE:600} +# The period in seconds of JVM metrics collection. Unit is second. +jvm.metrics_collect_period=${SW_JVM_METRICS_COLLECT_PERIOD:1} # The buffer channel size. buffer.channel_size=${SW_BUFFER_CHANNEL_SIZE:5} # The buffer size. diff --git a/docs/en/setup/service-agent/java-agent/configurations.md b/docs/en/setup/service-agent/java-agent/configurations.md index 9b6f662b5d..1514c0eb7b 100644 --- a/docs/en/setup/service-agent/java-agent/configurations.md +++ b/docs/en/setup/service-agent/java-agent/configurations.md @@ -47,6 +47,7 @@ This is the properties list supported in `agent/config/agent.config`. | `correlation.value_max_length` | Max value length of each element. | SW_CORRELATION_VALUE_MAX_LENGTH | `128` | | `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 | `""` | | `jvm.buffer_size` | The buffer size of collected JVM info. | SW_JVM_BUFFER_SIZE | `60 * 10` | +| `jvm.metrics_collect_period` | The period in seconds of JVM metrics collection. Unit is second. | SW_JVM_METRICS_COLLECT_PERIOD | `1` | | `buffer.channel_size` | The buffer channel size. | SW_BUFFER_CHANNEL_SIZE | `5` | | `buffer.buffer_size` | The buffer size. | SW_BUFFER_BUFFER_SIZE | `300` | | `profile.active` | If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile. | SW_AGENT_PROFILE_ACTIVE | `true` |