-
Notifications
You must be signed in to change notification settings - Fork 327
http.Request influenced sampling #869
Comments
This seems like a good approach to me. /cc @rakyll |
Cases like this makes me wonder whether we should have provided a hook to customize the created span.
Then, FormatSpanName or the blacklisting/filtering capabilities we have been discussing can be implemented by the user with full flexibility. |
@rakyll could you elaborate on the reasoning behind returning |
There is a repeating pattern I see when it comes to the need of customizing request spans. We might keep adding different fields or should provide a way for the user to override the implementation entirely. |
I prefer @rakyll 's more general solution of hooking in at StartSpan if possible, but I'm not sure how that would work since all of the fields of |
@toffaletti I am not following. @rakyll suggested to return a Span from the hook installed in the Handler struct. I don't see anywhere a suggestion to hook into StartSpan. After thinking about it, I think your original proposal to return a |
Yeah, this is something I agree with. Please ignore the StartSpan suggestion. |
@toffaletti Are you working on adding this? |
No, I am still waiting on approval to be able contribute. |
If @Ramonza has nothing against, the following looks good to me.
|
Looks good but the field will need to be called something else as there is already a StartOptions field on that struct. |
What about GetStartOptions? This is the naming pattern used in standard library. For example, net/http.Request has a GetBody where you can optionally set instead of Body. |
Is anyone working on this? If not, can I? |
Is your feature request related to a problem? Please describe.
I would like to always sample requests with certain properties. For example, when the request has
?trace=1
and theRemoteAddr
is on an internal network the trace will be sampled.Describe the solution you'd like
Describe alternatives you've considered
Injecting a sampler in the
http.Handler
thatochttp.Handler
wraps, usingtrace.StartSpan(..., trace.Sampler(...))
. The problem with this is that the root span added by ochttp might not be sampled.Wrapping
ochttp.Handler
itself and influencing theochttp.Handler.StartOptions.Sample
somehow. The problem with this is that there isn't really any good way to get context into atrace.Sampler
except by closing over some state and we can't modify the closure for every request.Wrapping
ochttp.Handler
and create an additional outer span where we can set a trace.Sampler viaStartSpan
TraceOptions that closes over the*http.Request
. Adding a meaningless span just for this seems not ideal.Duplicating all of the functionality of
ochttp.Handler
in another package just to add this. Essentially maintaining a fork.Creating another
http.Server
on a different port with all of the same endpoint handlers except with aAlwaysSample
sampler set. Opening another port isn't an option for us.The text was updated successfully, but these errors were encountered: