Skip to content

Add the possibility to flush traces/metrics after a handler loop has finished #691

Closed
@purkhusid

Description

@purkhusid

The problem I currently have is that there is no good way to flush traces/logs/metrics/errors once the runtime has finished handling a message.

Currently the handling code is structured something like this:

let request_span = <create span for the request>

async {
    <do parsing, call the user provider handler, catch panics etc>
}.instrument(tracing_span)

There are a couple of issues with this approach:

  1. The user provided handler is the only way or the end user to affect the loop and thus he has to e.g. flush spans inside the handler
  2. Since the handler can panic it is possible that the flushing is never done since it has to happen after the work has been done.
  3. The request_span span can not be flushed since it's finished after the user provided handler is provided.
  4. If the handler fails on e.g. parsing there is no way for the end user to send the errors to their error reporting tool of choice because their handler was never run.

I think it would be very valuable that the runtime would provide a hook for the end user so that they can do cleanup after each invocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions