Skip to content

Commit

Permalink
Merge branch 'main' into maxgolov/etw_warnings_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored May 6, 2021
2 parents 5ff935c + 556061a commit cda3b8b
Show file tree
Hide file tree
Showing 37 changed files with 316 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@
/out.*
# Indicator that the tools were deployed
.buildtools

# Temporary Bazel directories
/bazel-*
/plugin
/build
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <initializer_list>
#include <memory>
#include <vector>
#include "opentelemetry/trace/propagation/text_map_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
namespace context
{
namespace propagation
{
Expand Down Expand Up @@ -68,5 +68,5 @@ class CompositePropagator : public TextMapPropagator
std::vector<std::unique_ptr<TextMapPropagator>> propagators_;
};
} // namespace propagation
} // namespace trace
} // namespace context
OPENTELEMETRY_END_NAMESPACE;
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

#include <mutex>

#include "opentelemetry/trace/propagation/noop_propagator.h"
#include "opentelemetry/trace/propagation/text_map_propagator.h"
#include "opentelemetry/context/propagation/noop_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"

#include "opentelemetry/common/spin_lock_mutex.h"
#include "opentelemetry/nostd/shared_ptr.h"

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
namespace context
{
namespace propagation
{
Expand Down Expand Up @@ -62,5 +62,5 @@ class GlobalTextMapPropagator
};

} // namespace propagation
} // namespace trace
} // namespace context
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "opentelemetry/trace/propagation/text_map_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
namespace context
{
namespace propagation
{
Expand All @@ -26,5 +26,5 @@ class NoOpPropagator : public TextMapPropagator
void Inject(TextMapCarrier & /*carrier*/, const context::Context &context) noexcept override {}
};
} // namespace propagation
} // namespace trace
} // namespace context
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
namespace context
{
namespace propagation
{
Expand Down Expand Up @@ -39,5 +39,5 @@ class TextMapPropagator
virtual void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept = 0;
};
} // namespace propagation
} // namespace trace
} // namespace context
OPENTELEMETRY_END_NAMESPACE
14 changes: 8 additions & 6 deletions api/include/opentelemetry/trace/propagation/b3_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "detail/context.h"
#include "detail/hex.h"
#include "detail/string.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/trace/default_span.h"
#include "opentelemetry/trace/propagation/text_map_propagator.h"

#include <array>

Expand Down Expand Up @@ -38,11 +38,11 @@ static const int kSpanIdHexStrLength = 16;
// providing the object containing the headers, and a getter function for the extraction. Based on:
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md#b3-extract

class B3PropagatorExtractor : public TextMapPropagator
class B3PropagatorExtractor : public opentelemetry::context::propagation::TextMapPropagator
{
public:
// Returns the context that is stored in the HTTP header carrier.
context::Context Extract(const TextMapCarrier &carrier,
context::Context Extract(const opentelemetry::context::propagation::TextMapCarrier &carrier,
context::Context &context) noexcept override
{
SpanContext span_context = ExtractImpl(carrier);
Expand Down Expand Up @@ -74,7 +74,7 @@ class B3PropagatorExtractor : public TextMapPropagator
}

private:
static SpanContext ExtractImpl(const TextMapCarrier &carrier)
static SpanContext ExtractImpl(const opentelemetry::context::propagation::TextMapCarrier &carrier)
{
nostd::string_view trace_id_hex;
nostd::string_view span_id_hex;
Expand Down Expand Up @@ -125,7 +125,8 @@ class B3Propagator : public B3PropagatorExtractor
{
public:
// Sets the context for a HTTP header carrier with self defined rules.
void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
const context::Context &context) noexcept override
{
SpanContext span_context = detail::GetCurrentSpan(context);
if (!span_context.IsValid())
Expand All @@ -151,7 +152,8 @@ class B3Propagator : public B3PropagatorExtractor
class B3PropagatorMultiHeader : public B3PropagatorExtractor
{
public:
void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
const context::Context &context) noexcept override
{
SpanContext span_context = detail::GetCurrentSpan(context);
if (!span_context.IsValid())
Expand Down
14 changes: 8 additions & 6 deletions api/include/opentelemetry/trace/propagation/http_trace_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "detail/context.h"
#include "detail/hex.h"
#include "detail/string.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/trace/default_span.h"
#include "opentelemetry/trace/propagation/text_map_propagator.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
Expand All @@ -39,10 +39,11 @@ static const size_t kTraceParentSize = 55;
// HttpTraceContext().inject(setter, carrier, context);
// HttpTraceContext().extract(getter, carrier, context);

class HttpTraceContext : public TextMapPropagator
class HttpTraceContext : public opentelemetry::context::propagation::TextMapPropagator
{
public:
void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
const context::Context &context) noexcept override
{
SpanContext span_context = detail::GetCurrentSpan(context);
if (!span_context.IsValid())
Expand All @@ -52,7 +53,7 @@ class HttpTraceContext : public TextMapPropagator
InjectImpl(carrier, span_context);
}

context::Context Extract(const TextMapCarrier &carrier,
context::Context Extract(const opentelemetry::context::propagation::TextMapCarrier &carrier,
context::Context &context) noexcept override
{
SpanContext span_context = ExtractImpl(carrier);
Expand Down Expand Up @@ -91,7 +92,8 @@ class HttpTraceContext : public TextMapPropagator
return version != kInvalidVersion;
}

static void InjectImpl(TextMapCarrier &carrier, const SpanContext &span_context)
static void InjectImpl(opentelemetry::context::propagation::TextMapCarrier &carrier,
const SpanContext &span_context)
{
char trace_parent[kTraceParentSize];
trace_parent[0] = '0';
Expand Down Expand Up @@ -158,7 +160,7 @@ class HttpTraceContext : public TextMapPropagator
opentelemetry::trace::TraceState::FromHeader(trace_state));
}

static SpanContext ExtractImpl(const TextMapCarrier &carrier)
static SpanContext ExtractImpl(const opentelemetry::context::propagation::TextMapCarrier &carrier)
{
nostd::string_view trace_parent = carrier.Get(kTraceParent);
nostd::string_view trace_state = carrier.Get(kTraceState);
Expand Down
11 changes: 6 additions & 5 deletions api/include/opentelemetry/trace/propagation/jaeger.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "detail/context.h"
#include "detail/hex.h"
#include "detail/string.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/trace/default_span.h"
#include "opentelemetry/trace/propagation/text_map_propagator.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
Expand All @@ -28,10 +28,11 @@ namespace propagation

static const nostd::string_view kTraceHeader = "uber-trace-id";

class JaegerPropagator : public TextMapPropagator
class JaegerPropagator : public context::propagation::TextMapPropagator
{
public:
void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override
void Inject(context::propagation::TextMapCarrier &carrier,
const context::Context &context) noexcept override
{
SpanContext span_context = detail::GetCurrentSpan(context);
if (!span_context.IsValid())
Expand All @@ -58,7 +59,7 @@ class JaegerPropagator : public TextMapPropagator
carrier.Set(kTraceHeader, nostd::string_view(trace_identity, sizeof(trace_identity)));
}

context::Context Extract(const TextMapCarrier &carrier,
context::Context Extract(const context::propagation::TextMapCarrier &carrier,
context::Context &context) noexcept override
{
SpanContext span_context = ExtractImpl(carrier);
Expand All @@ -75,7 +76,7 @@ class JaegerPropagator : public TextMapPropagator
return TraceFlags(sampled);
}

static SpanContext ExtractImpl(const TextMapCarrier &carrier)
static SpanContext ExtractImpl(const context::propagation::TextMapCarrier &carrier)
{
nostd::string_view trace_identity = carrier.Get(kTraceHeader);

Expand Down
2 changes: 2 additions & 0 deletions api/test/context/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(propagation)

include(GoogleTest)

foreach(testname context_test runtime_context_test)
Expand Down
12 changes: 12 additions & 0 deletions api/test/context/propagation/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//bazel:otel_cc_benchmark.bzl", "otel_cc_benchmark")

cc_test(
name = "composite_propagator_test",
srcs = [
"composite_propagator_test.cc",
],
deps = [
"//api",
"@com_google_googletest//:gtest_main",
],
)
10 changes: 10 additions & 0 deletions api/test/context/propagation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
foreach(testname composite_propagator_test)
add_executable(${testname} "${testname}.cc")
target_link_libraries(
${testname} ${GTEST_BOTH_LIBRARIES} ${CORE_RUNTIME_LIBS}
${CMAKE_THREAD_LIBS_INIT} opentelemetry_api)
gtest_add_tests(
TARGET ${testname}
TEST_PREFIX trace.
TEST_LIST ${testname})
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context.h"

#include "opentelemetry/context/propagation/composite_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/trace/default_span.h"
#include "opentelemetry/trace/propagation/b3_propagator.h"
#include "opentelemetry/trace/propagation/composite_propagator.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"
#include "opentelemetry/trace/propagation/text_map_propagator.h"

#include <map>
#include <memory>
Expand All @@ -25,7 +25,7 @@ static std::string Hex(const T &id_item)
return std::string(buf, sizeof(buf));
}

class TextMapCarrierTest : public trace::propagation::TextMapCarrier
class TextMapCarrierTest : public context::propagation::TextMapCarrier
{
public:
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
Expand All @@ -51,21 +51,22 @@ class CompositePropagatorTest : public ::testing::Test
public:
CompositePropagatorTest()
{
std::vector<std::unique_ptr<trace::propagation::TextMapPropagator>> propogator_list = {};
std::unique_ptr<trace::propagation::TextMapPropagator> w3c_propogator(
std::vector<std::unique_ptr<context::propagation::TextMapPropagator>> propogator_list = {};
std::unique_ptr<context::propagation::TextMapPropagator> w3c_propogator(
new trace::propagation::HttpTraceContext());
std::unique_ptr<trace::propagation::TextMapPropagator> b3_propogator(
std::unique_ptr<context::propagation::TextMapPropagator> b3_propogator(
new trace::propagation::B3Propagator());
propogator_list.push_back(std::move(w3c_propogator));
propogator_list.push_back(std::move(b3_propogator));

composite_propagator_ = new trace::propagation::CompositePropagator(std::move(propogator_list));
composite_propagator_ =
new context::propagation::CompositePropagator(std::move(propogator_list));
}

~CompositePropagatorTest() { delete composite_propagator_; }

protected:
trace::propagation::CompositePropagator *composite_propagator_;
context::propagation::CompositePropagator *composite_propagator_;
};

TEST_F(CompositePropagatorTest, Extract)
Expand Down
2 changes: 1 addition & 1 deletion api/test/trace/propagation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
foreach(testname http_text_format_test b3_propagation_test
jaeger_propagation_test composite_propagator_test)
jaeger_propagation_test)
add_executable(${testname} "${testname}.cc")
target_link_libraries(
${testname} ${GTEST_BOTH_LIBRARIES} ${CORE_RUNTIME_LIBS}
Expand Down
2 changes: 1 addition & 1 deletion api/test/trace/propagation/b3_propagation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using namespace opentelemetry;

class TextMapCarrierTest : public trace::propagation::TextMapCarrier
class TextMapCarrierTest : public context::propagation::TextMapCarrier
{
public:
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
Expand Down
12 changes: 6 additions & 6 deletions api/test/trace/propagation/http_text_format_test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "opentelemetry/context/propagation/global_propagator.h"
#include "opentelemetry/context/runtime_context.h"
#include "opentelemetry/trace/propagation/global_propagator.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"
#include "opentelemetry/trace/scope.h"
#include "util.h"
Expand All @@ -11,7 +11,7 @@

using namespace opentelemetry;

class TextMapCarrierTest : public trace::propagation::TextMapCarrier
class TextMapCarrierTest : public context::propagation::TextMapCarrier
{
public:
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
Expand Down Expand Up @@ -155,7 +155,7 @@ TEST(TextMapPropagatorTest, InvalidIdentitiesAreNotExtracted)
TEST(GlobalTextMapPropagator, NoOpPropagator)
{

auto propagator = trace::propagation::GlobalTextMapPropagator::GetGlobalPropagator();
auto propagator = context::propagation::GlobalTextMapPropagator::GetGlobalPropagator();
TextMapCarrierTest carrier;

carrier.headers_ = {{"traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-0102030405060708-01"},
Expand All @@ -176,10 +176,10 @@ TEST(GlobalPropagator, SetAndGet)
{

auto trace_state_value = "congo=t61rcWkgMzE";
trace::propagation::GlobalTextMapPropagator::SetGlobalPropagator(
nostd::shared_ptr<trace::propagation::TextMapPropagator>(new MapHttpTraceContext()));
context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(
nostd::shared_ptr<context::propagation::TextMapPropagator>(new MapHttpTraceContext()));

auto propagator = trace::propagation::GlobalTextMapPropagator::GetGlobalPropagator();
auto propagator = context::propagation::GlobalTextMapPropagator::GetGlobalPropagator();

TextMapCarrierTest carrier;
carrier.headers_ = {{"traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-0102030405060708-01"},
Expand Down
2 changes: 1 addition & 1 deletion api/test/trace/propagation/jaeger_propagation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using namespace opentelemetry;

class TextMapCarrierTest : public trace::propagation::TextMapCarrier
class TextMapCarrierTest : public context::propagation::TextMapCarrier
{
public:
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
Expand Down
1 change: 1 addition & 0 deletions exporters/memory/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cc_library(
strip_include_prefix = "include",
deps = [
"//api",
"//sdk/src/resource",
"//sdk/src/trace",
],
)
Expand Down
Loading

0 comments on commit cda3b8b

Please sign in to comment.