From 29ec2f306de718888c7e0f2aefd7dafd00ab121f Mon Sep 17 00:00:00 2001 From: mythrnr <32730704+mythrnr@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:08:46 +0900 Subject: [PATCH] feat: Make span when call DynamoDB API. (#232) * feat: enable to create span on run DynamoDB operation by activating feature tracing. * fix: span setting * fix: exclude service from docker compose * chore: run cargo update * chore: update README, and revert docker compose setting. * fix: propagate feature flag * fix: rust toolchain version in CI * fix: clippy warnings --- .github/workflows/ci.yml | 2 +- Cargo.lock | 397 +++++++++++------- README.md | 16 + makefile | 7 +- raiden-derive/Cargo.toml | 4 + raiden-derive/src/ops/batch_delete.rs | 24 +- raiden-derive/src/ops/batch_get.rs | 23 +- raiden-derive/src/ops/delete.rs | 24 +- raiden-derive/src/ops/get.rs | 25 +- raiden-derive/src/ops/put.rs | 21 +- raiden-derive/src/ops/query.rs | 19 +- raiden-derive/src/ops/scan.rs | 23 +- raiden-derive/src/ops/shared.rs | 35 ++ raiden-derive/src/ops/update.rs | 21 +- raiden/Cargo.toml | 10 +- raiden/examples/delete.rs | 13 + raiden/examples/get_with_reserved.rs | 13 + raiden/examples/get_with_retries.rs | 15 +- raiden/examples/hello.rs | 13 + raiden/examples/last_key.rs | 13 + raiden/examples/put.rs | 13 + raiden/examples/query.rs | 13 + raiden/examples/query_rename.rs | 13 + raiden/examples/scan.rs | 13 + raiden/examples/scan_with_filter.rs | 13 + raiden/examples/transact_write.rs | 13 + .../transact_write_with_http_client.rs | 13 + raiden/examples/update.rs | 13 + raiden/examples/with_http_client.rs | 13 + raiden/src/condition/mod.rs | 22 +- raiden/src/errors/transaction.rs | 2 +- raiden/src/filter_expression/mod.rs | 76 ++-- raiden/src/key_condition/mod.rs | 42 +- raiden/src/lib.rs | 2 +- raiden/src/ops/transact_write.rs | 6 + raiden/src/update_expression/add.rs | 4 +- raiden/src/update_expression/delete.rs | 4 +- raiden/src/update_expression/set.rs | 32 +- raiden/tests/all/batch_delete.rs | 4 +- raiden/tests/all/batch_get.rs | 14 +- raiden/tests/all/condition.rs | 1 + raiden/tests/all/delete.rs | 2 + raiden/tests/all/filter_expression.rs | 1 + raiden/tests/all/key_condition.rs | 1 + raiden/tests/all/transact_write.rs | 1 + rust-toolchain | 2 +- 46 files changed, 766 insertions(+), 285 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34d41018..6ff36476 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.66.1 + toolchain: 1.67.0 override: true - name: Install deps run: sudo apt-get install libssl-dev diff --git a/Cargo.lock b/Cargo.lock index a55bcc8f..289d32cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -54,13 +54,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -104,9 +104,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -219,6 +219,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "deranged" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] + [[package]] name = "diff" version = "0.1.13" @@ -255,40 +264,16 @@ dependencies = [ "winapi", ] -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "errno" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -378,7 +363,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -536,12 +521,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.27" @@ -596,16 +575,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -642,17 +621,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - [[package]] name = "itoa" version = "1.0.9" @@ -676,21 +644,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -702,6 +670,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "md-5" version = "0.9.1" @@ -757,11 +734,21 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -803,7 +790,7 @@ version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -820,7 +807,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -841,6 +828,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.11.2" @@ -890,6 +883,12 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -906,16 +905,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "pretty_env_logger" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" -dependencies = [ - "env_logger", - "log", -] - [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -924,9 +913,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -971,7 +960,7 @@ dependencies = [ "again", "base64 0.21.4", "pretty_assertions", - "pretty_env_logger", + "raiden", "raiden-derive", "rusoto_core", "rusoto_credential", @@ -982,7 +971,10 @@ dependencies = [ "serde_derive", "serde_json", "thiserror", + "time 0.3.30", "tokio", + "tracing", + "tracing-subscriber", "uuid", ] @@ -994,7 +986,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1116,32 +1108,47 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.6" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" @@ -1152,12 +1159,26 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce3045ffa7c981a6ee93f640b538952e155f1ae3a1a02b84547fc7a56b7059a" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys", +] + [[package]] name = "rusoto_core" version = "0.48.0" @@ -1252,7 +1273,7 @@ dependencies = [ "libc", "rand 0.3.23", "rustc-serialize", - "time", + "time 0.1.45", ] [[package]] @@ -1278,11 +1299,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.15" +version = "0.38.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -1296,7 +1317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", - "ring", + "ring 0.16.20", "sct", "webpki", ] @@ -1369,8 +1390,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -1398,28 +1419,28 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1446,6 +1467,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.2.0" @@ -1502,6 +1532,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "subtle" version = "2.4.1" @@ -1521,9 +1557,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -1543,15 +1579,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "termcolor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.49" @@ -1569,7 +1596,17 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", ] [[package]] @@ -1583,11 +1620,40 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] + [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", @@ -1609,7 +1675,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1655,22 +1721,64 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" dependencies = [ - "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "time 0.3.30", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -1703,15 +1811,27 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "uuid" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ "getrandom 0.2.10", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -1772,7 +1892,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -1806,7 +1926,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1844,12 +1964,12 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.2" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring", - "untrusted", + "ring 0.17.4", + "untrusted 0.9.0", ] [[package]] @@ -1868,15 +1988,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1884,10 +1995,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] diff --git a/README.md b/README.md index 797fca4f..90ed08e1 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,22 @@ async fn main() { } ``` +## Support `tokio-rs/tracing` + +`raiden` supports making span for Tracing ( span name is `dynamodb::action` with table name and api name in field ). +To activate this feature, you need to specify `tracing` feature in your `Cargo.toml`. And your crate needs `tracing` . + +```toml +# Example +[dependencies] +raiden = { + tag = "0.0.76", + git = "https://github.com/raiden-rs/raiden-dynamo.git", + features = [ "tracing"] +} +tracing = "0.1" +``` + ## Development ### Requirements diff --git a/makefile b/makefile index a5624a5d..d89c27fb 100644 --- a/makefile +++ b/makefile @@ -1,21 +1,24 @@ -.PHONY: dynamo test lint - +.PHONY: dynamo dynamo: - docker rm -f dynamodb - docker stop dynamodb docker run --rm -d --name dynamodb -p 8000:8000 amazon/dynamodb-local:latest deno run --allow-net=localhost:8000 --allow-env --no-check ./setup/setup.ts +.PHONY: test test: make dynamo cargo test -- --test-threads=1 +.PHONY: lint lint: cargo clippy --all-targets -- -D warnings cargo clippy --all-targets --no-default-features --features rustls -- -D warnings + cargo clippy --all-targets --features tracing -- -D warnings .PHONY: check-deps check-deps: cargo machete || echo cargo +nightly udeps --all-targets cargo +nightly udeps --all-targets --no-default-features --features rustls + cargo +nightly udeps --all-targets --features tracing diff --git a/raiden-derive/Cargo.toml b/raiden-derive/Cargo.toml index 44e888d5..263d251f 100644 --- a/raiden-derive/Cargo.toml +++ b/raiden-derive/Cargo.toml @@ -15,3 +15,7 @@ ident_case = "^1.0.1" proc-macro2 = "^1.0.67" quote = "^1.0.33" syn = "^2.0.37" + +[features] +default = [] +tracing = [] diff --git a/raiden-derive/src/ops/batch_delete.rs b/raiden-derive/src/ops/batch_delete.rs index 9f72781a..f1b0fb48 100644 --- a/raiden-derive/src/ops/batch_delete.rs +++ b/raiden-derive/src/ops/batch_delete.rs @@ -92,6 +92,19 @@ pub(crate) fn expand_batch_delete( } }; + let api_call_token = super::api_call_token!("batch_write_item"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(&self.table_name, &self.client, input).await? }, + quote! { table_name: &str, }, + ) + } else { + ( + quote! { #builder_name::inner_run(&self.client, input).await? }, + quote! {}, + ) + }; + quote! { #client_trait @@ -128,7 +141,8 @@ pub(crate) fn expand_batch_delete( ..std::default::Default::default() }; - let result = self.client.batch_write_item(input).await?; + let result = #call_inner_run; + let mut unprocessed_items = match result.unprocessed_items { None => { // move on to the next iteration to check if there are unprocessed @@ -165,6 +179,14 @@ pub(crate) fn expand_batch_delete( unprocessed_items, }) } + + async fn inner_run( + #inner_run_args + client: &::raiden::DynamoDbClient, + input: ::raiden::BatchWriteItemInput, + ) -> Result<::raiden::BatchWriteItemOutput, ::raiden::RaidenError> { + Ok(#api_call_token?) + } } } } diff --git a/raiden-derive/src/ops/batch_get.rs b/raiden-derive/src/ops/batch_get.rs index 332aeff4..018bf7ea 100644 --- a/raiden-derive/src/ops/batch_get.rs +++ b/raiden-derive/src/ops/batch_get.rs @@ -109,6 +109,19 @@ pub(crate) fn expand_batch_get( } }; + let api_call_token = super::api_call_token!("batch_get_item"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(&self.table_name, &self.client, input).await? }, + quote! { table_name: &str, }, + ) + } else { + ( + quote! { #builder_name::inner_run(&self.client, input).await? }, + quote! {}, + ) + }; + quote! { #client_trait @@ -150,7 +163,7 @@ pub(crate) fn expand_batch_get( .request_items .insert(self.table_name.to_string(), item); - let res = self.client.batch_get_item(input).await?; + let res = #call_inner_run; if self.keys.is_empty() { unprocessed_retry -= 1; @@ -190,6 +203,14 @@ pub(crate) fn expand_batch_get( } } } + + async fn inner_run( + #inner_run_args + client: &::raiden::DynamoDbClient, + input: ::raiden::BatchGetItemInput, + ) -> Result<::raiden::BatchGetItemOutput, ::raiden::RaidenError> { + Ok(#api_call_token?) + } } } } diff --git a/raiden-derive/src/ops/delete.rs b/raiden-derive/src/ops/delete.rs index 56e77fc4..23a7cacb 100644 --- a/raiden-derive/src/ops/delete.rs +++ b/raiden-derive/src/ops/delete.rs @@ -60,6 +60,19 @@ pub(crate) fn expand_delete_item( } }; + let api_call_token = super::api_call_token!("delete_item"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(&self.input.table_name.clone(), &self.client, self.input).await? }, + quote! { table_name: &str, }, + ) + } else { + ( + quote! { #builder_name::inner_run(&self.client, self.input).await? }, + quote! {}, + ) + }; + quote! { #client_trait @@ -87,7 +100,16 @@ pub(crate) fn expand_delete_item( } pub async fn run(self) -> Result<(), ::raiden::RaidenError> { - let res = self.client.delete_item(self.input).await?; + #call_inner_run; + Ok(()) + } + + async fn inner_run( + #inner_run_args + client: &::raiden::DynamoDbClient, + input: ::raiden::DeleteItemInput, + ) -> Result<(), ::raiden::RaidenError> { + #api_call_token?; Ok(()) } } diff --git a/raiden-derive/src/ops/get.rs b/raiden-derive/src/ops/get.rs index 5cb0e122..755da86e 100644 --- a/raiden-derive/src/ops/get.rs +++ b/raiden-derive/src/ops/get.rs @@ -73,6 +73,19 @@ pub(crate) fn expand_get_item( } }; + let api_call_token = super::api_call_token!("get_item"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(input.table_name.clone(), client, input).await }, + quote! { table_name: String, }, + ) + } else { + ( + quote! { #builder_name::inner_run(client, input).await }, + quote! {}, + ) + }; + quote! { #client_trait @@ -96,14 +109,16 @@ pub(crate) fn expand_get_item( policy.retry_if(move || { let client = client.clone(); let input = input.clone(); - async { - #builder_name::inner_run(client, input).await - } + async { #call_inner_run } }, self.condition).await } - async fn inner_run(client: ::raiden::DynamoDbClient, input: ::raiden::GetItemInput) -> Result<::raiden::get::GetOutput<#struct_name>, ::raiden::RaidenError> { - let res = client.get_item(input).await?; + async fn inner_run( + #inner_run_args + client: ::raiden::DynamoDbClient, + input: ::raiden::GetItemInput, + ) -> Result<::raiden::get::GetOutput<#struct_name>, ::raiden::RaidenError> { + let res = #api_call_token?; if res.item.is_none() { return Err(::raiden::RaidenError::ResourceNotFound("resource not found".to_owned())); }; diff --git a/raiden-derive/src/ops/put.rs b/raiden-derive/src/ops/put.rs index 9d09eacf..ffd9db1c 100644 --- a/raiden-derive/src/ops/put.rs +++ b/raiden-derive/src/ops/put.rs @@ -96,6 +96,19 @@ pub(crate) fn expand_put_item( .collect(); let default_types = expand_default_type_variables(&required_field_idents); + let api_call_token = super::api_call_token!("put_item"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(input.table_name.clone(), client, input).await }, + quote! { table_name: String, }, + ) + } else { + ( + quote! { #builder_name::inner_run(client, input).await }, + quote! {}, + ) + }; + quote! { #[derive(Debug, Clone, PartialEq, ::raiden::Builder)] pub struct #item_input_name { @@ -195,9 +208,7 @@ pub(crate) fn expand_put_item( let res = policy.retry_if(move || { let input = input.clone(); let client = client.clone(); - async { - #builder_name::inner_run(client, input).await - } + async { #call_inner_run } }, self.condition).await?; Ok(::raiden::put::PutOutput { @@ -207,11 +218,11 @@ pub(crate) fn expand_put_item( } async fn inner_run( + #inner_run_args client: ::raiden::DynamoDbClient, input: ::raiden::PutItemInput, ) -> Result<::raiden::PutItemOutput, ::raiden::RaidenError> { - let res = client.put_item(input).await?; - Ok(res) + Ok(#api_call_token?) } } } diff --git a/raiden-derive/src/ops/query.rs b/raiden-derive/src/ops/query.rs index a7c162b7..7f8e8215 100644 --- a/raiden-derive/src/ops/query.rs +++ b/raiden-derive/src/ops/query.rs @@ -14,6 +14,18 @@ pub(crate) fn expand_query( let key_condition_token_name = format_ident!("{}KeyConditionToken", struct_name); let from_item = super::expand_attr_to_item(format_ident!("res_item"), fields, rename_all_type); + let api_call_token = super::api_call_token!("query"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(input.table_name.clone(), client, input).await }, + quote! { table_name: String, }, + ) + } else { + ( + quote! { #builder_name::inner_run(client, input).await }, + quote! {}, + ) + }; quote! { pub trait #trait_name { @@ -134,9 +146,7 @@ pub(crate) fn expand_query( let res: #query_output_item = policy.retry_if(move || { let input = input.clone(); let client = client.clone(); - async { - #builder_name::inner_run(client, input).await - } + async { #call_inner_run } }, self.condition).await?; if let Some(res_items) = res.items { @@ -175,10 +185,11 @@ pub(crate) fn expand_query( } async fn inner_run( + #inner_run_args client: ::raiden::DynamoDbClient, input: ::raiden::QueryInput, ) -> Result<#query_output_item, ::raiden::RaidenError> { - let res = client.query(input).await?; + let res = #api_call_token?; Ok(#query_output_item { consumed_capacity: res.consumed_capacity, count: res.count, diff --git a/raiden-derive/src/ops/scan.rs b/raiden-derive/src/ops/scan.rs index 82a3cb09..039c7b9f 100644 --- a/raiden-derive/src/ops/scan.rs +++ b/raiden-derive/src/ops/scan.rs @@ -11,6 +11,18 @@ pub(crate) fn expand_scan( let filter_expression_token_name = format_ident!("{}FilterExpressionToken", struct_name); let from_item = super::expand_attr_to_item(format_ident!("res_item"), fields, rename_all_type); + let api_call_token = super::api_call_token!("scan"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(&self.input.table_name, &self.client, self.input.clone()).await? }, + quote! { table_name: &str, }, + ) + } else { + ( + quote! { #builder_name::inner_run(&self.client, self.input.clone()).await? }, + quote! {}, + ) + }; quote! { pub trait #trait_name { @@ -86,7 +98,8 @@ pub(crate) fn expand_scan( self.input.limit = Some(limit); } - let res = self.client.scan(self.input.clone()).await?; + let res = #call_inner_run; + if let Some(res_items) = res.items { for res_item in res_items.into_iter() { let mut res_item = res_item; @@ -115,6 +128,14 @@ pub(crate) fn expand_scan( self.input.exclusive_start_key = res.last_evaluated_key; } } + + async fn inner_run( + #inner_run_args + client: &::raiden::DynamoDbClient, + input: ::raiden::ScanInput, + ) -> Result<::raiden::ScanOutput, ::raiden::RaidenError> { + Ok(#api_call_token?) + } } } } diff --git a/raiden-derive/src/ops/shared.rs b/raiden-derive/src/ops/shared.rs index 4044fafe..015034e6 100644 --- a/raiden-derive/src/ops/shared.rs +++ b/raiden-derive/src/ops/shared.rs @@ -73,3 +73,38 @@ pub(crate) fn expand_attr_to_item( } }).collect() } + +macro_rules! api_call_token { + ($operation: literal) => { + $crate::ops::api_call_token!("table_name", "client", $operation, "input") + }; + ($table_name: literal, $client: literal, $operation: literal, $input: literal) => {{ + let table_name = ::quote::format_ident!($table_name); + let client = ::quote::format_ident!($client); + let operation = ::quote::format_ident!($operation); + let input = ::quote::format_ident!($input); + + let span_token = if cfg!(feature = "tracing") { + ::quote::quote! { + use tracing::Instrument; + let fut = fut.instrument(::tracing::debug_span!( + "dynamodb::action", + table = #table_name, + api = std::stringify!(#operation), + )); + } + } else { + ::quote::quote! {} + }; + + ::quote::quote! {{ + let fut = #client.#operation(#input); + + #span_token + + fut.await + }} + }}; +} + +pub(super) use api_call_token; diff --git a/raiden-derive/src/ops/update.rs b/raiden-derive/src/ops/update.rs index e6a7afe8..3725f763 100644 --- a/raiden-derive/src/ops/update.rs +++ b/raiden-derive/src/ops/update.rs @@ -78,6 +78,19 @@ pub(crate) fn expand_update_item( } }; + let api_call_token = super::api_call_token!("update_item"); + let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { + ( + quote! { #builder_name::inner_run(input.table_name.clone(), client, input).await }, + quote! { table_name: String, }, + ) + } else { + ( + quote! { #builder_name::inner_run(client, input).await }, + quote! {}, + ) + }; + quote! { #[derive(Debug, Clone, PartialEq)] pub struct #item_output_name { @@ -280,9 +293,7 @@ pub(crate) fn expand_update_item( let res = policy.retry_if(move || { let input = input.clone(); let client = client.clone(); - async { - #builder_name::inner_run(client, input).await - } + async { #call_inner_run } }, self.condition).await?; @@ -303,11 +314,11 @@ pub(crate) fn expand_update_item( } async fn inner_run( + #inner_run_args client: ::raiden::DynamoDbClient, input: ::raiden::UpdateItemInput, ) -> Result<::raiden::UpdateItemOutput, ::raiden::RaidenError> { - let res = client.update_item(input).await?; - Ok(res) + Ok(#api_call_token?) } } diff --git a/raiden/Cargo.toml b/raiden/Cargo.toml index 39c83266..5f079de9 100644 --- a/raiden/Cargo.toml +++ b/raiden/Cargo.toml @@ -28,13 +28,17 @@ serde = { version = "^1", features = ["derive"] } serde_derive = "^1" serde_json = "^1" thiserror = "^1" +tracing = { version = "0.1", optional = true } uuid = { version = "^1.4.1", features = ["v4"] } [dev-dependencies] -pretty_assertions = "1.3.0" -pretty_env_logger = "0.5" -tokio = "1.32.0" +pretty_assertions = "1.4.0" +raiden = { path = "./", features = ["tracing"], default_features = false } +time = "0.3.30" +tokio = "1.33.0" +tracing-subscriber = { version = "0.3.17", features = ["env-filter", "time"] } [features] default = ["rusoto_core_default", "rusoto_dynamodb_default"] rustls = ["rusoto_core_rustls", "rusoto_dynamodb_rustls"] +tracing = ["dep:tracing", "raiden-derive/tracing"] diff --git a/raiden/examples/delete.rs b/raiden/examples/delete.rs index ddc62347..65d2bdf4 100644 --- a/raiden/examples/delete.rs +++ b/raiden/examples/delete.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "QueryTestData0")] @@ -13,6 +17,15 @@ pub struct Test { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("delete=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = Test::client(Region::Custom { diff --git a/raiden/examples/get_with_reserved.rs b/raiden/examples/get_with_reserved.rs index 1f334b9b..53228283 100644 --- a/raiden/examples/get_with_reserved.rs +++ b/raiden/examples/get_with_reserved.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "ReservedTestData0")] @@ -9,6 +13,15 @@ pub struct Reserved { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("get_with_reserved=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = Reserved::client(Region::Custom { diff --git a/raiden/examples/get_with_retries.rs b/raiden/examples/get_with_retries.rs index d63b5c1d..370e8714 100644 --- a/raiden/examples/get_with_retries.rs +++ b/raiden/examples/get_with_retries.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "user")] @@ -20,8 +24,15 @@ impl RetryStrategy for MyRetryStrategy { } fn main() { - std::env::set_var("RUST_LOG", "info"); - pretty_env_logger::init(); + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("get_with_retries=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = User::client(Region::Custom { diff --git a/raiden/examples/hello.rs b/raiden/examples/hello.rs index 1f22d137..d7cbba29 100644 --- a/raiden/examples/hello.rs +++ b/raiden/examples/hello.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "user")] @@ -13,6 +17,15 @@ pub struct User { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("hello=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = User::client(Region::Custom { diff --git a/raiden/examples/last_key.rs b/raiden/examples/last_key.rs index e1e70f00..94a15872 100644 --- a/raiden/examples/last_key.rs +++ b/raiden/examples/last_key.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "LastEvaluateKeyData")] @@ -10,6 +14,15 @@ pub struct Test { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("last_key=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = Test::client(Region::Custom { diff --git a/raiden/examples/put.rs b/raiden/examples/put.rs index d138bad1..8fde2ac7 100644 --- a/raiden/examples/put.rs +++ b/raiden/examples/put.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Debug, Clone, PartialEq)] pub struct CustomId(String); @@ -35,6 +39,15 @@ pub struct User { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("put=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = User::client(Region::Custom { diff --git a/raiden/examples/query.rs b/raiden/examples/query.rs index d4851962..ac3826d8 100644 --- a/raiden/examples/query.rs +++ b/raiden/examples/query.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden, Debug)] #[allow(dead_code)] @@ -13,6 +17,15 @@ pub struct QueryTestData0 { #[tokio::main] async fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("query=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let client = QueryTestData0::client(Region::Custom { endpoint: "http://localhost:8000".into(), name: "ap-northeast-1".into(), diff --git a/raiden/examples/query_rename.rs b/raiden/examples/query_rename.rs index 999d7dce..43c22ef1 100644 --- a/raiden/examples/query_rename.rs +++ b/raiden/examples/query_rename.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "Project")] @@ -11,6 +15,15 @@ pub struct Project { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("query_rename=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = Project::client(Region::Custom { diff --git a/raiden/examples/scan.rs b/raiden/examples/scan.rs index 6700e3dd..b31fccc3 100644 --- a/raiden/examples/scan.rs +++ b/raiden/examples/scan.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden, Debug)] #[raiden(table_name = "ScanTestData0")] @@ -13,6 +17,15 @@ pub struct ScanTestData0 { #[tokio::main] async fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("scan=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let client = ScanTestData0::client(Region::Custom { endpoint: "http://localhost:8000".into(), name: "ap-northeast-1".into(), diff --git a/raiden/examples/scan_with_filter.rs b/raiden/examples/scan_with_filter.rs index f93ef805..83f92ba8 100644 --- a/raiden/examples/scan_with_filter.rs +++ b/raiden/examples/scan_with_filter.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden, Debug)] #[raiden(table_name = "ScanWithFilterTestData0")] @@ -13,6 +17,15 @@ pub struct Scan { #[tokio::main] async fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("scan_with_filter=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let client = Scan::client(Region::Custom { endpoint: "http://localhost:8000".into(), name: "ap-northeast-1".into(), diff --git a/raiden/examples/transact_write.rs b/raiden/examples/transact_write.rs index 0ea102c9..c435ef75 100644 --- a/raiden/examples/transact_write.rs +++ b/raiden/examples/transact_write.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "user")] @@ -9,6 +13,15 @@ pub struct User { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("raiden=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let tx = ::raiden::WriteTx::new(Region::Custom { diff --git a/raiden/examples/transact_write_with_http_client.rs b/raiden/examples/transact_write_with_http_client.rs index d1947dca..2a79bc45 100644 --- a/raiden/examples/transact_write_with_http_client.rs +++ b/raiden/examples/transact_write_with_http_client.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "user")] @@ -9,6 +13,15 @@ pub struct User { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("raiden=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let dispatcher = diff --git a/raiden/examples/update.rs b/raiden/examples/update.rs index 91494bca..9197d371 100644 --- a/raiden/examples/update.rs +++ b/raiden/examples/update.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden, Debug)] #[raiden(table_name = "UpdateTestData0")] @@ -11,6 +15,15 @@ pub struct Example { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("update=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = Example::client(Region::Custom { diff --git a/raiden/examples/with_http_client.rs b/raiden/examples/with_http_client.rs index cab3958f..7380acc1 100644 --- a/raiden/examples/with_http_client.rs +++ b/raiden/examples/with_http_client.rs @@ -1,4 +1,8 @@ use raiden::*; +use tracing_subscriber::{ + fmt::{format::FmtSpan, time::UtcTime}, + EnvFilter, +}; #[derive(Raiden)] #[raiden(table_name = "user")] @@ -13,6 +17,15 @@ pub struct User { } fn main() { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::new("with_http_client=debug,info")) + .with_file(true) + .with_line_number(true) + .with_span_events(FmtSpan::CLOSE) + .with_target(true) + .with_timer(UtcTime::rfc_3339()) + .init(); + let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let dispatcher = diff --git a/raiden/src/condition/mod.rs b/raiden/src/condition/mod.rs index 64fd7c26..f639b0ad 100644 --- a/raiden/src/condition/mod.rs +++ b/raiden/src/condition/mod.rs @@ -79,21 +79,21 @@ impl ConditionBuilder for ConditionFilledOrWaitOperator { impl ConditionBuilder for ConditionFilled { fn build(self) -> (String, super::AttributeNames, super::AttributeValues) { let (right_str, right_names, right_values) = match self.operator { - super::condition::Operator::And(s, m, v) => (format!("AND ({})", s), m, v), - super::condition::Operator::Or(s, m, v) => (format!("OR ({})", s), m, v), + super::condition::Operator::And(s, m, v) => (format!("AND ({s})"), m, v), + super::condition::Operator::Or(s, m, v) => (format!("OR ({s})"), m, v), }; let left_str = self.cond.to_string(); let left_names = self.cond.to_attr_names(); let left_values = self.cond.into_attr_values(); if self.not { ( - format!("NOT ({}) {}", left_str, right_str), + format!("NOT ({left_str}) {right_str}"), super::merge_map(left_names, right_names), super::merge_map(left_values, right_values), ) } else { ( - format!("{} {}", left_str, right_str), + format!("{left_str} {right_str}"), super::merge_map(left_names, right_names), super::merge_map(left_values, right_values), ) @@ -106,10 +106,10 @@ impl std::string::ToString for ConditionFunctionExpression { use crypto::digest::Digest; use crypto::md5::Md5; match self { - Self::AttributeExists(path) => format!("attribute_exists(#{})", path), - Self::AttributeNotExists(path) => format!("attribute_not_exists(#{})", path), + Self::AttributeExists(path) => format!("attribute_exists(#{path})"), + Self::AttributeNotExists(path) => format!("attribute_not_exists(#{path})"), Self::AttributeType(path, attribute_type) => { - format!("attribute_type(#{}, :type{})", path, attribute_type) + format!("attribute_type(#{path}, :type{attribute_type})") } Self::BeginsWith(path, s) => { let mut md5 = Md5::new(); @@ -137,7 +137,7 @@ impl super::ToAttrNames for ConditionFunctionExpression { | Self::AttributeType(path, _) | Self::AttributeExists(path) | Self::AttributeNotExists(path) => { - m.insert(format!("#{}", path), path.clone()); + m.insert(format!("#{path}"), path.clone()); } _ => {} } @@ -153,7 +153,7 @@ impl super::IntoAttrValues for ConditionFunctionExpression { match self { Self::AttributeType(_path, t) => { m.insert( - format!(":type{}", t), + format!(":type{t}"), super::AttributeValue { s: Some(t.to_string()), ..super::AttributeValue::default() @@ -240,8 +240,8 @@ pub enum AttrOrPlaceholder { impl std::string::ToString for AttrOrPlaceholder { fn to_string(&self) -> String { match self { - Self::Placeholder(p) => format!(":{}", p), - Self::Attr(a) => format!("#{}", a), + Self::Placeholder(p) => format!(":{p}"), + Self::Attr(a) => format!("#{a}"), } } } diff --git a/raiden/src/errors/transaction.rs b/raiden/src/errors/transaction.rs index be18825e..2bd36e8d 100644 --- a/raiden/src/errors/transaction.rs +++ b/raiden/src/errors/transaction.rs @@ -76,7 +76,7 @@ impl fmt::Display for RaidenTransactionCancellationReasons { }) .collect::>() .join(", "); - f.write_fmt(format_args!("[{}]", reasons)) + f.write_fmt(format_args!("[{reasons}]")) } } diff --git a/raiden/src/filter_expression/mod.rs b/raiden/src/filter_expression/mod.rs index b76ee79a..1a48340f 100644 --- a/raiden/src/filter_expression/mod.rs +++ b/raiden/src/filter_expression/mod.rs @@ -105,17 +105,17 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { let mut attr_names: super::AttributeNames = std::collections::HashMap::new(); let mut attr_values: super::AttributeValues = std::collections::HashMap::new(); - attr_names.insert(format!("#{}", attr_name), attr_name.clone()); + attr_names.insert(format!("#{attr_name}"), attr_name.clone()); let left_cond = if self.is_size { - format!("size(#{})", attr_name) + format!("size(#{attr_name})") } else { - format!("#{}", attr_name) + format!("#{attr_name}") }; match self.cond { FilterExpressionTypes::Eq(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("{} = {}", left_cond, placeholder), + format!("{left_cond} = {placeholder}"), attr_names, attr_values, ) @@ -123,7 +123,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::Not(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("{} <> {}", left_cond, placeholder), + format!("{left_cond} <> {placeholder}"), attr_names, attr_values, ) @@ -131,7 +131,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::Gt(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("{} > {}", left_cond, placeholder), + format!("{left_cond} > {placeholder}"), attr_names, attr_values, ) @@ -139,7 +139,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::Ge(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("{} >= {}", left_cond, placeholder), + format!("{left_cond} >= {placeholder}"), attr_names, attr_values, ) @@ -147,7 +147,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::Le(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("{} <= {}", left_cond, placeholder), + format!("{left_cond} <= {placeholder}"), attr_names, attr_values, ) @@ -155,7 +155,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::Lt(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("{} < {}", left_cond, placeholder), + format!("{left_cond} < {placeholder}"), attr_names, attr_values, ) @@ -164,10 +164,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { attr_values.insert(placeholder1.to_string(), value1); attr_values.insert(placeholder2.to_string(), value2); ( - format!( - "{} BETWEEN {} AND {}", - left_cond, placeholder1, placeholder2 - ), + format!("{left_cond} BETWEEN {placeholder1} AND {placeholder2}"), attr_names, attr_values, ) @@ -182,7 +179,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { attr_values.insert(placeholder, value); } ( - format!("{} IN ({})", left_cond, placeholders), + format!("{left_cond} IN ({placeholders})"), attr_names, attr_values, ) @@ -190,25 +187,25 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::BeginsWith(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("begins_with(#{}, {})", attr_name, placeholder), + format!("begins_with(#{attr_name}, {placeholder})"), attr_names, attr_values, ) } FilterExpressionTypes::AttributeExists() => ( - format!("attribute_exists(#{})", attr_name), + format!("attribute_exists(#{attr_name})"), attr_names, attr_values, ), FilterExpressionTypes::AttributeNotExists() => ( - format!("attribute_not_exists(#{})", attr_name), + format!("attribute_not_exists(#{attr_name})"), attr_names, attr_values, ), FilterExpressionTypes::AttributeType(placeholder, attribute_type) => { attr_values.insert(placeholder.to_string(), attribute_type.into_attr()); ( - format!("attribute_type(#{}, {})", attr_name, placeholder), + format!("attribute_type(#{attr_name}, {placeholder})"), attr_names, attr_values, ) @@ -216,7 +213,7 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { FilterExpressionTypes::Contains(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("contains(#{}, {})", attr_name, placeholder), + format!("contains(#{attr_name}, {placeholder})"), attr_names, attr_values, ) @@ -228,52 +225,49 @@ impl FilterExpressionBuilder for FilterExpressionFilledOrWaitOperator { impl FilterExpressionBuilder for FilterExpressionFilled { fn build(self) -> (String, super::AttributeNames, super::AttributeValues) { let (right_str, right_names, right_values) = match self.operator { - FilterExpressionOperator::And(s, m, v) => (format!("AND ({})", s), m, v), - FilterExpressionOperator::Or(s, m, v) => (format!("OR ({})", s), m, v), + FilterExpressionOperator::And(s, m, v) => (format!("AND ({s})"), m, v), + FilterExpressionOperator::Or(s, m, v) => (format!("OR ({s})"), m, v), }; let attr_name = self.attr; let mut left_names: super::AttributeNames = std::collections::HashMap::new(); let mut left_values: super::AttributeValues = std::collections::HashMap::new(); - left_names.insert(format!("#{}", attr_name), attr_name.clone()); + left_names.insert(format!("#{attr_name}"), attr_name.clone()); let left_cond = if self.is_size { - format!("size(#{})", attr_name) + format!("size(#{attr_name})") } else { - format!("#{}", attr_name) + format!("#{attr_name}") }; let left_str = match self.cond { FilterExpressionTypes::Eq(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("{} = {}", left_cond, placeholder) + format!("{left_cond} = {placeholder}") } FilterExpressionTypes::Not(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("{} <> {}", left_cond, placeholder) + format!("{left_cond} <> {placeholder}") } FilterExpressionTypes::Gt(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("{} > {}", left_cond, placeholder) + format!("{left_cond} > {placeholder}") } FilterExpressionTypes::Ge(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("{} >= {}", left_cond, placeholder) + format!("{left_cond} >= {placeholder}") } FilterExpressionTypes::Le(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("{} <= {}", left_cond, placeholder) + format!("{left_cond} <= {placeholder}") } FilterExpressionTypes::Lt(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("{} < {}", left_cond, placeholder) + format!("{left_cond} < {placeholder}") } FilterExpressionTypes::Between(placeholder1, value1, placeholder2, value2) => { left_values.insert(placeholder1.clone(), value1); left_values.insert(placeholder2.clone(), value2); - format!( - "{} BETWEEN {} AND {}", - left_cond, placeholder1, placeholder2 - ) + format!("{left_cond} BETWEEN {placeholder1} AND {placeholder2}") } FilterExpressionTypes::In(attributes) => { let placeholders = attributes @@ -284,29 +278,29 @@ impl FilterExpressionBuilder for FilterExpressionFilled { for (placeholder, value) in attributes { left_values.insert(placeholder, value); } - format!("{} IN ({})", attr_name, placeholders) + format!("{attr_name} IN ({placeholders})") } FilterExpressionTypes::BeginsWith(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("begins_with(#{}, {})", attr_name, placeholder) + format!("begins_with(#{attr_name}, {placeholder})") } FilterExpressionTypes::AttributeExists() => { - format!("attribute_exists(#{})", attr_name) + format!("attribute_exists(#{attr_name})") } FilterExpressionTypes::AttributeNotExists() => { - format!("attribute_not_exists(#{})", attr_name) + format!("attribute_not_exists(#{attr_name})") } FilterExpressionTypes::AttributeType(placeholder, attribute_type) => { left_values.insert(placeholder.clone(), attribute_type.into_attr()); - format!("attribute_type(#{}, {})", attr_name, placeholder) + format!("attribute_type(#{attr_name}, {placeholder})") } FilterExpressionTypes::Contains(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("contains(#{}, {})", attr_name, placeholder) + format!("contains(#{attr_name}, {placeholder})") } }; ( - format!("{} {}", left_str, right_str), + format!("{left_str} {right_str}"), super::merge_map(left_names, right_names), super::merge_map(left_values, right_values), ) diff --git a/raiden/src/key_condition/mod.rs b/raiden/src/key_condition/mod.rs index 275fd9b3..e45c00c2 100644 --- a/raiden/src/key_condition/mod.rs +++ b/raiden/src/key_condition/mod.rs @@ -75,12 +75,12 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { let mut attr_names: super::AttributeNames = std::collections::HashMap::new(); let mut attr_values: super::AttributeValues = std::collections::HashMap::new(); - attr_names.insert(format!("#{}", attr_name), attr_name.clone()); + attr_names.insert(format!("#{attr_name}"), attr_name.clone()); match self.cond { super::key_condition::KeyConditionTypes::Eq(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("#{} = {}", attr_name, placeholder), + format!("#{attr_name} = {placeholder}"), attr_names, attr_values, ) @@ -88,7 +88,7 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { super::key_condition::KeyConditionTypes::Gt(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("#{} > {}", attr_name, placeholder), + format!("#{attr_name} > {placeholder}"), attr_names, attr_values, ) @@ -96,7 +96,7 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { super::key_condition::KeyConditionTypes::Ge(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("#{} >= {}", attr_name, placeholder), + format!("#{attr_name} >= {placeholder}"), attr_names, attr_values, ) @@ -104,7 +104,7 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { super::key_condition::KeyConditionTypes::Le(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("#{} <= {}", attr_name, placeholder), + format!("#{attr_name} <= {placeholder}"), attr_names, attr_values, ) @@ -112,7 +112,7 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { super::key_condition::KeyConditionTypes::Lt(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("#{} < {}", attr_name, placeholder), + format!("#{attr_name} < {placeholder}"), attr_names, attr_values, ) @@ -126,10 +126,7 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { attr_values.insert(placeholder1.to_string(), value1); attr_values.insert(placeholder2.to_string(), value2); ( - format!( - "#{} BETWEEN {} AND {}", - attr_name, placeholder1, placeholder2 - ), + format!("#{attr_name} BETWEEN {placeholder1} AND {placeholder2}"), attr_names, attr_values, ) @@ -137,7 +134,7 @@ impl KeyConditionBuilder for KeyConditionFilledOrWaitOperator { super::key_condition::KeyConditionTypes::BeginsWith(placeholder, value) => { attr_values.insert(placeholder.to_string(), value); ( - format!("begins_with(#{}, {})", attr_name, placeholder), + format!("begins_with(#{attr_name}, {placeholder})"), attr_names, attr_values, ) @@ -150,35 +147,35 @@ impl KeyConditionBuilder for KeyConditionFilled { fn build(self) -> (String, super::AttributeNames, super::AttributeValues) { let (right_str, right_names, right_values) = match self.operator { super::key_condition::KeyConditionOperator::And(s, m, v) => { - (format!("AND ({})", s), m, v) + (format!("AND ({s})"), m, v) } }; let attr_name = self.attr; let mut left_names: super::AttributeNames = std::collections::HashMap::new(); let mut left_values: super::AttributeValues = std::collections::HashMap::new(); - left_names.insert(format!("#{}", attr_name), attr_name.clone()); + left_names.insert(format!("#{attr_name}"), attr_name.clone()); let left_str = match self.cond { super::key_condition::KeyConditionTypes::Eq(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("#{} = {}", attr_name, placeholder) + format!("#{attr_name} = {placeholder}") } super::key_condition::KeyConditionTypes::Gt(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("#{} > {}", attr_name, placeholder) + format!("#{attr_name} > {placeholder}") } super::key_condition::KeyConditionTypes::Ge(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("#{} >= {}", attr_name, placeholder) + format!("#{attr_name} >= {placeholder}") } super::key_condition::KeyConditionTypes::Le(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("#{} <= {}", attr_name, placeholder) + format!("#{attr_name} <= {placeholder}") } super::key_condition::KeyConditionTypes::Lt(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("#{} < {}", attr_name, placeholder) + format!("#{attr_name} < {placeholder}") } super::key_condition::KeyConditionTypes::Between( placeholder1, @@ -188,18 +185,15 @@ impl KeyConditionBuilder for KeyConditionFilled { ) => { left_values.insert(placeholder1.clone(), value1); left_values.insert(placeholder2.clone(), value2); - format!( - "#{} BETWEEN {} AND {}", - attr_name, placeholder1, placeholder2 - ) + format!("#{attr_name} BETWEEN {placeholder1} AND {placeholder2}") } super::key_condition::KeyConditionTypes::BeginsWith(placeholder, value) => { left_values.insert(placeholder.clone(), value); - format!("begins_with(#{}, {})", attr_name, placeholder) + format!("begins_with(#{attr_name}, {placeholder})") } }; ( - format!("{} {}", left_str, right_str), + format!("{left_str} {right_str}"), super::merge_map(left_names, right_names), super::merge_map(left_values, right_values), ) diff --git a/raiden/src/lib.rs b/raiden/src/lib.rs index c5bd8709..0af27a63 100644 --- a/raiden/src/lib.rs +++ b/raiden/src/lib.rs @@ -68,7 +68,7 @@ impl IntoAttribute for AttributeType { impl std::fmt::Display for AttributeType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "{:?}", self) + write!(f, "{self:?}") } } diff --git a/raiden/src/ops/transact_write.rs b/raiden/src/ops/transact_write.rs index 03a5b889..e53c31b6 100644 --- a/raiden/src/ops/transact_write.rs +++ b/raiden/src/ops/transact_write.rs @@ -89,6 +89,12 @@ impl WriteTx { .await } + #[cfg_attr(feature = "tracing", tracing::instrument( + level = tracing::Level::DEBUG, + name = "dynamodb::action", + skip_all, + fields(api = "transact_write_items") + ))] async fn inner_run( client: crate::DynamoDbClient, input: crate::TransactWriteItemsInput, diff --git a/raiden/src/update_expression/add.rs b/raiden/src/update_expression/add.rs index d90ded75..a2320ca5 100644 --- a/raiden/src/update_expression/add.rs +++ b/raiden/src/update_expression/add.rs @@ -25,7 +25,7 @@ impl Add { impl UpdateAddExpressionBuilder for AddExpressionFilled { fn build(self) -> (String, super::AttributeNames, super::AttributeValues) { let attr = self.target.into_attr_name(); - let attr_name = format!("#{}", attr); + let attr_name = format!("#{attr}"); let mut names: super::AttributeNames = std::collections::HashMap::new(); let mut values: super::AttributeValues = std::collections::HashMap::new(); @@ -38,7 +38,7 @@ impl UpdateAddExpressionBuilder for AddExpressionFilled< } names.insert(attr_name.clone(), attr); - let expression = format!("{} {}", attr_name, placeholder); + let expression = format!("{attr_name} {placeholder}"); values.insert(placeholder, value); (expression, names, values) } diff --git a/raiden/src/update_expression/delete.rs b/raiden/src/update_expression/delete.rs index cc46bd70..3531f8df 100644 --- a/raiden/src/update_expression/delete.rs +++ b/raiden/src/update_expression/delete.rs @@ -25,7 +25,7 @@ impl Delete { impl UpdateDeleteExpressionBuilder for DeleteExpressionFilled { fn build(self) -> (String, super::AttributeNames, super::AttributeValues) { let attr = self.target.into_attr_name(); - let attr_name = format!("#{}", attr); + let attr_name = format!("#{attr}"); let mut names: super::AttributeNames = std::collections::HashMap::new(); let mut values: super::AttributeValues = std::collections::HashMap::new(); @@ -38,7 +38,7 @@ impl UpdateDeleteExpressionBuilder for DeleteExpressionF } names.insert(attr_name.clone(), attr); - let expression = format!("{} {}", attr_name, placeholder); + let expression = format!("{attr_name} {placeholder}"); values.insert(placeholder, value); (expression, names, values) } diff --git a/raiden/src/update_expression/set.rs b/raiden/src/update_expression/set.rs index 3f516146..3fbda230 100644 --- a/raiden/src/update_expression/set.rs +++ b/raiden/src/update_expression/set.rs @@ -117,7 +117,7 @@ impl SetExpressionFilledWithoutOperation { impl UpdateSetExpressionBuilder for SetExpressionFilledWithoutOperation { fn build(self) -> SetOrRemove { let attr = self.target.into_attr_name(); - let attr_name = format!("#{}", attr); + let attr_name = format!("#{attr}"); let mut names: super::AttributeNames = std::collections::HashMap::new(); names.insert(attr_name.clone(), attr); @@ -125,14 +125,11 @@ impl UpdateSetExpressionBuilder for SetExpressionFilledW match self.value { SetValue::Attr(a) => { let set_attr = a.into_attr_name(); - let set_attr_name = format!("#{}", set_attr); + let set_attr_name = format!("#{set_attr}"); let expression = if self.if_not_exists { - format!( - "{} = if_not_exists({}, {})", - attr_name, attr_name, set_attr_name - ) + format!("{attr_name} = if_not_exists({attr_name}, {set_attr_name})") } else { - format!("{} = {}", attr_name, set_attr_name) + format!("{attr_name} = {set_attr_name}") }; names.insert(set_attr_name, set_attr); SetOrRemove::Set(expression, names, values) @@ -145,12 +142,9 @@ impl UpdateSetExpressionBuilder for SetExpressionFilledW return SetOrRemove::Remove(attr_name, names); } let expression = if self.if_not_exists { - format!( - "{} = if_not_exists({}, {})", - attr_name, attr_name, placeholder - ) + format!("{attr_name} = if_not_exists({attr_name}, {placeholder})") } else { - format!("{} = {}", attr_name, placeholder) + format!("{attr_name} = {placeholder}") }; values.insert(placeholder, value); SetOrRemove::Set(expression, names, values) @@ -162,7 +156,7 @@ impl UpdateSetExpressionBuilder for SetExpressionFilledW impl UpdateSetExpressionBuilder for SetExpressionFilled { fn build(self) -> SetOrRemove { let attr = self.target.into_attr_name(); - let attr_name = format!("#{}", attr); + let attr_name = format!("#{attr}"); let mut names: super::AttributeNames = std::collections::HashMap::new(); names.insert(attr_name.clone(), attr); @@ -172,13 +166,13 @@ impl UpdateSetExpressionBuilder for SetExpressionFilled< let op_expression = match self.operand { Operand::_Attr(a) => { let operand_attr = a.into_attr_name(); - let operand_attr_name = format!("#{}", operand_attr); - let val = format!("{} {}", op, operand_attr_name); + let operand_attr_name = format!("#{operand_attr}"); + let val = format!("{op} {operand_attr_name}"); names.insert(operand_attr_name, operand_attr); val } Operand::Value(placeholder, value) => { - let val = format!("{} {}", op, placeholder); + let val = format!("{op} {placeholder}"); values.insert(placeholder, value); val } @@ -187,13 +181,13 @@ impl UpdateSetExpressionBuilder for SetExpressionFilled< match self.value { SetValue::Attr(a) => { let set_attr = a.into_attr_name(); - let set_attr_name = format!("#{}", set_attr); - let expression = format!("{} = {} {}", attr_name, set_attr_name, op_expression); + let set_attr_name = format!("#{set_attr}"); + let expression = format!("{attr_name} = {set_attr_name} {op_expression}"); names.insert(set_attr_name, set_attr); SetOrRemove::Set(expression, names, values) } SetValue::Value(placeholder, value) => { - let expression = format!("{} = {} {}", attr_name, placeholder, op_expression); + let expression = format!("{attr_name} = {placeholder} {op_expression}"); values.insert(placeholder, value); SetOrRemove::Set(expression, names, values) } diff --git a/raiden/tests/all/batch_delete.rs b/raiden/tests/all/batch_delete.rs index 974f178b..d6b06892 100644 --- a/raiden/tests/all/batch_delete.rs +++ b/raiden/tests/all/batch_delete.rs @@ -80,7 +80,7 @@ mod partition_key_tests { }); let res = client - .batch_delete((4..=100).map(|i| format!("id{}", i)).collect()) + .batch_delete((4..=100).map(|i| format!("id{i}")).collect()) .run() .await; assert!(res.is_ok()); @@ -177,7 +177,7 @@ mod partition_key_and_sort_key_tests { let res = client .batch_delete( (4..=100) - .map(|i| (format!("id{}", i), 1999_usize + i)) + .map(|i| (format!("id{i}"), 1999_usize + i)) .collect(), ) .run() diff --git a/raiden/tests/all/batch_get.rs b/raiden/tests/all/batch_get.rs index a57cd44d..0a18952c 100644 --- a/raiden/tests/all/batch_get.rs +++ b/raiden/tests/all/batch_get.rs @@ -77,10 +77,10 @@ mod tests { name: "ap-northeast-1".into(), }); - let keys: Vec = (0..101).into_iter().map(|n| format!("id{}", n)).collect(); + let keys: Vec = (0..101).into_iter().map(|n| format!("id{n}")).collect(); let expected_items = (0..101) .map(|n| BatchTest0 { - id: format!("id{}", n), + id: format!("id{n}"), name: "bob".to_owned(), }) .collect(); @@ -173,13 +173,13 @@ mod tests { let keys: Vec<(String, usize)> = (0..250) .into_iter() - .map(|n| (format!("id{}", n), (2000 + n) as usize)) + .map(|n| (format!("id{n}"), (2000 + n) as usize)) .collect(); let expected_items = (0..250) .map(|n| BatchTest1 { - id: format!("id{}", n), + id: format!("id{n}"), name: "bob".to_owned(), - year: (2000 + n) as usize, + year: (2000 + n), num: n, }) .collect(); @@ -224,11 +224,11 @@ mod tests { let keys: Vec<(String, usize)> = (0..250) .into_iter() - .map(|n| (format!("id{}", n), (2000 + n) as usize)) + .map(|n| (format!("id{n}"), (2000 + n) as usize)) .collect(); let expected_items = (0..250) .map(|n| BatchTest1a { - id: format!("id{}", n), + id: format!("id{n}"), name: "bob".to_owned(), year: 2000 + n as usize, }) diff --git a/raiden/tests/all/condition.rs b/raiden/tests/all/condition.rs index da2ddab8..d945b24d 100644 --- a/raiden/tests/all/condition.rs +++ b/raiden/tests/all/condition.rs @@ -6,6 +6,7 @@ mod tests { use raiden::condition::*; use raiden::*; + #[allow(dead_code)] #[derive(Raiden)] #[raiden(table_name = "user")] #[derive(Debug, Clone)] diff --git a/raiden/tests/all/delete.rs b/raiden/tests/all/delete.rs index 209523f4..bc3c46e7 100644 --- a/raiden/tests/all/delete.rs +++ b/raiden/tests/all/delete.rs @@ -5,6 +5,7 @@ mod tests { use pretty_assertions::assert_eq; use raiden::*; + #[allow(dead_code)] #[derive(Raiden, Debug, Clone)] pub struct DeleteTest0 { #[raiden(partition_key)] @@ -62,6 +63,7 @@ mod tests { rt.block_on(example()); } + #[allow(dead_code)] #[derive(Raiden, Debug, Clone)] pub struct DeleteTest1 { #[raiden(partition_key)] diff --git a/raiden/tests/all/filter_expression.rs b/raiden/tests/all/filter_expression.rs index b58c7bcb..3f11a290 100644 --- a/raiden/tests/all/filter_expression.rs +++ b/raiden/tests/all/filter_expression.rs @@ -5,6 +5,7 @@ mod tests { use pretty_assertions::assert_eq; use raiden::*; + #[allow(dead_code)] #[derive(Raiden)] #[raiden(table_name = "user")] #[derive(Debug, Clone)] diff --git a/raiden/tests/all/key_condition.rs b/raiden/tests/all/key_condition.rs index b89c417a..c86a119f 100644 --- a/raiden/tests/all/key_condition.rs +++ b/raiden/tests/all/key_condition.rs @@ -5,6 +5,7 @@ mod tests { use pretty_assertions::assert_eq; use raiden::*; + #[allow(dead_code)] #[derive(Raiden)] #[raiden(table_name = "user")] #[derive(Debug, Clone)] diff --git a/raiden/tests/all/transact_write.rs b/raiden/tests/all/transact_write.rs index 4549bd3e..8f02c90d 100644 --- a/raiden/tests/all/transact_write.rs +++ b/raiden/tests/all/transact_write.rs @@ -5,6 +5,7 @@ mod tests { use pretty_assertions::assert_eq; use raiden::*; + #[allow(dead_code)] #[derive(Raiden)] #[raiden(table_name = "user")] #[derive(Debug, Clone)] diff --git a/rust-toolchain b/rust-toolchain index 0403bed1..65ee0959 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.66.1 +1.67.0