Skip to content

track stats on Ok vs Err return values for tasks that return Result #172

Open
@pnkfelix

Description

@pnkfelix

I wrote some async code recently that looked roughly like this:

  1. create MPSC channel
  2. spawn huge collection of tasks that do some work and transmit messages on the channel. Each task returns Result so that ? can bubble up errors.
  3. process messages received
  4. when channel is closed, await all the tasks (with ?? on the result of each await, since its a Result<Result<..>>).

This phenomenon occurred: I did not see as much useful work out of the tasks that I expected. Here is why: Many of the tasks went on the error path (I was hitting local resource limitations), but I didn't have any code that tried to report that the error path was being executed. So those errors would not be observed until step 4 above, when we started awaiting all the tasks and would actually get panics from the ??

At one point I was using the console to try to figure out what was going on. It did not illuminate anything for me.

But: it could have. Namely, the fact that so many of those tasks were returning error ended up being a significant hint, and is something that we could report succinctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-instrumentationArea: instrumentation.C-subscriberCrate: console-subscriber.S-featureSeverity: feature. This is adding a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions