slawlor / ractor

Rust actor framework
MIT License
1.31k stars 68 forks source link

Instrument crate with tracing instead of log crate #134

Closed slawlor closed 11 months ago

slawlor commented 11 months ago

Once instrumentation is included on the actor handlers:

$ cargo run --example counter
   Compiling ractor v0.8.5 (/Users/seanlawlor/src/slawlor_ractor/ractor)
    Finished dev [unoptimized + debuginfo] target(s) in 2.23s
     Running `target/debug/examples/counter`
I0805 21:23:53.769058 93424 ractor/examples/counter.rs:46] [Actor{id: "0.0"}] Starting the counter actor
I0805 21:23:53.770157 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770190 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770211 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770228 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770262 93424 ractor/examples/counter.rs:124] Count is: 10
I0805 21:23:53.770322 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770342 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770359 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770375 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770407 93424 ractor/examples/counter.rs:124] Count is: 20
I0805 21:23:53.770459 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770494 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770515 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770534 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770569 93424 ractor/examples/counter.rs:124] Count is: 30
I0805 21:23:53.770626 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770652 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770673 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770693 93424 ractor/examples/counter.rs:57] [Actor{id: "0.0"}] Counting actor handle message...
I0805 21:23:53.770727 93424 ractor/examples/counter.rs:124] Count is: 40
codecov[bot] commented 11 months ago

Codecov Report

Patch coverage: 16.82% and project coverage change: -0.58% :warning:

Comparison is base (de62f42) 79.74% compared to head (4e44bf8) 79.16%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #134 +/- ## ========================================== - Coverage 79.74% 79.16% -0.58% ========================================== Files 49 49 Lines 8881 8890 +9 ========================================== - Hits 7082 7038 -44 - Misses 1799 1852 +53 ``` | [Files Changed](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor) | Coverage Δ | | |---|---|---| | [ractor/src/lib.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yL3NyYy9saWIucnM=) | `78.57% <ø> (ø)` | | | [ractor\_cluster/src/net/listener.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yX2NsdXN0ZXIvc3JjL25ldC9saXN0ZW5lci5ycw==) | `0.00% <0.00%> (ø)` | | | [ractor\_cluster/src/net/session.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yX2NsdXN0ZXIvc3JjL25ldC9zZXNzaW9uLnJz) | `0.00% <0.00%> (ø)` | | | [ractor\_cluster/src/node/client.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yX2NsdXN0ZXIvc3JjL25vZGUvY2xpZW50LnJz) | `0.00% <0.00%> (ø)` | | | [ractor\_cluster/src/node/mod.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yX2NsdXN0ZXIvc3JjL25vZGUvbW9kLnJz) | `2.75% <0.00%> (-0.11%)` | :arrow_down: | | [ractor\_cluster/src/node/node\_session/mod.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yX2NsdXN0ZXIvc3JjL25vZGUvbm9kZV9zZXNzaW9uL21vZC5ycw==) | `30.95% <0.00%> (-1.15%)` | :arrow_down: | | [ractor/src/factory/mod.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yL3NyYy9mYWN0b3J5L21vZC5ycw==) | `82.22% <37.50%> (-1.76%)` | :arrow_down: | | [ractor/src/factory/tests/mod.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yL3NyYy9mYWN0b3J5L3Rlc3RzL21vZC5ycw==) | `91.40% <50.00%> (ø)` | | | [ractor/src/rpc/call\_result.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yL3NyYy9ycGMvY2FsbF9yZXN1bHQucnM=) | `96.03% <50.00%> (+1.41%)` | :arrow_up: | | [ractor/src/actor/mod.rs](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor#diff-cmFjdG9yL3NyYy9hY3Rvci9tb2QucnM=) | `88.34% <70.00%> (-1.66%)` | :arrow_down: | | ... and [3 more](https://app.codecov.io/gh/slawlor/ractor/pull/134?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/slawlor/ractor/pull/134/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Sean+Lawlor)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

slawlor commented 11 months ago

Unless I missed something, is this just a mechanical s/log::/tracing::/g?

Once tracing is in place there'll be a lot more we'll want to record, but this is a good start.

It is in addition to instrumenting 2 calls in the actor handler with the actor's id. This adds a span so that tracing messages called from an actor handler will attach the actor id which means we can get sequential message flow from actors grouped by actor id. Agree it's a start, and there's room to grow. The sample log in the pr summary demonstrates the added span.

slawlor commented 11 months ago

Related issue #22