census-instrumentation/opencensus-go

ochttp: add hooks to enrich request and response attributes

julianvmodesto opened this issue · 1 comments

NB: Before opening a feature request against this repo, consider whether the feature should/could be implemented in other the OpenCensus libraries in other languages. If so, please open an issue on opencensus-specs first.

Is your feature request related to a problem? Please describe.
I have many http handlers that are chained together in my router, and it's currently easy to add attributes from the request, but it's more difficult to add attributes from the response -- I'd have to span.FromContext in each of my http handlers wherever I'm setting my response.

Describe the solution you'd like
It would be wonderful to have a hook to add attributes to the existing ochttp plugin's instrumentation.

Describe alternatives you've considered
I think I'd have to redo what ochttp plugin does, and i think implement my own http.RoundTripper.

Additional context
N/A

The use case is I'm using Datadog exporter, and I'd like to set the following error attributes:
https://sourcegraph.com/github.com/DataDog/dd-trace-go@v1.8.0/-/blob/ddtrace/ext/tags.go#L44-53