-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Recover the OT context header from the B3 headers if not propagated #1702
Changes from 3 commits
e6b82ff
eb237f0
540feff
3e5c029
c1a859d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#include "common/tracing/zipkin/zipkin_tracer_impl.h" | ||
|
||
#include "common/common/enum_to_int.h" | ||
#include "common/common/utility.h" | ||
#include "common/http/headers.h" | ||
#include "common/http/message_impl.h" | ||
#include "common/http/utility.h" | ||
|
@@ -105,6 +106,20 @@ Tracing::SpanPtr Driver::startSpan(const Tracing::Config& config, Http::HeaderMa | |
// annotation. In this case, we are dealing with an ingress operation. This envoy instance, | ||
// being at the receiving end, will add the SR annotation to the shared span context. | ||
|
||
new_zipkin_span = | ||
tracer.startSpan(config, request_headers.Host()->value().c_str(), start_time, context); | ||
} else if (request_headers.XB3TraceId() && request_headers.XB3SpanId()) { | ||
uint64_t traceId(0); | ||
uint64_t spanId(0); | ||
uint64_t parentId(0); | ||
if (!StringUtil::atoul(request_headers.XB3TraceId()->value().c_str(), traceId, 16) | ||
|| !StringUtil::atoul(request_headers.XB3SpanId()->value().c_str(), spanId, 16) | ||
|| (request_headers.XB3ParentSpanId() && !StringUtil::atoul(request_headers.XB3ParentSpanId()->value().c_str(), parentId, 16))) { | ||
return nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'd probably return nullspan here to be on a safe side. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry yes I meant NullSpan (not nullptr) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem will sort it tomorrow. |
||
} | ||
|
||
SpanContext context(traceId, spanId, parentId); | ||
|
||
new_zipkin_span = | ||
tracer.startSpan(config, request_headers.Host()->value().c_str(), start_time, context); | ||
} else { | ||
|
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.
Sorry didn't catch this before. Please use snake_case for variables (trace_id, span_id, etc.).