You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/12/26 14:34:36 UTC

[skywalking-java] branch main updated: Support to customize the collect period of JVM relative metrics. (#428)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git


The following commit(s) were added to refs/heads/main by this push:
     new a68b447878 Support to customize the collect period of JVM relative metrics. (#428)
a68b447878 is described below

commit a68b4478787b94707a453e8d84afb5d07c479b0d
Author: dylanforest <dy...@foxmail.com>
AuthorDate: Mon Dec 26 22:34:30 2022 +0800

    Support to customize the collect period of JVM relative metrics. (#428)
---
 CHANGES.md                                                            | 3 ++-
 .../main/java/org/apache/skywalking/apm/agent/core/conf/Config.java   | 4 ++++
 .../java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java     | 3 ++-
 apm-sniffer/config/agent.config                                       | 2 ++
 docs/en/setup/service-agent/java-agent/configurations.md              | 1 +
 5 files changed, 11 insertions(+), 2 deletions(-)

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 class Config {
          * 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.BootService;
 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 class JVMService implements BootService, Runnable {
                                                    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.                                                                                                                                                                                                                                                                                                                                                                                                              [...]
 | `correlation.auto_tag_keys`                               | Tag the span by the key/value in the correlation context, when the keys listed here exist.                                                                                                                                                                                                                                                                                                                                                     [...]
 | `jvm.buffer_size`                                         | The buffer size of collected JVM info.                                                                                                                                                                                                                                                                                                                                                                                                         [...]
+| `jvm.metrics_collect_period`                              | The period in seconds of JVM metrics collection.  Unit is second.                                                                                                                                                                                                                                                                                                                                                                              [...]
 | `buffer.channel_size`                                     | The buffer channel size.                                                                                                                                                                                                                                                                                                                                                                                                                       [...]
 | `buffer.buffer_size`                                      | The buffer size.                                                                                                                                                                                                                                                                                                                                                                                                                               [...]
 | `profile.active`                                          | If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile.                                                                                                                                                                                                                                                                                                                                  [...]