mini-redis
mini-redis copied to clipboard
Add additional `tracing` instrumentation.
This commit lays the ground-work for making mini-redis a better example of an instrumented tokio application. While it does not go so far to turn mini-redis into a fully-featured guide for using tracing
, it ensures that people who use mini-redis as a basis for experimenting with different subscribers get a more complete experience out-of-the-box.
E.g., with tracing-tree
a tracing-tree subscriber and level=Debug
:
INFO mini_redis::server accepting inbound connections ┐mini_redis::db::purge_expired_tasks ├─┐mini_redis::db::Shared::purge_expired_keys ├─┘ ┐mini_redis::server::Handler::run peer_addr=127.0.0.1:56574 ├─┐mini_redis::server::Handler::process_frame │ ├─0ms DEBUG mini_redis::server cmd=Unknown(Unknown { command_name: "config" }) │ ├─0ms DEBUG mini_redis::cmd::unknown response=Error("ERR unknown command 'config'") ├─┘ ├─┐mini_redis::server::Handler::process_frame │ ├─0ms DEBUG mini_redis::server cmd=Unknown(Unknown { command_name: "config" }) │ ├─0ms DEBUG mini_redis::cmd::unknown response=Error("ERR unknown command 'config'") ├─┘ ├─┐mini_redis::server::Handler::process_frame │ ├─0ms WARN mini_redis::connection connection closed abruptly by peer ├─┘ ┘ ┐mini_redis::server::Handler::run peer_addr=127.0.0.1:56576 ├─┐mini_redis::server::Handler::process_frame │ ├─0ms DEBUG mini_redis::server cmd=Set(Set { key: "key:000000000027", value: b"VXK", expire: None }) ├─┘ ├─┐mini_redis::server::Handler::process_frame │ ├─0ms DEBUG mini_redis::server cmd=Set(Set { key: "key:000000000001", value: b"VXK", expire: None }) ├─┘ ├─┐mini_redis::server::Handler::process_frame ├─┘ ┘
This PR also reduces ConnectionReset
'errors' to warnings, as they do not reflect errors in mini-redis, but rather client misbehavior. (And you get them frequently when using redis-benchmark
.)
Looks pretty good to me
@hawkw I've added a few such comments; e.g.:
- https://github.com/tokio-rs/mini-redis/blob/49ef356960f4b3cfcf7af2ed4c06028f455d2de9/src/cmd/mod.rs#L50-L54
- https://github.com/tokio-rs/mini-redis/blob/49ef356960f4b3cfcf7af2ed4c06028f455d2de9/src/cmd/mod.rs#L109-L113
- https://github.com/tokio-rs/mini-redis/blob/49ef356960f4b3cfcf7af2ed4c06028f455d2de9/src/server.rs#L378-L393
So... LGTM? @jswrenn
@hawkw I've applied most of the suggestions (will need to think more about the last two), and rebased (to fix a merge conflict).
too bad this never got merged, it would have been useful