Skip to content

Capture start time from beginning of request #138

@mheffner

Description

@mheffner

In the Retry policy we need to lookup the start time of the request so that we can correctly calculate total elapsed time. We currently use the first retry attempt as the start time, but that excludes any time spent waiting on the first request.

Off the top of my head I can think of a couple ways to go about this:

  • Wrap requests in some struct that maintains a start time and add trait bound (get_start_time()) in Retry on the request. This will push trait requirements up/down the tower stack which will require refactoring.
  • Use the extension storage of the Request to store a typed start time object. It's bit unclear if that could conflict with other components or how extensions are used.

While we could set the start time when the request is emitted from the request builder, it isn't truly accurate. We should set the start time when we actually invoke the request in the lower client layer service. However, the request structure is not passed as mutable then. Therefore, we may need to add a struct with interior mutability to set the start time at the client layer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions