Skip to content

Commit

Permalink
resolved aditya's questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianlin-Zhao committed Aug 21, 2020
1 parent 4ff679b commit 3f03636
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
11 changes: 11 additions & 0 deletions api/test/trace/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ cc_test(
],
)

cc_test(
name = "noop_test",
srcs = [
"noop_test.cc",
],
deps = [
"//api",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "key_value_iterable_view_test",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion api/test/trace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foreach(testname key_value_iterable_view_test provider_test span_id_test
foreach(testname key_value_iterable_view_test provider_test span_id_test noop_test
trace_id_test trace_flags_test span_context_test)
add_executable(${testname} "${testname}.cc")
target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES}
Expand Down
29 changes: 29 additions & 0 deletions api/test/trace/noop_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "opentelemetry/trace/noop.h"

#include <map>
#include <memory>
#include <string>

#include <gtest/gtest.h>

using opentelemetry::trace::NoopTracer;
using opentelemetry::trace::Tracer;

TEST(NoopTest, UseNoopTracers)
{
std::shared_ptr<Tracer> tracer{new NoopTracer{}};
auto s1 = tracer->StartSpan("abc");

std::map<std::string, std::string> attributes1;
s1->AddEvent("abc", attributes1);

std::vector<std::pair<std::string, int>> attributes2;
s1->AddEvent("abc", attributes2);

s1->AddEvent("abc", {{"a", 1}, {"b", "2"}, {"c", 3.0}});

std::vector<std::pair<std::string, std::vector<int>>> attributes3;
s1->AddEvent("abc", attributes3);

s1->SetAttribute("abc", 4);
}

0 comments on commit 3f03636

Please sign in to comment.