Skip to content
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

Added Http Trace Context #143

Merged
merged 944 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
944 commits
Select commit Hold shift + click to select a range
d0e637d
tracer workaround
Tianlin-Zhao Jul 30, 2020
555e05c
tracer workaround
Tianlin-Zhao Jul 30, 2020
8245e6a
tracer workaround
Tianlin-Zhao Jul 30, 2020
0442a52
tracer workaround
Tianlin-Zhao Jul 30, 2020
29e89de
tracer workaround
Tianlin-Zhao Jul 30, 2020
fb29a2b
tracer workaround
Tianlin-Zhao Jul 30, 2020
6cff40e
tracer workaround
Tianlin-Zhao Jul 30, 2020
f614fb9
tracer workaround
Tianlin-Zhao Jul 30, 2020
838c94e
Merge branch 'origin/propagation' into origin/propagators
Tianlin-Zhao Jul 30, 2020
b09a788
Merge pull request #9 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Jul 30, 2020
2e2f9df
tracer workaround
Tianlin-Zhao Jul 30, 2020
4476a31
Merge remote-tracking branch 'origin/origin/propagators' into origin/…
Tianlin-Zhao Jul 30, 2020
c88cc14
tracer workaround
Tianlin-Zhao Jul 30, 2020
2f081d8
Merge pull request #10 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Jul 30, 2020
dd2d515
tracer workaround
Tianlin-Zhao Jul 30, 2020
a4e1cbd
tracer workaround
Tianlin-Zhao Jul 30, 2020
974d1bd
tracer workaround
Tianlin-Zhao Jul 30, 2020
c1314cb
tracer workaround
Tianlin-Zhao Jul 30, 2020
c5f1f2d
tracer workaround
Tianlin-Zhao Jul 30, 2020
77abce8
tracer workaround
Tianlin-Zhao Jul 30, 2020
d3a1931
tracer workaround
Tianlin-Zhao Jul 30, 2020
ed44b0a
tracer workaround
Tianlin-Zhao Jul 30, 2020
1462b48
tracer workaround
Tianlin-Zhao Jul 30, 2020
5d13af0
tracer workaround
Tianlin-Zhao Jul 30, 2020
49200ac
tracer workaround
Tianlin-Zhao Jul 30, 2020
d2c3ebf
tracer workaround
Tianlin-Zhao Jul 30, 2020
aacecd5
tracer workaround
Tianlin-Zhao Jul 30, 2020
bf134b8
tracer workaround
Tianlin-Zhao Jul 30, 2020
3647d6a
tracer workaround
Tianlin-Zhao Jul 30, 2020
956055b
tracer workaround
Tianlin-Zhao Jul 30, 2020
374d7c4
tracer workaround
Tianlin-Zhao Jul 30, 2020
2873ef0
tracer workaround
Tianlin-Zhao Jul 30, 2020
692967b
tracer workaround
Tianlin-Zhao Jul 30, 2020
b8df0b1
tracer
Tianlin-Zhao Jul 30, 2020
26da008
tracer
Tianlin-Zhao Jul 30, 2020
98ca4e0
tracer
Tianlin-Zhao Jul 30, 2020
6826a41
tracer
Tianlin-Zhao Jul 30, 2020
1f47c39
tracer
Tianlin-Zhao Jul 30, 2020
2ded3e1
tracer
Tianlin-Zhao Jul 30, 2020
fc1ef96
tracer
Tianlin-Zhao Jul 30, 2020
94831ab
tracer
Tianlin-Zhao Jul 30, 2020
23d78d1
tracer
Tianlin-Zhao Jul 30, 2020
24ab44b
tracer
Tianlin-Zhao Jul 30, 2020
b64427e
tracer
Tianlin-Zhao Jul 30, 2020
78c4158
tracer
Tianlin-Zhao Jul 30, 2020
77ca5ca
tracer
Tianlin-Zhao Jul 30, 2020
3f0173c
tracer
Tianlin-Zhao Jul 30, 2020
f0db27e
tracer
Tianlin-Zhao Jul 30, 2020
a58b4ee
tracer
Tianlin-Zhao Jul 30, 2020
76d6f29
tracer
Tianlin-Zhao Jul 30, 2020
93e0e66
tracer
Tianlin-Zhao Jul 30, 2020
7a2d5f2
tracer
Tianlin-Zhao Jul 30, 2020
69fc0d6
tracer
Tianlin-Zhao Jul 30, 2020
818865f
tracer
Tianlin-Zhao Jul 30, 2020
6dccadf
tracer
Tianlin-Zhao Jul 30, 2020
8b84e55
tracer
Tianlin-Zhao Jul 30, 2020
3290a17
tracer
Tianlin-Zhao Jul 30, 2020
0eb2e77
tracer
Tianlin-Zhao Jul 30, 2020
1f0b6e1
tracer
Tianlin-Zhao Jul 30, 2020
e0c8d5f
tracer
Tianlin-Zhao Jul 30, 2020
e602890
tracer
Tianlin-Zhao Jul 30, 2020
1a5d792
tracer
Tianlin-Zhao Jul 31, 2020
c2952e8
tracer
Tianlin-Zhao Jul 31, 2020
1f0d5e7
tracer
Tianlin-Zhao Jul 31, 2020
acdf179
tracer
Tianlin-Zhao Jul 31, 2020
a6c150b
tracer
Tianlin-Zhao Jul 31, 2020
19a4cd5
tracer
Tianlin-Zhao Jul 31, 2020
28e4d0a
Merge pull request #12 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Aug 1, 2020
d22b43e
tracer
Tianlin-Zhao Aug 1, 2020
5429141
Merge pull request #13 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Aug 1, 2020
8c3d6fd
tracer
Tianlin-Zhao Aug 1, 2020
81a0640
Merge pull request #14 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Aug 1, 2020
513b0e0
tracer
Tianlin-Zhao Aug 1, 2020
f388ac1
Merge pull request #15 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Aug 1, 2020
94834dd
tracer
Tianlin-Zhao Aug 1, 2020
5026789
Merge pull request #16 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Aug 1, 2020
fe62212
tracer
Tianlin-Zhao Aug 1, 2020
92f0e0f
Merge pull request #17 from Tianlin-Zhao/origin/propagators
Tianlin-Zhao Aug 1, 2020
6d90293
tracer
Tianlin-Zhao Aug 1, 2020
25e549d
tracer
Tianlin-Zhao Aug 1, 2020
5a71b43
tracer
Tianlin-Zhao Aug 1, 2020
01d8cec
tracer
Tianlin-Zhao Aug 1, 2020
427030a
tracer
Tianlin-Zhao Aug 1, 2020
d8bbd52
tracer
Tianlin-Zhao Aug 1, 2020
7580adb
tracer
Tianlin-Zhao Aug 1, 2020
544855b
tracer
Tianlin-Zhao Aug 1, 2020
349fbb9
tracer
Tianlin-Zhao Aug 1, 2020
4104e91
tracer
Tianlin-Zhao Aug 1, 2020
bbdfed1
tracer
Tianlin-Zhao Aug 1, 2020
d67c502
tracer
Tianlin-Zhao Aug 1, 2020
cf25139
tracer
Tianlin-Zhao Aug 1, 2020
10463c0
comply to noexcept requirements
Tianlin-Zhao Aug 1, 2020
c0ac15e
comply to noexcept requirements
Tianlin-Zhao Aug 1, 2020
36b3241
comply to noexcept requirements
Tianlin-Zhao Aug 1, 2020
6b6b533
comply to noexcept requirements
Tianlin-Zhao Aug 1, 2020
c706b4c
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
053d92e
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
458d4aa
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
20f747b
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
5e2ee69
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
bc3fb98
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
38a94a5
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
fa070d4
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
0e0d344
comply to noexcept requirements
Tianlin-Zhao Aug 2, 2020
e0c63d3
new span context constructor
Tianlin-Zhao Aug 2, 2020
886d893
format
Tianlin-Zhao Aug 4, 2020
bcfb751
format, txt manuel adjustment due to the failure of importing of cmak…
Tianlin-Zhao Aug 4, 2020
d2fc434
format, txt manuel adjustment due to the failure of importing of cmak…
Tianlin-Zhao Aug 4, 2020
3ebe9e6
format, txt manuel adjustment due to the failure of importing of cmak…
Tianlin-Zhao Aug 4, 2020
6d0cd8b
Merge branch 'master' of https://github.com/Tianlin-Zhao/opentelemetr…
Tianlin-Zhao Aug 4, 2020
20259a9
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
Tianlin-Zhao Aug 5, 2020
11efe1f
Merge remote-tracking branch 'upstream/master' into origin/propagation
Tianlin-Zhao Aug 5, 2020
c1adf5a
updated the trace state reference in http trace context to keep with …
Tianlin-Zhao Aug 5, 2020
a19cd59
updated the trace state reference in http trace context to keep with …
Tianlin-Zhao Aug 5, 2020
d392f64
changed opentelemetry namespace in trace_state.h
Tianlin-Zhao Aug 5, 2020
d774328
span_context.h fix of function get invalid
Tianlin-Zhao Aug 5, 2020
99be4b7
span context added back empty constructor
Tianlin-Zhao Aug 5, 2020
87ae915
span context added back empty constructor
Tianlin-Zhao Aug 5, 2020
a78b5d1
span context added back empty constructor
Tianlin-Zhao Aug 5, 2020
17d8c3e
span context added back empty constructor
Tianlin-Zhao Aug 5, 2020
9168e67
span context added back empty constructor
Tianlin-Zhao Aug 10, 2020
e4d6474
Merge pull request #18 from Tianlin-Zhao/origin/w3ctest
Tianlin-Zhao Aug 10, 2020
47b6a6f
commenting out trace state in span context
Tianlin-Zhao Aug 10, 2020
c78c8cb
Merge pull request #19 from Tianlin-Zhao/origin/w3ctest
Tianlin-Zhao Aug 10, 2020
edd9188
commenting out trace state in span context
Tianlin-Zhao Aug 10, 2020
9e4e820
Merge pull request #20 from Tianlin-Zhao/origin/w3ctest
Tianlin-Zhao Aug 10, 2020
6d4a23f
commenting out trace state in span context
Tianlin-Zhao Aug 10, 2020
d95f29e
Merge pull request #21 from Tianlin-Zhao/origin/w3ctest
Tianlin-Zhao Aug 10, 2020
7a9e9ba
format
Tianlin-Zhao Aug 11, 2020
fa90b35
Merge pull request #22 from Tianlin-Zhao/origin/w3ctest
Tianlin-Zhao Aug 11, 2020
c1fb682
Merge branch 'master' into origin/propagation
Tianlin-Zhao Aug 12, 2020
5fe65b6
change in tokens
Tianlin-Zhao Aug 12, 2020
5701303
change in tokens
Tianlin-Zhao Aug 12, 2020
c42cd38
format
Tianlin-Zhao Aug 12, 2020
07c5930
format
Tianlin-Zhao Aug 12, 2020
b182a5f
Update api/include/opentelemetry/propagators/composite_http_propagator.h
Tianlin-Zhao Aug 13, 2020
3887dc7
Update api/include/opentelemetry/trace/propagation/http_text_format.h
Tianlin-Zhao Aug 13, 2020
1d47802
format
Tianlin-Zhao Aug 13, 2020
0d53d33
format
Tianlin-Zhao Aug 13, 2020
2de9266
format
Tianlin-Zhao Aug 13, 2020
cd47c3a
format
Tianlin-Zhao Aug 13, 2020
e7ebefa
resolving issues
Tianlin-Zhao Aug 13, 2020
820dd14
resolving issues
Tianlin-Zhao Aug 13, 2020
7dc1203
resolving issues
Tianlin-Zhao Aug 13, 2020
3f73d5d
resolving issues
Tianlin-Zhao Aug 13, 2020
3fa337a
resolving issues
Tianlin-Zhao Aug 13, 2020
f31f9fa
resolving issues
Tianlin-Zhao Aug 13, 2020
93a9389
resolving issues
Tianlin-Zhao Aug 13, 2020
5bf0693
new PR: removed all TraceState references
Tianlin-Zhao Aug 13, 2020
544c0ee
removed all TraceState references
Tianlin-Zhao Aug 13, 2020
2064606
Merge pull request #23 from Tianlin-Zhao/noTraceState
Tianlin-Zhao Aug 13, 2020
69b688c
Merge pull request #24 from Tianlin-Zhao/noTraceState
Tianlin-Zhao Aug 14, 2020
aee8cfd
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
Tianlin-Zhao Aug 14, 2020
5e054ee
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
Tianlin-Zhao Aug 18, 2020
d066f4e
Merge branch 'origin/propagation' of https://github.com/Tianlin-Zhao/…
Tianlin-Zhao Aug 18, 2020
c0e74ff
format, todo clean ups
Tianlin-Zhao Aug 19, 2020
466d4f3
format, todo clean ups
Tianlin-Zhao Aug 19, 2020
c5164c9
removed tracer from all span classes
Tianlin-Zhao Aug 19, 2020
2cd73ce
removed noop test because all it does is testing the noop tracer whic…
Tianlin-Zhao Aug 19, 2020
bd41f80
removed noop test because all it does is testing the noop tracer whic…
Tianlin-Zhao Aug 19, 2020
051089d
Added new field to span.h of spancontext
Tianlin-Zhao Aug 19, 2020
249c32c
Added new field to span.h of spancontext
Tianlin-Zhao Aug 19, 2020
b6002fc
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
Tianlin-Zhao Aug 19, 2020
3e89067
manual format of cmake
Tianlin-Zhao Aug 19, 2020
19ca833
cmake
Tianlin-Zhao Aug 20, 2020
5d6a288
format, added test case for default span on GetContext
Tianlin-Zhao Aug 20, 2020
1a90fec
format, added test case for default span on GetContext
Tianlin-Zhao Aug 20, 2020
8aa9b7f
format, added test case for default span on GetContext
Tianlin-Zhao Aug 20, 2020
1c89300
format, added test case for default span on GetContext
Tianlin-Zhao Aug 20, 2020
f928930
format, added test case for default span on GetContext
Tianlin-Zhao Aug 20, 2020
2e813fb
removed pointer addition, replaced with loop variable
Tianlin-Zhao Aug 20, 2020
017e470
removed pointer addition, replaced with loop variable
Tianlin-Zhao Aug 20, 2020
9bb3984
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
3eb1d6a
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
a0e2f23
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
51a380a
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
d5edbec
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
8ac9486
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
af1b484
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
eddb689
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
fabc345
resolving Null issue of span
Tianlin-Zhao Aug 20, 2020
0a8021a
resolved aditya's questions
Tianlin-Zhao Aug 20, 2020
31220c6
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
190a7fa
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
fd8dd98
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
185e8a3
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
432ab0d
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
d0724ae
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
0b1a90f
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
f0c1c9d
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
8e6c3a1
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
eb8c38f
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
dd7f65d
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
bae2047
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
e8eeb9d
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
d86fbd3
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
4ff679b
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
3f03636
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
42c1ace
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
5f23ebe
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
09bd626
resolved aditya's questions
Tianlin-Zhao Aug 21, 2020
c7aa9ae
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
186f47f
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
987b90c
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
e063cb7
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
f423173
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
2925d5a
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
5eaa32d
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
ba2bfaa
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
Tianlin-Zhao Aug 21, 2020
1dfc9d7
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
6acc97f
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
b04a00f
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
c367480
added noop test to cover more lines of code -- for code coverage
Tianlin-Zhao Aug 21, 2020
e98bb2a
Revert "dependency"
Tianlin-Zhao Aug 21, 2020
127c6f1
Merge branch 'origin/propagation' of https://github.com/Tianlin-Zhao/…
Tianlin-Zhao Aug 21, 2020
7df20dd
revert to ba2bfaa
Tianlin-Zhao Aug 21, 2020
c6690b0
test revert
Tianlin-Zhao Aug 21, 2020
5b66308
Merge pull request #28 from ZhaoTianlin990121/test_revert
ZhaoTianlin990121 Aug 21, 2020
1144903
Update .gitignore
ZhaoTianlin990121 Aug 24, 2020
1ff6c52
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
Tianlin-Zhao Aug 24, 2020
fb0ac53
test revert
Tianlin-Zhao Aug 24, 2020
43722fd
resolving conflicts
Tianlin-Zhao Aug 25, 2020
a5166a9
resolving conflicts
Tianlin-Zhao Aug 25, 2020
8f82a70
resolving conflicts
Tianlin-Zhao Aug 25, 2020
8f0d0c4
resolving conflicts
Tianlin-Zhao Aug 25, 2020
0d83afa
resolving conflicts
Tianlin-Zhao Aug 25, 2020
43ec98e
Merge branch 'master' into origin/propagation
reyang Aug 25, 2020
9576052
resolving conflicts
Tianlin-Zhao Aug 25, 2020
0947b16
Merge remote-tracking branch 'origin/origin/propagation' into origin/…
Tianlin-Zhao Aug 25, 2020
7f560ed
resolving conflicts
Tianlin-Zhao Aug 25, 2020
298cf43
resolving conflicts
Tianlin-Zhao Aug 25, 2020
e27a159
resolving conflicts
Tianlin-Zhao Aug 25, 2020
2a0e5b3
resolving conflicts
Tianlin-Zhao Aug 25, 2020
5b5b930
resolving conflicts
Tianlin-Zhao Aug 25, 2020
431ee66
resolving conflicts
Tianlin-Zhao Aug 25, 2020
e78ad86
resolving conflicts
Tianlin-Zhao Aug 25, 2020
16c340a
resolving conflicts
Tianlin-Zhao Aug 25, 2020
7c6cba8
resolving conflicts
Tianlin-Zhao Aug 25, 2020
5a0a40f
resolving conflicts
Tianlin-Zhao Aug 25, 2020
d6fe242
resolving conflicts
Tianlin-Zhao Aug 25, 2020
24e490d
resolving conflicts
Tianlin-Zhao Aug 25, 2020
b090657
resolving conflicts
Tianlin-Zhao Aug 25, 2020
e75105e
resolving conflicts
Tianlin-Zhao Aug 25, 2020
3fb3182
resolving conflicts
Tianlin-Zhao Aug 25, 2020
ae9485c
resolving conflicts
Tianlin-Zhao Aug 25, 2020
3da1f13
resolving conflicts
Tianlin-Zhao Aug 25, 2020
d5f869e
resolving conflicts
Tianlin-Zhao Aug 25, 2020
4b9605e
resolving conflicts
Tianlin-Zhao Aug 25, 2020
b7d0eb4
Minor change to EOF
Tianlin-Zhao Aug 25, 2020
9a27369
Merge branch 'master' into origin/propagation
reyang Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@

# Bazel files
/bazel-*
/.idea/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be IDE specific files, would you put them in a separate section (and put a comment)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll do that right away. Actually, do you mind to see the other PR I've made sometime before?

#129

It contains the header I'd like to merge into while this PR is more about consulting about some of the coding details.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the lines below needed? Isn't the whole .idea subdir ignored?

Also I'm not sure this belongs in the .gitignore file at all. I'd like to avoid e.g. every single IDE/editor being covered here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should have been removed by now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still plan to keep this line?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commited those changes to remove it.

/.idea/.gitignore
/.idea/modules.xml
/.idea/opentelemetry-cpp.iml
/.idea/vcs.xml
37 changes: 37 additions & 0 deletions api/include/opentelemetry/trace/default_span.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "opentelemetry/trace/span.h"
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace {
public const class DefaultSpan : Span {
public:
// Returns an invalid span.
static DefaultSpan getInvalid() {
return INVALID;
}

// Creates an instance of this class with spancontext.
static DefaultSpan create(SpanContext spanContext) {
return DefaultSpan(spanContext);
}

static DefaultSpan createRandom() {
return DefaultSpan(
SpanContext(
TraceId.generateRandomId(),
SpanId.generateRandomId(),
false,
TraceFlags.getDefault(),
TraceState.getDefault()
)
);
}

DefaultSpan(SpanContext spanContext) {
this.spanContext = spanContext;
}

private:
static const DefaultSpan INVALID = new DefaultSpan(SpanContext.getInvalid());
const SpanContext spanContext;
}
}
183 changes: 183 additions & 0 deletions api/include/opentelemetry/trace/propagation/HttpTraceContext.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#include <vector>
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved
#include <regex>
#include <stdexcept>
#include "opentelemetry/trace/propagation/httptextformat.h"
#include "opentelemetry/trace/spancontext.h"
#include "opentelemetry/trace/trace_state.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/default_span.cc"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{
namespace propagation
{
namespace
{

static Context SetSpanInContext(Span span, Context &context) {
Context new_values = Context(context);
// I don't know if the SPAN_KEY is defined in the context.h.
// My point is that since each key when it is created is unique in terms of its id even though they may have the same name,
// it would make sense to define those keys in a single file only and had to be referenced by other files to store and retrieve values,
// otherwise I will not be able to access any fields, for example, "current-span" as CreateKey("current-span") will
// not work because the id is different when the value is put into despite the Key is also created from
// CreateKey("current-span").
// Don't know if I get the correct understanding there.
new_values.setValue(Context.SPAN_KEY,span);
return new_values;
}

static Span GetCurrentSpan(Context &context) {
Span span = get_value(Context.SPAN_KEY, context);
if (span == NULL) {
return NULL;
}
return span;
}

// The HttpTraceContext provides methods to extract and inject
// context into headers of HTTP requests with traces.
// Example:
// HttpTraceContext.inject(setter,&carrier,&context);
// HttpTraceContext.extract(getter,&carrier,&context);
class HttpTraceContext : public HTTPTextFormat
{
public:
List<nostd::string_view> fields() {
static const auto* FIELDS = new std::vector<nostd::string_view>({TRACE_PARENT, TRACE_STATE});
return FIELDS;
}

void inject(Setter setter, T &carrier, const Context &context) override {
common::AttributeValue span = GetCurrentSpan(context);
if (span == NULL || !span.getContext().isValid()) {
// We don't have span.getContext() in span.h, should we just use span? As well as acquiring validity. (I do know how to implement them though)
return;
}
injectImpl(setter, carrier, span.getContext());
}

Context extract(Getter getter, const T &carrier, Context &context) override {
SpanContext spanContext = extractImpl(carrier, getter);
return SetSpanInContext(trace.DefaultSpan(spanContext), context);
}

private:
static const nostd::string_view TRACE_PARENT = "traceparent";
static const nostd::string_view TRACE_STATE = "tracestate";
static const int VERSION_BYTES = 2;
static const int TRACE_ID_BYTES = 32;
static const int PARENT_ID_BYTES = 16;
static const int TRACE_FLAG_BYTES = 2;
static const int TRACE_DELIMITER_BYTES = 3;
static const int HEADER_SIZE = VERSION_BYTES + TRACE_ID_BYTES + PARENT_ID_BYTES + TRACE_FLAG_BYTES + TRACE_DELIMITER_BYTES;
static const int TRACESTATE_MAX_MEMBERS = 32;
static const nostd::string_view TRACESTATE_KEY_VALUE_DELIMITER = "=";
static const std::regex TRACESTATE_ENTRY_DELIMITER_SPLIT_PATTERN("[ \t]*,[ \t]*");

static Context checkNotNull(Context &arg, nostd::string_view errorMessage) {
if (arg == NULL) {
throw new NullPointerException("error: null " + errorMessage);
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (arg == NULL) {
throw new NullPointerException("error: null " + errorMessage);
}

arg is a reference, it cannot be null.

return arg;
}

static void injectImpl(Setter setter, T &carrier, const SpanContext &spanContext) {
char hex_string[HEADER_SIZE];
sprintf(hex_string, "00-%032x-%016x-%02x",spanContext.trace_id(),spanContext.span_id(),spanContext.trace_flags());
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved
nostd::string_view traceparent_string = nostd::string_view(hex_string, HEADER_SIZE);
setter(carrier, TRACE_PARENT, traceparent_string);
if (spanContext.getTraceState()) {
nostd::string_view tracestate_string = formatTracestate(spanContext.getTraceState()); // I need the definition for the type of TraceState(Dictionary or something else). The trace state data structure will determine how I will able to join this together.
setter(carrier, TRACE_STATE, tracestate_string);
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved
}
}

static SpanContext extractContextFromTraceParent(nostd::string_view &traceparent) {
bool isValid = traceparent.length() == HEADER_SIZE
&& traceparent[VERSION_BYTES] == "-"
&& traceparent[VERSION_BYTES+TRACE_ID_BYTES+1] == "-"
&& traceparent[VERSION_BYTES+TRACE_ID_BYTES+PARENT_ID_BYTES+2] == "-";
if (!isValid) {
std::cout<<"Unparseable traceparent header. Returning INVALID span context."<<std::endl;
return SpanContext.getInvalid();
}

try {
TraceId traceId = TraceId.fromLowerBase16(traceparent, TRACE_ID_OFFSET);
SpanId spanId = SpanId.fromLowerBase16(traceparent, SPAN_ID_OFFSET);
TraceFlags traceFlags = TraceFlags.fromLowerBase16(traceparent, TRACE_OPTION_OFFSET);
return SpanContext.createFromRemoteParent(traceId, spanId, traceFlags, TRACE_STATE_DEFAULT);
} catch (IllegalArgumentException e) {
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved
std::cout<<"Unparseable traceparent header. Returning INVALID span context."<<std::endl;
return SpanContext.getInvalid();
}
}

static TraceState extractTraceState(nostd::string_view traceStateHeader) {
// TODO: implementation
/** The question here is that how should I treat the trace state. Implementation will differ pretty much
depending on what is the data structure of TraceState. Also this is based on the premise that
trace state exists and has a builder
*/
std::smatch listMembers;
TraceState.Builder traceStateBuilder = TraceState.builder();
regex_search(traceStateHeader,sm,TRACESTATE_ENTRY_DELIMITER_SPLIT_PATTERN); // I hope regex accepts string view
if (listMembers.size() <= TRACESTATE_MAX_MEMBERS) {
throw std::invalid_argument("TraceState has too many elements.");
}
for (int i = listMembers.size() - 1; i >= 0; i--) {
nostd::string_view listMember = listMembers[i];
int index = -1;
for (int j = 0; j < listMember.length(); j++) {
if (listMember[j] == TRACESTATE_KEY_VALUE_DELIMITER) {
index = j;
break;
}
}
if (index == -1) {
throw std::invalid_argument("Invalid TraceState list-member format.");
}
traceStateBuilder.set(listMember.substring(0, index), listMember.substring(index + 1));
}
return traceStateBuilder.build();
}

static SpanContext extractImpl(Getter getter, T &carrier) {
nostd::string_view traceParent = getter(carrier, TRACE_PARENT);
if (traceParent == NULL) {
return SpanContext.getInvalid();
}

SpanContext contextFromParentHeader = extractContextFromTraceParent(traceParent);
if (!contextFromParentHeader.isValid()) {
return contextFromParentHeader;
}

nostd::string_view traceStateHeader = getter(carrier, TRACE_STATE);
if (traceStateHeader == NULL || traceStateHeader.isEmpty()) {
return contextFromParentHeader;
}

try {
// Again, the trace state problem, should I treat it like a string or dictionary or an encapsuled class? This is not defined in current files
TraceState traceState = extractTraceState(traceStateHeader);
// Need getter support from SpanContext
return SpanContext.createFromRemoteParent(
contextFromParentHeader.getTraceId(),
contextFromParentHeader.getSpanId(),
contextFromParentHeader.getTraceFlags(),
traceState);
} catch (IllegalArgumentException e) {
std::cout<<"Unparseable tracestate header. Returning span context without state."<<std::endl;
return contextFromParentHeader;
}
}
}
}
}
} // namespace trace
OPENTELEMETRY_END_NAMESPACE
41 changes: 41 additions & 0 deletions api/include/opentelemetry/trace/propagation/httptextformat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include <cstdint>
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{
namespace propagation
{

// Set the span in the given context.
virtual static Context SetSpanInContext(Span span, Context &context) = 0;
// Retrieve the current span.
virtual static Span GetCurrentSpan(Context &context) = 0;

// The HTTPTextFormat class provides an interface that enables extracting and injecting
// context into headers of HTTP requests. HTTP frameworks and clients
// can integrate with HTTPTextFormat by providing the object containing the
// headers, and a getter and setter function for the extraction and
// injection of values, respectively.
template <typename T>
class HTTPTextFormat {
public:
// Rules that manages how context will be extracted from carrier.
using Getter = nostd::string_view(*)(T &carrier, nostd::string_view trace_type);

// Rules that manages how context will be injected to carrier.
using Setter = void(*)(T &carrier, nostd::string_view trace_type,nostd::string trace_description);

// Returns the context that is stored in the HTTP header carrier with self defined rules.
virtual Context extract(Getter get_from_carrier, const T &carrier, Context &context) = 0;

// Sets the context for a HTTP header carrier with self defined rules.
virtual void inject(Setter set_from_carrier, T &carrier, const Context &context) = 0;
};
}
}
OPENTELEMETRY_END_NAMESPACE
8 changes: 8 additions & 0 deletions api/include/opentelemetry/trace/span_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ class SpanId final
}
}

// Creates a SpanId from traceparent
static SpanId fromLowerBase16(nostd::string_view src, int srcOffset)
{
// I don't really know about what to do with this function
// The java implementation has this: return new SpanId(BigendianEncoding.longFromBase16String(src, srcOffset));
// But I am not sure if this will suffice here and I don't know what is BigendianEncoding module as well.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A SpanId is represented internally with a
uint8_t rep_[kSize];
so you need to convert from a string containing a hexadecimal value into 8-bit values.

I suggest you define a helper function to map from nostd::string_view to uint8_t[] that can be used here and in the TraceId case. That function can then be used when calling the SpanId constructor that takes a nostd::span of uint8_t (and then this function doesn't need to exist).

I also suggest that you have the caller handle the offset by using string_view substringing

}

// Returns a nostd::span of the ID.
nostd::span<const uint8_t, kSize> Id() const noexcept
{
Expand Down
70 changes: 70 additions & 0 deletions api/include/opentelemetry/trace/spancontext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#pragma once

#include <cstdint>
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"
#include "opentelemetry/trace/trace_id.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/trace_flags.h"
#include "opentelemetry/trace/trace_state.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{

public class SpanContext:
// The state of a Span to propagate between processes.
// This class includes the immutable attributes of a :class:`.Span` that must
// be propagated to a span's children and across process boundaries.
public:
TraceId traceId;
SpanId spanId;
bool remote;
TraceFlags traceFlags;
TraceState traceState;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect the member variables should be private, since there are getters and they're set in the constructor.

static SpanContext INVALID = SpanContext(TraceId.getInvalid(),SpanId.getInvalid(),false,TraceFlags.getDefault(),TraceState.getDefault());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest putting INVALID inside GetInvalid() as
static SpanContext* INVALID = new ....

see https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables


SpanContext(TraceId trace_id, SpanId span_id, bool is_remote, TraceFlags &trace_flags, TraceState &trace_state) {
traceId = trace_id;
spanId = span_id;
traceFlags = trace_flags;
traceState = trace_state;
remote = is_remote;
}

// Creates a new SpanContext that was propagated from a remote parent, with the given
// identifiers and options.
public static SpanContext createFromRemoteParent(TraceId traceId, SpanId spanId, TraceFlags traceFlags, TraceState traceState) {
// Question: what is AutoValue_spanContext, where is it defined?
return new AutoValue_SpanContext(traceId, spanId, traceFlags, traceState, /* remote=*/ true);
}

static SpanContext getInvalid() {
return INVALID;
}

bool isValid() {
// Get whether this `SpanContext` is valid.
// A `SpanContext` is said to be invalid if its trace ID or span ID is
// invalid (i.e. ``0``).
return traceId != INVALID_TRACE_ID && self.span_id != INVALID_SPAN_ID;
}

TraceId getTraceId() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, the getters can be named like trace_id(), span_id(), ...

return traceId;
}

SpanId getSpanId() {
return spanId;
}

TraceFlags getTraceFlags() {
return traceFlags;
}

TraceState getTraceState() {
return traceState;
}
}
OPENTELEMETRY_END_NAMESPACE
8 changes: 8 additions & 0 deletions api/include/opentelemetry/trace/trace_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ class TraceFlags final
buffer[1] = kHex[(rep_ >> 0) & 0xF];
}

// Creates TraceFlags from traceparent
static TraceFlags fromLowerBase16(nostd::string_view src, int srcOffset)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to SpanId.fromLowerBase16, use the
TraceFlags(uint8_t flags)
constructor instead of adding this.

{
// I don't really know about what to do with this function
// The java implementation has this: return new TraceFlags(BigendianEncoding.byteFromBase16String(src, srcOffset));
// But I am not sure if this will suffice here and I don't know what is BigendianEncoding module as well.
}

uint8_t flags() const noexcept { return rep_; }

bool operator==(const TraceFlags &that) const noexcept { return rep_ == that.rep_; }
Expand Down
10 changes: 10 additions & 0 deletions api/include/opentelemetry/trace/trace_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ class TraceId final
}
}

// Creates a SpanId from traceparent
static TraceId fromLowerBase16(nostd::string_view src, int srcOffset)
Tianlin-Zhao marked this conversation as resolved.
Show resolved Hide resolved
{
// I don't really know about what to do with this function
// The java implementation has this: return new TraceId(
// BigendianEncoding.longFromBase16String(src, srcOffset),
// BigendianEncoding.longFromBase16String(src, srcOffset + BigendianEncoding.LONG_BASE16));
// But I am not sure if this will suffice here and I don't know what is BigendianEncoding module as well.
}

// Returns a nostd::span of the ID.
nostd::span<const uint8_t, kSize> Id() const noexcept
{
Expand Down
Loading