Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[contrib/net/http] add option to wrap a provided *http.ServeMux #2690

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on May 10, 2024

  1. [contrib/net/http] add option to wrap a provided *http.ServeMux

    There are many cases where the traced serve mux should be the 'outer'
    most http handler in a chain of wrapped handlers. For example, if
    one wanted to write a middleware which logged all requests by wrapping
    a http.Handler and they wanted this logger to log dd.trace_id and
    dd.span_id, that logger would have to execute after the traced
    http.Handler. One could achieve this using the
    contrib/net/http#WrapHandler function, but this loses the nice
    capability of naming the resource using the http.ServeMux#Handler method
    because the resourceNamer config does not have access to the mux itself.
    
    Another approach, would be to have the contrib/net/http.ServeMux take
    another ServeMux as an option, and use that as its mux if provided. This
    way, the first 'handler' in a chain of request handlers would be the
    contrib/net/http.ServeMux. This traced mux would add trace context to
    the http request. This traced request would then be passed to the e.g.
    logging middleare mux, and so on, and so forth.
    powerbill committed May 10, 2024
    Configuration menu
    Copy the full SHA
    ce81310 View commit details
    Browse the repository at this point in the history