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

[ETW Exporter] Add Virtual destructor for TailSampler, Update Maintainer mode warnings for MSVC #1897

Merged
merged 15 commits into from
Jan 4, 2023
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ if(OTELCPP_MAINTAINER_MODE)
add_compile_options(/wd4267)

# Enforced warnings
add_compile_options(/we4265) # 'class': class has virtual functions, but
# destructor is not virtual
add_compile_options(/we5204) # A class with virtual functions has
# non-virtual trivial destructor.

elseif()
message(FATAL_ERROR "Building with unknown compiler in maintainer mode.")
endif()
Expand Down
4 changes: 2 additions & 2 deletions api/test/nostd/span_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ TEST(SpanTest, Iteration)
std::array<int, 3> array = {1, 2, 3};

span<int> s1{array.data(), array.size()};
EXPECT_EQ(std::distance(s1.begin(), s1.end()), array.size());
EXPECT_EQ(std::distance(s1.begin(), s1.end()), (ptrdiff_t)array.size());
EXPECT_TRUE(std::equal(s1.begin(), s1.end(), array.begin()));

span<int, 3> s2{array.data(), array.size()};
EXPECT_EQ(std::distance(s2.begin(), s2.end()), array.size());
EXPECT_EQ(std::distance(s2.begin(), s2.end()), (ptrdiff_t)array.size());
EXPECT_TRUE(std::equal(s2.begin(), s2.end(), array.begin()));
}
2 changes: 1 addition & 1 deletion examples/http/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[])
// The port the validation service listens to can be specified via the command line.
if (argc > 1)
{
port = atoi(argv[1]);
port = (uint16_t)(atoi(argv[1]));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion examples/http/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char *argv[])
// The port the validation service listens to can be specified via the command line.
if (argc > 1)
{
server_port = atoi(argv[1]);
server_port = (uint16_t)atoi(argv[1]);
}

HttpServer http_server(server_name, server_port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TailSampler
// Span::GetContext()
virtual opentelemetry::sdk::trace::SamplingResult ShouldSample(
const opentelemetry::trace::Span &span) noexcept = 0;
virtual ~TailSampler() = default;
};

class AlwaysOnTailSampler : public TailSampler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#include "opentelemetry/ext/http/client/http_client.h"
#include "opentelemetry/version.h"

#include <future>
#if defined(_MSC_VER)
# pragma warning(suppress : 5204)
# include <future>
#else
# include <future>
#endif

#include <map>
#include <regex>
#include <sstream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
#include "opentelemetry/sdk/metrics/push_metric_exporter.h"

#include <chrono>
#include <future>
#if defined(_MSC_VER)
# pragma warning(suppress : 5204)
# include <future>
#else
# include <future>
#endif

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
Expand Down
6 changes: 3 additions & 3 deletions sdk/test/trace/tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ TEST(Tracer, StartSpanWithAttributes)
ASSERT_EQ(9, cur_span_data->GetAttributes().size());
ASSERT_EQ(314159, nostd::get<int32_t>(cur_span_data->GetAttributes().at("attr1")));
ASSERT_EQ(false, nostd::get<bool>(cur_span_data->GetAttributes().at("attr2")));
ASSERT_EQ(314159, nostd::get<uint32_t>(cur_span_data->GetAttributes().at("attr3")));
ASSERT_EQ((uint32_t)314159, nostd::get<uint32_t>(cur_span_data->GetAttributes().at("attr3")));
ASSERT_EQ(-20, nostd::get<int32_t>(cur_span_data->GetAttributes().at("attr4")));
ASSERT_EQ(20, nostd::get<uint32_t>(cur_span_data->GetAttributes().at("attr5")));
ASSERT_EQ((uint32_t)20, nostd::get<uint32_t>(cur_span_data->GetAttributes().at("attr5")));
ASSERT_EQ(-20, nostd::get<int64_t>(cur_span_data->GetAttributes().at("attr6")));
ASSERT_EQ(20, nostd::get<uint64_t>(cur_span_data->GetAttributes().at("attr7")));
ASSERT_EQ((uint64_t)20, nostd::get<uint64_t>(cur_span_data->GetAttributes().at("attr7")));
ASSERT_EQ(3.1, nostd::get<double>(cur_span_data->GetAttributes().at("attr8")));
ASSERT_EQ("string", nostd::get<std::string>(cur_span_data->GetAttributes().at("attr9")));

Expand Down