-
Notifications
You must be signed in to change notification settings - Fork 560
Implement basic OTLP Recordable #127
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
reyang
merged 26 commits into
open-telemetry:master
from
nadiaciobanu:basic-otlp-recordable
Jul 2, 2020
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
99e3672
Add basic recordable functions
nadiaciobanu e326783
Add start time
nadiaciobanu bb8b215
Add duration and ids
nadiaciobanu 257d03a
Add recordable test
nadiaciobanu 249b308
Move SetIds to its own test
nadiaciobanu b85b49a
Fix SetIds by not converting to hex
nadiaciobanu 78cf8e0
Reformat tests
nadiaciobanu a53e871
Fix Recordable instantiation in test
nadiaciobanu 91f454a
Merge branch 'master' into basic-otlp-recordable
nadiaciobanu ce61e40
Update code for new function (SetAttribute)
nadiaciobanu 11ce576
Fix undefined reference error
nadiaciobanu bc98b81
Fix memory leak
nadiaciobanu a61c01f
Address review comments
nadiaciobanu afa17f1
Update Bazel version for MacOS check
nadiaciobanu 4b16157
Address additional review comments
nadiaciobanu 4b41538
Add recordable_test to CMakeLists
nadiaciobanu 91f55b6
Fix CMakeList
nadiaciobanu 1ac3883
Fix CMakeLists by using opentelemetry_trace
nadiaciobanu f2e7430
Link test with proper library
nadiaciobanu 5ffea5a
Link to proto object library
nadiaciobanu 7a21795
Add protobuf dependency
nadiaciobanu bbbca02
Merge branch 'master' into basic-otlp-recordable
nadiaciobanu b9e135b
Simplify namespaces in test
nadiaciobanu 60373bc
Merge branch 'master' into basic-otlp-recordable
nadiaciobanu bc0f953
Merge branch 'master' into basic-otlp-recordable
nadiaciobanu 053b7f9
Merge branch 'basic-otlp-recordable' of https://github.com/nadiacioba…
nadiaciobanu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| add_library(opentelemetry_exporter_otprotocol recordable.cc) | ||
| target_link_libraries(opentelemetry_exporter_otprotocol | ||
| $<TARGET_OBJECTS:opentelemetry_proto>) | ||
|
|
||
| add_executable(recordable_test recordable_test.cc) | ||
| target_link_libraries(recordable_test | ||
| ${GTEST_BOTH_LIBRARIES} | ||
| ${CMAKE_THREAD_LIBS_INIT} | ||
| opentelemetry_exporter_otprotocol | ||
| protobuf::libprotobuf) | ||
| gtest_add_tests(TARGET recordable_test TEST_PREFIX exporter. TEST_LIST recordable_test) |
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,73 @@ | ||
| #include "exporters/otlp/recordable.h" | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace exporter | ||
| { | ||
| namespace otlp | ||
| { | ||
| TEST(Recordable, SetIds) | ||
| { | ||
| const trace::TraceId trace_id( | ||
| std::array<const uint8_t, trace::TraceId::kSize>( | ||
| {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})); | ||
|
|
||
| const trace::SpanId span_id( | ||
| std::array<const uint8_t, trace::SpanId::kSize>( | ||
| {0, 0, 0, 0, 0, 0, 0, 2})); | ||
|
|
||
| const trace::SpanId parent_span_id( | ||
| std::array<const uint8_t, trace::SpanId::kSize>( | ||
| {0, 0, 0, 0, 0, 0, 0, 3})); | ||
|
|
||
| Recordable rec; | ||
|
|
||
| rec.SetIds(trace_id, span_id, parent_span_id); | ||
|
|
||
| EXPECT_EQ(rec.span().trace_id(), | ||
| std::string(reinterpret_cast<const char *>(trace_id.Id().data()), trace::TraceId::kSize)); | ||
| EXPECT_EQ(rec.span().span_id(), | ||
| std::string(reinterpret_cast<const char *>(span_id.Id().data()), trace::SpanId::kSize)); | ||
| EXPECT_EQ(rec.span().parent_span_id(), | ||
| std::string(reinterpret_cast<const char *>(parent_span_id.Id().data()), trace::SpanId::kSize)); | ||
| } | ||
|
|
||
| TEST(Recordable, SetName) | ||
| { | ||
| Recordable rec; | ||
| nostd::string_view name = "TestSpan"; | ||
| rec.SetName(name); | ||
| EXPECT_EQ(rec.span().name(), name); | ||
| } | ||
|
|
||
| TEST(Recordable, SetStartTime) | ||
| { | ||
| Recordable rec; | ||
| std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now(); | ||
| core::SystemTimestamp start_timestamp(start_time); | ||
|
|
||
| uint64_t unix_start = | ||
| std::chrono::duration_cast<std::chrono::nanoseconds>(start_time.time_since_epoch()).count(); | ||
|
|
||
| rec.SetStartTime(start_timestamp); | ||
| EXPECT_EQ(rec.span().start_time_unixnano(), unix_start); | ||
| } | ||
|
|
||
| TEST(Recordable, SetDuration) | ||
| { | ||
| Recordable rec; | ||
| // Start time is 0 | ||
| core::SystemTimestamp start_timestamp; | ||
|
|
||
| std::chrono::nanoseconds duration(10); | ||
| uint64_t unix_end = duration.count(); | ||
|
|
||
| rec.SetStartTime(start_timestamp); | ||
| rec.SetDuration(duration); | ||
|
|
||
| EXPECT_EQ(rec.span().end_time_unixnano(), unix_end); | ||
| } | ||
| } // namespace otlp | ||
| } // namespace exporter | ||
| OPENTELEMETRY_END_NAMESPACE |
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.
Uh oh!
There was an error while loading. Please reload this page.