go-kit/kit

transport/http ServerFinalizer should accept error for better logging support

开放

#807 创建于 2018年12月1日

 (14 条评论) (2 个反应) (0 位负责人)Go (2,446 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (27,422 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

We have three systems where logs are sent: our internal ELK stack, NewRelic and Airbrake. Some of our endpoints send errors to all of this systems, some endpoints send errors to only one of it.

We want log entries to have both error message and http status code. And also some http request context (uri, method, user-agent, ip...)

The only place which has access to both error and http status is ServerErrorEncoder. But since different endpoints need different sets of log outputs, we would have to create multiple error encoders just for sake of logging. Also, ServerErrorEncoder is not a good place for logging, because we would like it to do only one job - encode errors.

ServerFinalizer seems to be a great place to send logs, but there is no access to actual error message.

贡献者指南