-
Notifications
You must be signed in to change notification settings - Fork 16
Refactor for better performance #115
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
82e92da
Tweak span.
rnburn fa7edf4
Use protobuf operation name.
rnburn b5df35e
Avoid storing start_timestamp_.
rnburn 33f0b65
Don't use embedded span context.
rnburn 858220c
Replace LightStepSpanContext with LightStepImmutableSpanContext.
rnburn a218b39
s/LightStepSpanContextBase/LightStepSpanContext
rnburn 258ad1f
Remove unused propagation code.
rnburn ef9a257
Set tags directly on protobuf object.
rnburn 37b7056
Add reference benchmark.
rnburn 1119b6a
Set reference directly on protobuf object.
rnburn 003eab5
Set logs on protobuf object.
rnburn 532478e
Fix clang-tidy warning.
rnburn f6d54f7
Change include order.
rnburn 22cf1a1
Clear reference before setting.
rnburn 83a5501
Use final specifier.
rnburn fbc87e1
Uncomment tests.
rnburn 325fe4b
Merge branch 'master' of github.com:lightstep/lightstep-tracer-cpp in…
rnburn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #include "lightstep_immutable_span_context.h" | ||
|
|
||
| namespace lightstep { | ||
| //------------------------------------------------------------------------------ | ||
| // constructor | ||
| //------------------------------------------------------------------------------ | ||
| LightStepImmutableSpanContext::LightStepImmutableSpanContext( | ||
| uint64_t trace_id, uint64_t span_id, bool sampled, | ||
| const std::unordered_map<std::string, std::string>& baggage) | ||
| : trace_id_{trace_id}, span_id_{span_id}, sampled_{sampled} { | ||
| for (auto& baggage_item : baggage) { | ||
| baggage_.insert( | ||
| BaggageMap::value_type(baggage_item.first, baggage_item.second)); | ||
| } | ||
| } | ||
|
|
||
| LightStepImmutableSpanContext::LightStepImmutableSpanContext( | ||
| uint64_t trace_id, uint64_t span_id, bool sampled, | ||
| BaggageMap&& baggage) noexcept | ||
| : trace_id_{trace_id}, | ||
| span_id_{span_id}, | ||
| sampled_{sampled}, | ||
| baggage_{std::move(baggage)} {} | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| // ForeachBaggageItem | ||
| //------------------------------------------------------------------------------ | ||
| void LightStepImmutableSpanContext::ForeachBaggageItem( | ||
| std::function<bool(const std::string& key, const std::string& value)> f) | ||
| const { | ||
| for (const auto& baggage_item : baggage_) { | ||
| if (!f(baggage_item.first, baggage_item.second)) { | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } // namespace lightstep | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #pragma once | ||
|
|
||
| #include "lightstep_span_context.h" | ||
|
|
||
| namespace lightstep { | ||
| class LightStepImmutableSpanContext final : public LightStepSpanContext { | ||
| public: | ||
| LightStepImmutableSpanContext( | ||
| uint64_t trace_id, uint64_t span_id, bool sampled, | ||
| const std::unordered_map<std::string, std::string>& baggage); | ||
|
|
||
| LightStepImmutableSpanContext(uint64_t trace_id, uint64_t span_id, | ||
| bool sampled, BaggageMap&& baggage) noexcept; | ||
|
|
||
| uint64_t trace_id() const noexcept override { return trace_id_; } | ||
|
|
||
| uint64_t span_id() const noexcept override { return span_id_; } | ||
|
|
||
| bool sampled() const noexcept override { return sampled_; } | ||
|
|
||
| void ForeachBaggageItem( | ||
| std::function<bool(const std::string& key, const std::string& value)> f) | ||
| const override; | ||
|
|
||
| opentracing::expected<void> Inject( | ||
| const PropagationOptions& propagation_options, | ||
| std::ostream& writer) const override { | ||
| return this->InjectImpl(propagation_options, writer); | ||
| } | ||
|
|
||
| opentracing::expected<void> Inject( | ||
| const PropagationOptions& propagation_options, | ||
| const opentracing::TextMapWriter& writer) const override { | ||
| return this->InjectImpl(propagation_options, writer); | ||
| } | ||
|
|
||
| opentracing::expected<void> Inject( | ||
| const PropagationOptions& propagation_options, | ||
| const opentracing::HTTPHeadersWriter& writer) const override { | ||
| return this->InjectImpl(propagation_options, writer); | ||
| } | ||
|
|
||
| private: | ||
| uint64_t trace_id_; | ||
| uint64_t span_id_; | ||
| bool sampled_; | ||
| BaggageMap baggage_; | ||
|
|
||
| template <class Carrier> | ||
| opentracing::expected<void> InjectImpl( | ||
| const PropagationOptions& propagation_options, Carrier& writer) const { | ||
| return InjectSpanContext(propagation_options, writer, trace_id_, span_id_, | ||
| sampled_, baggage_); | ||
| } | ||
| }; | ||
| } // namespace lightstep |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: I would be slightly inclined to remove the LightStep prefix since you're in namespace lightstep.
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, it's a little redundant.
I used names like LightStepSpan, LightStepTracer, etc to keep them from clashing with the opentracing names in case you happen to use both namespaces; then chose this name to be consistent. But maybe I should rename them all.
I'll merge in as is for now and maybe make a separate PR to rename everything.