From 11892e44f82338daa1a4d46500c8a0d7d90035bd Mon Sep 17 00:00:00 2001 From: dylanforest Date: Thu, 22 Dec 2022 16:40:46 +0800 Subject: [PATCH 1/3] Support to customize the collect period of JVM relative metrics. --- CHANGES.md | 1 + .../org/apache/skywalking/apm/agent/core/conf/Config.java | 4 ++++ .../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, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 9c4cdb3b94..536615fb98 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Release Notes. * Add [Micrometer Observation](https://github.com/micrometer-metrics/micrometer/) support * 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 +* 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..27e815cca8 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. +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..f0e5099cf3 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. | 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` | From 0af77dea4d4cd23f13a555b3a5d37ac379a2435a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Mon, 26 Dec 2022 21:52:29 +0800 Subject: [PATCH 2/3] Update docs/en/setup/service-agent/java-agent/configurations.md --- docs/en/setup/service-agent/java-agent/configurations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/setup/service-agent/java-agent/configurations.md b/docs/en/setup/service-agent/java-agent/configurations.md index f0e5099cf3..1514c0eb7b 100644 --- a/docs/en/setup/service-agent/java-agent/configurations.md +++ b/docs/en/setup/service-agent/java-agent/configurations.md @@ -47,7 +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. | SW_JVM_METRICS_COLLECT_PERIOD | `1` | +| `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` | From 87fe00128f013e9352b112b6b14ad694e7e891e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Mon, 26 Dec 2022 21:52:50 +0800 Subject: [PATCH 3/3] Update apm-sniffer/config/agent.config --- apm-sniffer/config/agent.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-sniffer/config/agent.config b/apm-sniffer/config/agent.config index 27e815cca8..3f8c535af0 100755 --- a/apm-sniffer/config/agent.config +++ b/apm-sniffer/config/agent.config @@ -150,7 +150,7 @@ 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. +# 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}