-
Notifications
You must be signed in to change notification settings - Fork 438
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
Refactoring trace_state to reuse common functionality in baggage #638
Refactoring trace_state to reuse common functionality in baggage #638
Conversation
Codecov Report
@@ Coverage Diff @@
## main #638 +/- ##
==========================================
+ Coverage 94.51% 94.66% +0.15%
==========================================
Files 199 203 +4
Lines 9136 9322 +186
==========================================
+ Hits 8635 8825 +190
+ Misses 501 497 -4
|
if (list_member.size() == 0) | ||
{ | ||
// empty list member. Move to next entry. For both baggage and trace_state this is valid | ||
// behaviour. |
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 - as this tokenizer class is not just for baggage and trace_state, we can remove comment specific to them. Or perhaps add flag whether to skip empty entries ( with default as true ) ?
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.
Makes sense, I will update the comment. About the flag, I am not sure if we will need this parsing at many places, so thought of not making it too generic.
If we go ahead with the flag approach, do you think we should have that as part of tokenizer's constructor (I feel flag will be same for all next calls) ? In that case we can probably create TokenizerConfigOption struct to be passed to the constructor.
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, I actually meant this flag for constructor.
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.
Added flag
{ | ||
|
||
// Iterator for key-value headers | ||
class KeyValueStringIterator |
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.
change class name to KeyValueStringTokenizer
taking inspiration from strtok
function in C ?
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.
Agreed
@@ -5,3 +5,25 @@ otel_cc_benchmark( | |||
srcs = ["spinlock_benchmark.cc"], | |||
deps = ["//api"], | |||
) | |||
|
|||
cc_test( |
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.
Adding the tests to CMake build script as well?
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
{ | ||
first = false; | ||
} | ||
header_s.append(std::string(key)); |
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 is probably my mistake - but I don't think this conversion (nostd::string_view to std::string) will work properly always (eg if key
contains end of line character). As C++11 std::string constructor won't accept std::string_view type. Better to use proper conversion : https://stackoverflow.com/questions/59424390/how-to-correctly-create-stdstring-from-a-stdstring-view
} | ||
header_s.append(std::string(key)); | ||
header_s.append(1, kKeyValueSeparator); | ||
header_s.append(std::string(value)); |
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.
Need to check this conversion in other places too
@@ -7,58 +21,14 @@ namespace | |||
{ | |||
|
|||
using opentelemetry::trace::TraceState; | |||
namespace nostd = opentelemetry::nostd; |
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 seems not used?
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.
Its used in the newly added tests (check line 200). I see that there is some inconsistency, at some places opentelemetry::nostd is used and at some nostd is directly used.
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'd suggest keeping its usage consistent.
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.
Thanks for the changes. Looks good to me once we take care of string_view to string conversion. Will wait for feedback from others.
@@ -7,58 +21,14 @@ namespace | |||
{ | |||
|
|||
using opentelemetry::trace::TraceState; | |||
namespace nostd = opentelemetry::nostd; |
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'd suggest keeping its usage consistent.
Related to #79
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes