Skip to content

Commit

Permalink
Fix some C++ warnings (open-telemetry#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentingodeau authored Mar 24, 2021
1 parent 5933f9f commit bd68a22
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class SpanContext final
trace_api::TraceId trace_id_;
trace_api::SpanId span_id_;
trace_api::TraceFlags trace_flags_;
bool is_remote_;
nostd::shared_ptr<trace_api::TraceState> trace_state_;
bool is_remote_ = false;
};
} // namespace trace
OPENTELEMETRY_END_NAMESPACE
1 change: 0 additions & 1 deletion api/include/opentelemetry/trace/trace_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class TraceState

std::size_t begin{0};
std::size_t end{0};
bool invalid_header = false;
while (begin < header.size() && ts->num_entries_ < kMaxKeyValuePairs)
{
// find list-member
Expand Down
1 change: 0 additions & 1 deletion exporters/ostream/test/ostream_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ TEST(OStreamLogExporter, IntegrationTest)
" span_id : 0000000000000000\n"
" trace_flags : 00\n"
"}\n";
"}\n";

ASSERT_EQ(stdcoutOutput.str(), expectedOutput);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,22 @@ class HttpOperation
// Default connectivity and response size options
bool is_raw_response = false,
std::chrono::milliseconds http_conn_timeout = default_http_conn_timeout)
: method_(method),
url_(url),
callback_(callback),
request_mode_(request_mode),
// Local vars
request_headers_(request_headers),
request_body_(request_body),
: is_aborted_(false),
is_finished_(false),
// Optional connection params
is_raw_response_(is_raw_response),
http_conn_timeout_(http_conn_timeout),
request_mode_(request_mode),
curl_(nullptr),
// Result
res_(CURLE_OK),
callback_(callback),
method_(method),
url_(url),
// Local vars
request_headers_(request_headers),
request_body_(request_body),
sockfd_(0),
is_aborted_(false),
is_finished_(false),
nread_(0)
{
/* get a curl handle */
Expand Down Expand Up @@ -406,7 +407,7 @@ class HttpOperation
CURL *curl_; // Local curl instance
CURLcode res_; // Curl result OR HTTP status code if successful

http_client::EventHandler *callback_ = nullptr;
http_client::EventHandler *callback_;

// Request values
http_client::Method method_;
Expand Down
6 changes: 3 additions & 3 deletions sdk/include/opentelemetry/sdk/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class Logger final : public opentelemetry::logs::Logger
core::SystemTimestamp timestamp) noexcept override;

private:
// The name of this logger
std::string logger_name_;

// The logger provider of this Logger. Uses a weak_ptr to avoid cyclic dependency issues the with
// logger provider
std::weak_ptr<LoggerProvider> logger_provider_;

// The name of this logger
std::string logger_name_;
};

} // namespace logs
Expand Down
1 change: 0 additions & 1 deletion sdk/include/opentelemetry/sdk/logs/recordable.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/core/timestamp.h"
#include "opentelemetry/logs/severity.h"
#include "opentelemetry/sdk/common/empty_attributes.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/span_id.h"
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/logs/batch_log_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ TEST_F(BatchLogProcessorTest, TestScheduledDelayMillis)
auto batch_processor = GetMockProcessor(logs_received, is_shutdown, is_export_completed,
export_delay, scheduled_delay_millis);

for (int i = 0; i < max_export_batch_size; ++i)
for (std::size_t i = 0; i < max_export_batch_size; ++i)
{
auto log = batch_processor->MakeRecordable();
log->SetName("Log" + std::to_string(i));
Expand Down
10 changes: 10 additions & 0 deletions sdk/test/resource/resource_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ TEST(ResourceTest, create_with_servicename)
{
EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end());
if (expected_attributes.find(e.first) != expected_attributes.end())
{
if (e.first == "version")
EXPECT_EQ(opentelemetry::nostd::get<uint32_t>(expected_attributes.find(e.first)->second),
opentelemetry::nostd::get<uint32_t>(e.second));
Expand All @@ -79,6 +80,7 @@ TEST(ResourceTest, create_with_servicename)
else
EXPECT_EQ(opentelemetry::nostd::get<std::string>(expected_attributes.find(e.first)->second),
opentelemetry::nostd::get<std::string>(e.second));
}
}
EXPECT_EQ(received_attributes.size(), expected_attributes.size()); // for missing service.name
}
Expand Down Expand Up @@ -118,8 +120,10 @@ TEST(ResourceTest, Merge)
{
EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end());
if (expected_attributes.find(e.first) != expected_attributes.end())
{
EXPECT_EQ(expected_attributes.find(e.first)->second,
opentelemetry::nostd::get<std::string>(e.second));
}
}
EXPECT_EQ(received_attributes.size(), expected_attributes.size());
}
Expand All @@ -138,8 +142,10 @@ TEST(ResourceTest, MergeEmptyString)
{
EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end());
if (expected_attributes.find(e.first) != expected_attributes.end())
{
EXPECT_EQ(expected_attributes.find(e.first)->second,
opentelemetry::nostd::get<std::string>(e.second));
}
}
EXPECT_EQ(received_attributes.size(), expected_attributes.size());
}
Expand All @@ -161,8 +167,10 @@ TEST(ResourceTest, OtelResourceDetector)
{
EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end());
if (expected_attributes.find(e.first) != expected_attributes.end())
{
EXPECT_EQ(expected_attributes.find(e.first)->second,
opentelemetry::nostd::get<std::string>(e.second));
}
}
EXPECT_EQ(received_attributes.size(), expected_attributes.size());
unsetenv("OTEL_RESOURCE_ATTRIBUTES");
Expand All @@ -179,8 +187,10 @@ TEST(ResourceTest, OtelResourceDetectorEmptyEnv)
{
EXPECT_TRUE(expected_attributes.find(e.first) != expected_attributes.end());
if (expected_attributes.find(e.first) != expected_attributes.end())
{
EXPECT_EQ(expected_attributes.find(e.first)->second,
opentelemetry::nostd::get<std::string>(e.second));
}
}
EXPECT_EQ(received_attributes.size(), expected_attributes.size());
}
Expand Down

0 comments on commit bd68a22

Please sign in to comment.