You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm starting to replace OpenCensus Tracing with OpenTelemetry Tracing now that OT is in beta.
The first problem I'm running into is migrating ochttp into othttp
One thing I found a bit difficult to replicate is that othttp.NewHandler takes an operation argument which becomes the span name. In ochttp, the span name, by default, is the URL Path for every incoming request, or you can pass an option that formats the span name for every request here
However, for othttp, we don't have either of those options except the operation string argument which means for every route, I have to statically provide the span name for it.
This is mostly problematic when a user does not have control over http paths such as when using Twirp
Therefore, I see two solutions:
A quick solution is to make it so that if a user passes an empty string such as othttp.NewHandler(myHandler, "") then the othttp Handler will default to taking the URL Path for each request as the Span Name.
More ideally, I'd rather have the user provide a span formatter based on each request, similar to ochttp's FormatSpanName that was linked above. In othttp's use case, you can provide this as an option such as othttp.WithSpanName(func(r *http.Request) string), which might also prompt the removal of the operation string argument entirely.
The text was updated successfully, but these errors were encountered:
marwan-at-work
changed the title
othttp: Allow dynamic span name based on URL Path
othttp: Allow dynamic span name based on URL Path or a functional option
Apr 4, 2020
Hi there 👋
I'm starting to replace OpenCensus Tracing with OpenTelemetry Tracing now that OT is in beta.
The first problem I'm running into is migrating ochttp into othttp
One thing I found a bit difficult to replicate is that othttp.NewHandler takes an operation argument which becomes the span name. In ochttp, the span name, by default, is the URL Path for every incoming request, or you can pass an option that formats the span name for every request here
However, for othttp, we don't have either of those options except the
operation string
argument which means for every route, I have to statically provide the span name for it.This is mostly problematic when a user does not have control over http paths such as when using Twirp
Therefore, I see two solutions:
A quick solution is to make it so that if a user passes an empty string such as
othttp.NewHandler(myHandler, "")
then the othttp Handler will default to taking the URL Path for each request as the Span Name.More ideally, I'd rather have the user provide a span formatter based on each request, similar to ochttp's FormatSpanName that was linked above. In othttp's use case, you can provide this as an option such as
othttp.WithSpanName(func(r *http.Request) string)
, which might also prompt the removal of theoperation string
argument entirely.The text was updated successfully, but these errors were encountered: