server: Add standardized error reporting
Is your feature request related to a problem? Please describe.
It would be useful to enable standardized error reporting for HTTP services. These errors include 5xx responses, as well as panics in http handlers.
Reporting them to an error aggregator enables triage and response in a way that logging and tracing do not.
Describe the solution you'd like
I imagine adding a new field to the server.Options that accepts an optional error reporter with an interface similar to this:
type ErrorReporter interface {
ReportError(entry Entry)
}
where Entry is a struct similar to errorreporting.Error.
If this is set, then all request handling errors are reported to the error reporter.
I imagine google/go-cloud providing an adapter for GCP Error Reporting, and eventually there could be packages for other common error reporting services, like Sentry or Rollbar.
There are a few problems related to "stacktrace" management and asynchronous batching, but I think these can be left for the ErrorReporter implementations.