From 333bcd48e05bc57ecfc7fe5517df5ab3239e2419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Mon, 18 Feb 2019 21:23:36 +0800 Subject: [PATCH] Provide slow database rule document. (#2253) --- README.md | 1 + docs/en/setup/backend/backend-setup.md | 2 ++ docs/en/setup/backend/slow-db-statement.md | 14 ++++++++++++++ .../trace/provider/DBLatencyThresholds.java | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 docs/en/setup/backend/slow-db-statement.md diff --git a/README.md b/README.md index 747646cee..77d043453 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The core features are following. - Slow services and endpoints detected - Performance optimization - Distributed tracing and context propagation +- Database access metric. Detect slow database access statements(including SQL statements). - Alarm diff --git a/docs/en/setup/backend/backend-setup.md b/docs/en/setup/backend/backend-setup.md index 13edff0d4..0c30535f9 100644 --- a/docs/en/setup/backend/backend-setup.md +++ b/docs/en/setup/backend/backend-setup.md @@ -68,6 +68,8 @@ Choose the one you like, we are also welcome anyone to contribute new storage im are harmless, at least our default receivers are. You would set and active all receivers provided. 1. Do [trace sampling](trace-sampling.md) at backend. This sample keep the metric accurate, only don't save some of traces in storage based on rate. +1. Follow [slow DB statement threshold](slow-db-statement.md) config document to understand that, +how to detect the Slow database statements(including SQL statements) in your system. 1. Official [OAL scripts](../../guides/backend-oal-scripts.md). As you known from our [OAL introduction](../../concepts-and-designs/oal.md), most of backend analysis capabilities based on the scripts. Here is the description of official scripts, which helps you to understand which metric data are in process, also could be used in alarm. diff --git a/docs/en/setup/backend/slow-db-statement.md b/docs/en/setup/backend/slow-db-statement.md new file mode 100644 index 000000000..c8bb54eed --- /dev/null +++ b/docs/en/setup/backend/slow-db-statement.md @@ -0,0 +1,14 @@ +# Slow Database Statement +Slow Database statements are significant important to find out the bottleneck of the system, which relied on Database. + +Slow DB statements are based on sampling, right now, the core samples top 50 slowest in every 10 minutes. +But duration of those statements must be slower than threshold. + +The setting format is following, unit is millisecond. +> database-type:thresholdValue,database-type2:thresholdValue2 + +Default setting is `default:200,mongodb:100`. `Reserved DB type` is **default**, which be as default threshold for all +database types, except set explicitly. + +**Notice**, the threshold should not be too small, like `1ms`. Functionally, it works, but would cost OAP performance issue, +if your system statement access time are mostly more than 1ms. \ No newline at end of file diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/DBLatencyThresholds.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/DBLatencyThresholds.java index b66c8900a..a0fbbecc8 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/DBLatencyThresholds.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/DBLatencyThresholds.java @@ -32,7 +32,7 @@ public class DBLatencyThresholds { for (String setting : settings) { String[] typeValue = setting.split(":"); if (typeValue.length == 2) { - thresholds.put(typeValue[0].toLowerCase(), Integer.parseInt(typeValue[1])); + thresholds.put(typeValue[0].trim().toLowerCase(), Integer.parseInt(typeValue[1].trim())); } } if (!thresholds.containsKey("default")) {