Skip to content

Not right behaviour in case of CancelledErorr #34

@Mixser

Description

@Mixser

Hi,

Description

We are faced with a strange number of the 500 errors in our metrics (which are collected by aiodogstatsd.contrib.aiohttp middleware) and that number was different from what we at ALB logs. The reason for this - is that when the connection is aborted before we processed it, the CancelledError would be raised -- and it will be counted as a 500 error, but this is not true -- user will not receive any response in that case.

Expected behavior

In the case of CancelledError it would be great to have the option to separate it from other errors and have an option to skip it from the metrics

 try:
     response = await handler(request)
     response_status = response.status
 except web.HTTPException as e:
     response_status = e.status
     raise e
except CancelledError: 
      response_status = ... # some code, that will indicate that is `CancelledError`
 finally:
     if _proceed_collecting(..., collect_canceled=True/False):   # allow to mute CancelledError metric
         ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions