-
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
tracing: add direct support for a span to spawn a child #932
Conversation
needs test |
@@ -87,6 +87,11 @@ class NullSpan : public Tracing::Span { | |||
// Tracing::Span | |||
void setTag(const std::string&, const std::string&) override {} | |||
void finishSpan() override {} | |||
SpanPtr spawnChild(const std::string&, SystemTime) override { | |||
SpanPtr nullSpan; |
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.
very minor, SpanPtr nullSpan(new NullSpan())
|
||
void LightStepSpan::finishSpan() { span_.Finish(); } | ||
|
||
void LightStepSpan::setTag(const std::string& name, const std::string& value) { | ||
span_.SetTag(name, value); | ||
} | ||
|
||
SpanPtr LightStepSpan::spawnChild(const std::string& name, SystemTime start_time) { | ||
SpanPtr child_span; |
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.
same here.
SpanPtr child_span; | ||
lightstep::Span ls_span = tracer_.StartSpan( | ||
name, {lightstep::ChildOf(span_.context()), lightstep::StartTimestamp(start_time)}); | ||
child_span.reset(new LightStepSpan(ls_span, tracer_)); |
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, you can move child_span declaration right in here.
name, {lightstep::ChildOf(span_.context()), lightstep::StartTimestamp(start_time)}); | ||
child_span.reset(new LightStepSpan(ls_span, tracer_)); | ||
|
||
return std::move(child_span); |
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.
should not we be able to just return chlid_span
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.
can we? this seems to be a common pattern adopted elsewhere, but I'm not familiar enough with the ramifications.
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.
this should be possible as child_span is actually SpanPtr type.
include/envoy/tracing/http_tracer.h
Outdated
class Span { | ||
public: | ||
virtual ~Span() {} | ||
|
||
virtual void setTag(const std::string& name, const std::string& value) PURE; | ||
virtual void finishSpan() PURE; | ||
virtual void injectContext(Http::HeaderMap& request_headers) PURE; |
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.
what about overrides for zipkin spans?
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.
updated
@@ -88,6 +88,12 @@ class NullSpan : public Tracing::Span { | |||
// Tracing::Span | |||
void setTag(const std::string&, const std::string&) override {} | |||
void finishSpan() override {} | |||
void injectContext(Http::HeaderMap&) override {} | |||
SpanPtr spawnChild(const std::string&, SystemTime) override { |
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.
null span had 0 coverage, can you also update your PR to include that?
and make sure that we have full coverage of the new code as well
Tracing::SpanPtr ZipkinSpan::spawnChild(const std::string& name, SystemTime start_time) { | ||
Tracing::SpanPtr child_span; | ||
SpanContext context; | ||
new SpanContext(span_); |
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.
something is broken here :-)
|
||
ZipkinSpanPtr active_span; | ||
active_span.reset(new ZipkinSpan(*new_zipkin_span)); | ||
active_span.reset(new ZipkinSpan(*new_zipkin_span, tracer)); |
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: ZipkinSpanPtr active_span(new ZipkinSpan(*new_zipkin_span, tracer))
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.
i think this is still a valid comment :)
cc @fabolive |
include/envoy/tracing/http_tracer.h
Outdated
class Span; | ||
|
||
typedef std::unique_ptr<Span> SpanPtr; | ||
|
||
class Span { | ||
public: | ||
virtual ~Span() {} | ||
|
||
virtual void setTag(const std::string& name, const std::string& value) PURE; |
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.
comments here in all these methods, sorry I've not put it in the first place
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.
in general lgtm. Will let @RomanDzhabarov do the review.
} | ||
|
||
Tracing::SpanPtr ZipkinSpan::spawnChild(const std::string& name, SystemTime start_time) { | ||
std::unique_ptr<SpanContext> context{new SpanContext(span_)}; |
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.
this can be allocated on a stack. SpanContext context(span_);
// Set the ot-span-context header with the new context. | ||
SpanContext new_span_context(*new_zipkin_span); | ||
request_headers.insertOtSpanContext().value(new_span_context.serializeToString()); | ||
|
||
ZipkinSpanPtr active_span; |
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.
minor, ZipkinSpanPtr active_span(new ZipkinSpan(*new_zipkin_span, tracer));
and remove reset.
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.
Small comment and +1
Automatic merge from submit-queue. add envoyproxy as dependency **What this PR does / why we need it**: Add envoy proxy as dependency in istio.deps, after this PR is merged envoy proxy will be be updated once every week. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note ```
This reverts ef8a2fc2f388853b7db3498cce43e32a813c8428 and e333c485103c14983d2465f0befad8134f49a229 These are no longer required since we now build with Swift 5.2 Signed-off-by: Keith Smiley <keithbsmiley@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
This reverts ef8a2fc2f388853b7db3498cce43e32a813c8428 and e333c485103c14983d2465f0befad8134f49a229 These are no longer required since we now build with Swift 5.2 Signed-off-by: Keith Smiley <keithbsmiley@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
No description provided.