-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add tracecontextb3 HTTPFormats #1429
Conversation
It will utilize either B3 or TraceContext propagation formats coming in (preferring TraceContext) and while sending both.
Maybe it would be better to only set the outgoing headers which are present in the incoming request? This could be a little tricky to implement but it should be possible to wrap the handler with one which inserts a format key into ctx. On the other hand there may be little downside to always writing both formats. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lint
|
||
var _ propagation.HTTPFormat = (*HTTPFormat)(nil) | ||
|
||
func (H *HTTPFormat) SpanContextFromRequest(req *http.Request) (trace.SpanContext, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (H *HTTPFormat) SpanContextFromRequest(req *http.Request) (trace.SpanContext, bool) { | |
func (h *HTTPFormat) SpanContextFromRequest(req *http.Request) (trace.SpanContext, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed entirely.
traceContext.SpanContextToRequest(sc, req) | ||
b3Format.SpanContextToRequest(sc, req) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we set both headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vagababov: 2 warnings.
In response to this:
/lint
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
I think there is little downside in always writing both formats. Given that, I think writing a new Handler is overkill for this situation. And even if we did write that Handler, I think we would still need this (write both formats) propagator for situations where something other than HTTP was used as the input. For example an eventing piece reading from Kafka or Pub/Sub. A wrapping handler would not help, as we don't have an incoming HTTP request. We would need to wrap an |
/assign @slinkydeveloper mind taking a look? |
Yeah i think that could be interesting for kafka tracing too! /assign |
// HTTPFormatSequence.Formats. | ||
// For outgoing requests, it will apply all the formats to the outgoing request, in the order of | ||
// HTTPFormatSequence.Formats. | ||
type HTTPFormatSequence struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The struct isn't necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just inline with
type HHFS []proo.HTTPFormat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the issue @ian-mi raised, I don't get why we should write always in both formats, to me it sounds pretty overkill (and adds unnecessary overhead to the message). We could make it configurable for the egress maybe? Like b3/tracecontext/both and default to tracecontext? I would prefer to stick with one format on egress side, and support both on ingress.
Also, before merging this one, can you run the e2e tracing tests on eventing with this patch?
My main hesitation of only outputting one format is that we are more likely to hit a component that speaks the other form of tracing, thus stopping the existing trace. That is what is happening in Knative today (before this PR). Every hop between eventing and serving cuts the trace because they use different tracing formats. Once this PR is in and all the downstream repos are updated and the user has updated to all those new versions, then it would no longer be a problem for Knative itself. But I'm worried about any software downstream of Knative that happens to rely on the existing format. If we go the route of configurable egress, then I think we need to have serving use B3 output and eventing use TraceContext output, to match what is already present in both places. As both may already have downstream software that relies on it. I think the additional overhead on the message is small enough (either ~70 or ~100 bytes), that its existence is justified by the increased chance of interoperating with other software.
Will do. |
To me this sounds like a different problem, because we don't have an alignment between their tracing propagation and our tracing propagation. Also as far as I understood the b3 propagation is specific to zipkin (which, by the way, can understand also traces propagated with trace context), so that's another reason for me to prefer making it configurable (same on serving). Also as far as I understood from the problem, we should make the
Well, it's always additional bytes that are potentially not used downstream. |
Makes sense. This PR will lay the ground work for allowing that option. This repo will need to extend the
Done. Although I still believe it is better to send the extra bytes than to have the trace broken. |
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Harwayne, slinkydeveloper, vaikas The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Helps with google/knative-gcp#1147.
Changes
tracecontextb3
package which contains threepropagation.HTTPFormat
s.B3Egress
sends only b3.TraceContextEgress
sends only TraceContextTraceContextB3Egress
sends both.This is being created because we found that serving relied on B3 tracing headers. While eventing relied on TraceContext tracing headers. So an HTTP request sent from a Broker to a Knative Service would break into two distinct traces.