diff --git a/Cargo.lock b/Cargo.lock index 623664294..f471e52b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "arbitrary" @@ -451,9 +451,9 @@ dependencies = [ [[package]] name = "capnp" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e0676a27d3cf41fc949b3061cca99c67791a8a3baf1544b30ef712936e7e3b" +checksum = "bce4e2d41c16cf9188f47ca4d59fdcdca1f33705af211bdb41f0afbd3442f8b5" dependencies = [ "embedded-io", ] @@ -2919,9 +2919,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.2+3.3.2" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] @@ -3031,9 +3031,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -3426,18 +3426,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -3638,18 +3638,18 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", @@ -3683,9 +3683,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 30ddb8bbc..05d1b45d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,7 @@ hdrhistogram = { version = "7.5", default-features = false } clap = "4.5.20" clap_complete = "4.5.33" # -tokio = "1.39.1" +tokio = "1.41.0" tokio-util = "0.7" tokio-stream = "0.1" futures-util = "0.3" diff --git a/g3proxy/doc/metrics/index.rst b/g3proxy/doc/metrics/index.rst index 8ce1365d0..8a8108cd6 100644 --- a/g3proxy/doc/metrics/index.rst +++ b/g3proxy/doc/metrics/index.rst @@ -81,3 +81,4 @@ The following is the common tags for all metrics: user user_site logger + runtime diff --git a/g3proxy/doc/metrics/runtime.rst b/g3proxy/doc/metrics/runtime.rst new file mode 100644 index 000000000..34db1b2aa --- /dev/null +++ b/g3proxy/doc/metrics/runtime.rst @@ -0,0 +1,37 @@ +.. _metrics_runtime: + +############### +Runtime Metrics +############### + +The metrics for runtimes that support metrics. + +The following are the tags for all logger metrics: + +* :ref:`daemon_group ` +* :ref:`stat_id ` + +* runtime_id + + Show the runtime ID / label. + + There maybe many instances for the same runtime type, this field is used to distinguish between them. + +.. _metrics_runtime_tokio: + +Tokio Runtime Metrics +===================== + +The metrics from tokio runtime. + +* runtime.tokio.alive_tasks + + **type**: gauge + + Show the current number of alive tasks in the runtime. + +* runtime.tokio.global_queue_depth + + **type**: gauge + + Show the number of tasks currently scheduled in the runtime's global queue. diff --git a/g3tiles/doc/configuration/values/db.rst b/g3tiles/doc/configuration/values/db.rst new file mode 100644 index 000000000..5719daec1 --- /dev/null +++ b/g3tiles/doc/configuration/values/db.rst @@ -0,0 +1,82 @@ +.. _configure_db_value_types: + +** +DB +** + +.. _conf_value_db_redis: + +redis +===== + +**yaml type**: map + +Set the redis database address and connection params. + +The following fields are supported: + +* addr + + **required**, **type**: :ref:`upstream str ` + + Set the address of the redis instance. The default port is 6379 which can be omitted. + +* tls_client + + **optional**, **type**: :ref:`rustls client config ` + + Enable tls and set the config. + + **default**: not set + + .. versionadded:: 1.9.7 + +* tls_name + + **optional**, **type**: :ref:`tls name ` + + Set the tls server name to verify peer certificate. + + **default**: not set + + .. versionadded:: 1.9.7 + +* db + + **optional**, **type**: int + + Set the database. + + **default**: 0 + +* username + + **optional**, **type**: str + + Set the username for redis 6 database if needed. It is required if connect to an ACL enabled redis 6 database. + + **default**: not set + +* password + + **optional**, **type**: str + + Set the password. + + **default**: not set + +* connect_timeout + + **optional**, **type**: :ref:`humanize duration ` + + Set the connect timeout. + + **default**: 5s + +* response_timeout + + **optional**, **type**: :ref:`humanize duration ` + + Set the read timeout for redis command response. + + **default**: 2s, **alias**: read_timeout diff --git a/g3tiles/doc/configuration/values/index.rst b/g3tiles/doc/configuration/values/index.rst index 7635cccde..c1838c7bb 100644 --- a/g3tiles/doc/configuration/values/index.rst +++ b/g3tiles/doc/configuration/values/index.rst @@ -10,6 +10,7 @@ The meanings and formats of them are described as follows: base fs + db network acl tls diff --git a/g3tiles/doc/metrics/index.rst b/g3tiles/doc/metrics/index.rst index 241af8bfa..2a16b7115 100644 --- a/g3tiles/doc/metrics/index.rst +++ b/g3tiles/doc/metrics/index.rst @@ -56,3 +56,4 @@ The following is the common tags for all metrics: server logger backend/index + runtime diff --git a/g3tiles/doc/metrics/runtime.rst b/g3tiles/doc/metrics/runtime.rst new file mode 100644 index 000000000..34db1b2aa --- /dev/null +++ b/g3tiles/doc/metrics/runtime.rst @@ -0,0 +1,37 @@ +.. _metrics_runtime: + +############### +Runtime Metrics +############### + +The metrics for runtimes that support metrics. + +The following are the tags for all logger metrics: + +* :ref:`daemon_group ` +* :ref:`stat_id ` + +* runtime_id + + Show the runtime ID / label. + + There maybe many instances for the same runtime type, this field is used to distinguish between them. + +.. _metrics_runtime_tokio: + +Tokio Runtime Metrics +===================== + +The metrics from tokio runtime. + +* runtime.tokio.alive_tasks + + **type**: gauge + + Show the current number of alive tasks in the runtime. + +* runtime.tokio.global_queue_depth + + **type**: gauge + + Show the number of tasks currently scheduled in the runtime's global queue. diff --git a/lib/g3-daemon/src/runtime/metrics.rs b/lib/g3-daemon/src/runtime/metrics.rs index 1b1a8df7c..646d934db 100644 --- a/lib/g3-daemon/src/runtime/metrics.rs +++ b/lib/g3-daemon/src/runtime/metrics.rs @@ -26,6 +26,7 @@ use crate::metrics::TAG_KEY_STAT_ID; const TAG_KEY_RUNTIME_ID: &str = "runtime_id"; const METRIC_NAME_RUNTIME_TOKIO_ALIVE_TASKS: &str = "runtime.tokio.alive_tasks"; +const METRIC_NAME_RUNTIME_TOKIO_GLOBAL_QUEUE_DEPTH: &str = "runtime.tokio.global_queue_depth"; static TOKIO_STATS_VEC: Mutex> = Mutex::new(Vec::new()); @@ -66,4 +67,11 @@ fn emit_tokio_stats(client: &mut StatsdClient, v: &mut TokioStatsValue) { &common_tags, ) .send(); + client + .gauge_with_tags( + METRIC_NAME_RUNTIME_TOKIO_GLOBAL_QUEUE_DEPTH, + v.stats.global_queue_depth(), + &common_tags, + ) + .send(); }