From fec4124c55d63786baef8440ec8c100c1ca51386 Mon Sep 17 00:00:00 2001 From: kazusa <409053122@qq.com> Date: Fri, 22 Aug 2025 14:44:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E9=9B=86=E9=A2=91=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/datacarrier/buffer/Channels.java | 1 + apm-sniffer/config/agent.config | 90 ++++++++++++++----- .../skywalking/{Main.java => MetricDemo.java} | 8 +- 3 files changed, 74 insertions(+), 25 deletions(-) rename debug-demo/src/main/java/org/apache/skywalking/{Main.java => MetricDemo.java} (82%) diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java index 5f7137e7e..42e2eb369 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java @@ -37,6 +37,7 @@ public class Channels { bufferChannels = new QueueBuffer[channelSize]; for (int i = 0; i < channelSize; i++) { if (BufferStrategy.BLOCKING.equals(strategy)) { + // 根据缓存策略选择用CAS结构还是锁结构来缓存数据 bufferChannels[i] = new ArrayBlockingQueueBuffer<>(bufferSize, strategy); } else { bufferChannels[i] = new Buffer<>(bufferSize, strategy); diff --git a/apm-sniffer/config/agent.config b/apm-sniffer/config/agent.config index f27572a1e..75cee67b9 100755 --- a/apm-sniffer/config/agent.config +++ b/apm-sniffer/config/agent.config @@ -14,6 +14,73 @@ # See the License for the specific language governing permissions and # limitations under the License. +# ============================================================================= +# SkyWalking Agent 上报频率配置区域 +# ============================================================================= +# 以下配置用于控制Agent向OAP后端上报数据的频率和时机 +# 数值越小,上报越频繁,链路显示越及时,但会消耗更多资源 +# 数值越大,上报越少,资源消耗越少,但链路显示会有延迟 +# ============================================================================= + +# ============================================================================= +# 缓冲区配置 - 控制内存中缓存的数据量和刷新频率 +# ============================================================================= +# 缓冲区通道大小 - 控制并发处理的数据通道数量 +# 建议值:1-5,数值越小刷新越快,但并发处理能力越弱 +buffer.channel_size=${SW_BUFFER_CHANNEL_SIZE:1} + +# 缓冲区大小 - 控制内存中缓存的数据条数 +# 建议值:50-300,数值越小刷新越快,但可能丢失数据 +buffer.buffer_size=${SW_BUFFER_BUFFER_SIZE:100} + +# ============================================================================= +# 数据上报频率配置 - 控制各种数据的上报间隔 +# ============================================================================= +# gRPC连接状态检查间隔(秒)- 检查与后端的连接状态 +# 建议值:5-30秒,数值越小检测越及时 +collector.grpc_channel_check_interval=${SW_AGENT_COLLECTOR_GRPC_CHANNEL_CHECK_INTERVAL:10} + +# Agent心跳上报周期(秒)- Agent定期向后端发送心跳 +# 建议值:5-30秒,数值越小后端越及时感知Agent状态 +collector.heartbeat_period=${SW_AGENT_COLLECTOR_HEARTBEAT_PERIOD:10} + +# 实例属性上报周期因子 - 实例属性上报间隔 = 心跳周期 × 此因子 +# 建议值:1-10,数值越小属性更新越及时 +collector.properties_report_period_factor=${SW_AGENT_COLLECTOR_PROPERTIES_REPORT_PERIOD_FACTOR:5} + +# gRPC上游超时时间(秒)- 发送数据到后端的超时时间 +# 建议值:3-30秒,数值越小失败检测越及时 +collector.grpc_upstream_timeout=${SW_AGENT_COLLECTOR_GRPC_UPSTREAM_TIMEOUT:5} + +# 获取性能分析任务列表间隔(秒)- 获取新的性能分析任务 +# 建议值:5-30秒,数值越小任务获取越及时 +collector.get_profile_task_interval=${SW_AGENT_COLLECTOR_GET_PROFILE_TASK_INTERVAL:10} + +# 获取Agent动态配置间隔(秒)- 获取后端下发的动态配置 +# 建议值:5-30秒,数值越小配置更新越及时 +collector.get_agent_dynamic_config_interval=${SW_AGENT_COLLECTOR_GET_AGENT_DYNAMIC_CONFIG_INTERVAL:10} + +# ============================================================================= +# 指标数据上报配置 +# ============================================================================= +# JVM指标收集周期(秒)- JVM相关指标的上报间隔 +# 建议值:1-10秒,数值越小监控越实时 +jvm.metrics_collect_period=${SW_JVM_METRICS_COLLECT_PERIOD:1} + +# 指标数据上报间隔(秒)- 各种业务指标的上报间隔 +# 建议值:3-20秒,数值越小指标更新越及时 +meter.report_interval=${SW_METER_REPORT_INTERVAL:5} + +# ============================================================================= +# 后端服务地址配置 +# ============================================================================= +# OAP后端服务地址 - 数据上报的目标地址 +collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800} + +# ============================================================================= +# 其他配置区域 +# ============================================================================= + # The service name in UI # ${service name} = [${group name}::]${logic name} # The group name is optional only. @@ -86,21 +153,6 @@ agent.enable=${SW_AGENT_ENABLE:true} # Limit the length of the ipv4 list size. osinfo.ipv4_list_size=${SW_AGENT_OSINFO_IPV4_LIST_SIZE:10} -# grpc channel status check interval. -collector.grpc_channel_check_interval=${SW_AGENT_COLLECTOR_GRPC_CHANNEL_CHECK_INTERVAL:30} -# Agent heartbeat report period. Unit, second. -collector.heartbeat_period=${SW_AGENT_COLLECTOR_HEARTBEAT_PERIOD:30} -# The agent sends the instance properties to the backend every -# collector.heartbeat_period * collector.properties_report_period_factor seconds -collector.properties_report_period_factor=${SW_AGENT_COLLECTOR_PROPERTIES_REPORT_PERIOD_FACTOR:10} -# Backend service addresses. -collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800} -# How long grpc client will timeout in sending data to upstream. Unit is second. -collector.grpc_upstream_timeout=${SW_AGENT_COLLECTOR_GRPC_UPSTREAM_TIMEOUT:30} -# Sniffer get profile task list interval. -collector.get_profile_task_interval=${SW_AGENT_COLLECTOR_GET_PROFILE_TASK_INTERVAL:20} -# Sniffer get agent dynamic config interval. -collector.get_agent_dynamic_config_interval=${SW_AGENT_COLLECTOR_GET_AGENT_DYNAMIC_CONFIG_INTERVAL:20} # If true, skywalking agent will enable periodically resolving DNS to update receiver service addresses. collector.is_resolve_dns_periodically=${SW_AGENT_COLLECTOR_IS_RESOLVE_DNS_PERIODICALLY:false} @@ -146,12 +198,6 @@ 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. -buffer.buffer_size=${SW_BUFFER_BUFFER_SIZE:300} # If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile. profile.active=${SW_AGENT_PROFILE_ACTIVE:true} # Parallel monitor endpoint thread count @@ -172,8 +218,6 @@ asyncprofiler.max_duration=${SW_AGENT_ASYNC_PROFILER_MAX_DURATION:1200} asyncprofiler.output_path=${SW_AGENT_ASYNC_PROFILER_OUTPUT_PATH:} # If true, the agent collects and reports metrics to the backend. meter.active=${SW_METER_ACTIVE:true} -# Report meters interval. The unit is second -meter.report_interval=${SW_METER_REPORT_INTERVAL:20} # Max size of the meter pool meter.max_meter_size=${SW_METER_MAX_METER_SIZE:500} # The max size of message to send to server.Default is 10 MB diff --git a/debug-demo/src/main/java/org/apache/skywalking/Main.java b/debug-demo/src/main/java/org/apache/skywalking/MetricDemo.java similarity index 82% rename from debug-demo/src/main/java/org/apache/skywalking/Main.java rename to debug-demo/src/main/java/org/apache/skywalking/MetricDemo.java index 840f62dab..2e547d27e 100644 --- a/debug-demo/src/main/java/org/apache/skywalking/Main.java +++ b/debug-demo/src/main/java/org/apache/skywalking/MetricDemo.java @@ -6,8 +6,8 @@ package org.apache.skywalking; */ //TIP To Run code, press or // click the icon in the gutter. -public class Main { - public static void main(String[] args) { +public class MetricDemo { + public static void main(String[] args) throws InterruptedException { //TIP Press with your caret at the highlighted text // to see how IntelliJ IDEA suggests fixing it. System.out.printf("Hello and welcome!"); @@ -17,5 +17,9 @@ public class Main { // for you, but you can always add more by pressing . System.out.println("i = " + i); } + + while (true) { + Thread.sleep(1); + } } } \ No newline at end of file