Skip to content

Commit dfe421b

Browse files
authored
Merge branch 'main' into FixJaegerIds
2 parents b89ca2c + 5acf4cf commit dfe421b

File tree

13 files changed

+39
-54
lines changed

13 files changed

+39
-54
lines changed

.bazelrc

+3
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ common:tsan --copt -fsanitize=thread
1919
common:tsan --copt -DTHREAD_SANITIZER
2020
common:tsan --linkopt -fsanitize=thread
2121
common:tsan --cc_output_directory_tag=tsan
22+
# This is needed to address false positive problem with abseil.The same setting as gRPC
23+
# https://github.com/google/sanitizers/issues/953
24+
common:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0

CMakeLists.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)
5050
option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)
5151

5252
if(WITH_ABSEIL)
53-
add_definitions(-DHAVE_ABSEIL)
5453
find_package(absl CONFIG REQUIRED)
5554

56-
set(CORE_RUNTIME_LIBS absl::any absl::base absl::bits absl::city)
55+
set(CORE_RUNTIME_LIBS absl::bad_variant_access absl::any absl::base
56+
absl::bits absl::city)
5757

5858
# target_link_libraries(main PRIVATE absl::any absl::base absl::bits
5959
# absl::city)
@@ -67,7 +67,7 @@ if(WITH_STL)
6767
add_definitions(-DHAVE_CPP_STDLIB)
6868
add_definitions(-DHAVE_GSL)
6969
# Require at least C++17. C++20 is needed to avoid gsl::span
70-
if(CMAKE_MINOR_VERSION VERSION_GREATER "3.18")
70+
if(CMAKE_VERSION VERSION_GREATER 3.18.0)
7171
# Ask for 20, may get anything below
7272
set(CMAKE_CXX_STANDARD 20)
7373
else()
@@ -92,8 +92,7 @@ if(WITH_STL)
9292
set(MSVC_CXX_OPT_FLAG "/O2")
9393
endif()
9494
endif()
95-
set(CMAKE_CXX_FLAGS
96-
"${CMAKE_CXX_FLAGS} /Zc:__cplusplus ${MSVC_CXX_OPT_FLAG}")
95+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_OPT_FLAG}")
9796
endif()
9897
endif()
9998

@@ -168,8 +167,10 @@ if(MSVC)
168167
# Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value
169168
# for recent C++ language standards. Without this option MSVC returns the
170169
# value of __cplusplus="199711L"
171-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
172-
170+
if(MSVC_VERSION GREATER 1900)
171+
# __cplusplus flag is not supported by Visual Studio 2015
172+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
173+
endif()
173174
# When using vcpkg, all targets build with the same runtime
174175
if(VCPKG_TOOLCHAIN)
175176
set(CMAKE_MSVC_RUNTIME_LIBRARY

api/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ if(BUILD_TESTING)
4141
add_subdirectory(test)
4242
endif()
4343

44+
if(WITH_ABSEIL)
45+
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
46+
endif()
47+
4448
if(WITH_STL)
4549
message("Building with standard library types...")
4650
target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB

api/include/opentelemetry/nostd/variant.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ OPENTELEMETRY_END_NAMESPACE
4747
# endif
4848

4949
# ifdef HAVE_ABSEIL
50-
# include "absl/types/variant.h"
50+
# include <absl/types/variant.h>
5151
# else
5252
# include "./absl/types/variant.h"
5353
# endif

api/include/opentelemetry/trace/propagation/b3_propagator.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ class B3Propagator : public B3PropagatorExtractor
139139

140140
char trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 3];
141141
static_assert(sizeof(trace_identity) == 51, "b3 trace identity buffer size mismatch");
142-
span_context.trace_id().ToLowerBase16(
143-
nostd::span<char, 2 * TraceId::kSize>{&trace_identity[0], kTraceIdHexStrLength});
142+
span_context.trace_id().ToLowerBase16(nostd::span<char, 2 * TraceId::kSize>{
143+
&trace_identity[0], static_cast<std::size_t>(kTraceIdHexStrLength)});
144144
trace_identity[kTraceIdHexStrLength] = '-';
145145
span_context.span_id().ToLowerBase16(nostd::span<char, 2 * SpanId::kSize>{
146-
&trace_identity[kTraceIdHexStrLength + 1], kSpanIdHexStrLength});
146+
&trace_identity[kTraceIdHexStrLength + 1], static_cast<std::size_t>(kSpanIdHexStrLength)});
147147
trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 1] = '-';
148148
trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 2] =
149149
span_context.trace_flags().IsSampled() ? '1' : '0';

api/test/nostd/variant_test.cc

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ TEST(VariantSizeTest, GetVariantSize)
2727
EXPECT_EQ((nostd::variant_size<nostd::variant<int, double>>::value), 2);
2828
}
2929

30+
#if 0 // Disable this test for now. It does not compile with Visual Studio 2015.
3031
TEST(VariantAlternativeTest, GetVariantSize)
3132
{
3233
EXPECT_TRUE((std::is_same<nostd::variant_alternative_t<0, nostd::variant<int>>, int>::value));
@@ -35,6 +36,7 @@ TEST(VariantAlternativeTest, GetVariantSize)
3536
EXPECT_TRUE((std::is_same<nostd::variant_alternative_t<1, const nostd::variant<int, double>>,
3637
const double>::value));
3738
}
39+
#endif
3840

3941
TEST(VariantTest, Get)
4042
{

examples/grpc/client.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
// Make sure to include GRPC headers first because otherwise Abseil may create
2+
// ambiguity with `nostd::variant` if compiled with Visual Studio 2015. Other
3+
// modern compilers are unaffected.
4+
#include <grpcpp/grpcpp.h>
5+
#include "messages.grpc.pb.h"
6+
17
#include "tracer_common.h"
28
#include <iostream>
39
#include <memory>
410
#include <string>
511

6-
#include <grpcpp/grpcpp.h>
7-
8-
#include "messages.grpc.pb.h"
9-
1012
using grpc::Channel;
1113
using grpc::ClientContext;
1214
using grpc::ClientReader;

exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# endif
99
# endif
1010
#else
11-
# ifdef HAVE_TLD
12-
# include "TraceLoggingDynamic.h"
11+
# ifndef HAVE_TLD
12+
# define HAVE_TLD
1313
# endif
14+
# include "TraceLoggingDynamic.h"
1415
#endif

exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,12 @@ static inline bool CopySpanIdToActivityId(const trace::SpanContext &spanContext,
291291
{
292292
return false;
293293
}
294-
auto spanId = spanContext.span_id().Id().data();
295-
std::copy(spanId, spanId + 8, reinterpret_cast<uint8_t *>(&outGuid));
294+
auto spanId = spanContext.span_id().Id().data();
295+
uint8_t *guidPtr = reinterpret_cast<uint8_t *>(&outGuid);
296+
for (size_t i = 0; i < 8; i++)
297+
{
298+
guidPtr[i] = spanId[i];
299+
}
296300
return true;
297301
};
298302

exporters/etw/test/etw_perf_test.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
using namespace OPENTELEMETRY_NAMESPACE;
1616

17-
using Properties = opentelemetry::exporter::etw::Properties;
18-
using PropertyValue = opentelemetry::exporter::etw::PropertyValue;
19-
using PropertyValueMap = opentelemetry::exporter::etw::PropertyValueMap;
17+
using namespace opentelemetry::exporter::etw;
2018

2119
namespace
2220
{

exporters/etw/test/etw_tracer_test.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
using namespace OPENTELEMETRY_NAMESPACE;
1414

15-
using Properties = opentelemetry::exporter::etw::Properties;
16-
using PropertyValue = opentelemetry::exporter::etw::PropertyValue;
17-
using PropertyValueMap = opentelemetry::exporter::etw::PropertyValueMap;
15+
using namespace opentelemetry::exporter::etw;
1816

1917
std::string getTemporaryValue()
2018
{

sdk/include/opentelemetry/sdk/trace/multi_span_processor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class MultiSpanProcessor : public SpanProcessor
148148
ProcessorNode(std::unique_ptr<SpanProcessor> &&value,
149149
ProcessorNode *prev = nullptr,
150150
ProcessorNode *next = nullptr)
151-
: value_(std::move(value)), prev_(prev), next_(next)
151+
: value_(std::move(value)), next_(next), prev_(prev)
152152
{}
153153
};
154154

sdk/src/common/core.cc

-28
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,3 @@
66
#include "opentelemetry/version.h"
77
#include "opentelemetry/nostd/variant.h"
88
// clang-format on
9-
10-
#if defined(HAVE_ABSEIL)
11-
/* The option of building and linking with Abseil library implies that Abseil
12-
* may already provide the ThrowBadVariantAccess implementation if its own.
13-
* Reconsider the implementation below: we are potentially introducing
14-
* a function that is already implemented in the Abseil. Most likely the code
15-
* below needs to be removed entirely.
16-
*/
17-
# if defined(__GNUC__) || defined(__GNUG__)
18-
# ifndef __cdecl
19-
// see https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html
20-
// Intel x86 architecture specific calling conventions
21-
# ifdef _M_IX86
22-
# define __cdecl __attribute__((__cdecl__))
23-
# else
24-
# define __cdecl
25-
# endif
26-
# endif
27-
# endif
28-
29-
namespace absl
30-
{
31-
namespace variant_internal
32-
{
33-
void __cdecl ThrowBadVariantAccess(){/* TODO: std::terminate or re-throw? */};
34-
}
35-
} // namespace absl
36-
#endif

0 commit comments

Comments
 (0)