diff --git a/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h b/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h index 9783504d2d..81caa0d75c 100644 --- a/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h +++ b/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h @@ -75,7 +75,7 @@ namespace variant_internal { [[noreturn]] static inline void ThrowBadVariantAccess() { THROW_BAD_VARIANT_ACCESS; -}; +} //[[noreturn]] static inline void Rethrow() //{ // THROW_BAD_VARIANT_ACCESS; // Unused! diff --git a/api/test/trace/span_benchmark.cc b/api/test/trace/span_benchmark.cc index ef14cd4ca3..fc54081ca6 100644 --- a/api/test/trace/span_benchmark.cc +++ b/api/test/trace/span_benchmark.cc @@ -55,19 +55,19 @@ void BM_NestedSpanCreationWithScope(benchmark::State &state) auto tracer = initTracer(); while (state.KeepRunning()) { - auto span = tracer->StartSpan("outer"); - auto scope = tracer->WithActiveSpan(span); + auto o_span = tracer->StartSpan("outer"); + auto o_scope = tracer->WithActiveSpan(o_span); { - auto span = tracer->StartSpan("inner"); - auto scope = tracer->WithActiveSpan(span); + auto i_span = tracer->StartSpan("inner"); + auto i_scope = tracer->WithActiveSpan(i_span); { - auto span = tracer->StartSpan("innermost"); - auto scope = tracer->WithActiveSpan(span); - span->End(); + auto im_span = tracer->StartSpan("innermost"); + auto im_scope = tracer->WithActiveSpan(im_span); + im_span->End(); } - span->End(); + i_span->End(); } - span->End(); + o_span->End(); } } diff --git a/examples/grpc/tracer_common.h b/examples/grpc/tracer_common.h index 51ffeb101f..71f0afeaa7 100644 --- a/examples/grpc/tracer_common.h +++ b/examples/grpc/tracer_common.h @@ -29,7 +29,7 @@ class GrpcClientCarrier : public opentelemetry::context::propagation::TextMapCar GrpcClientCarrier(ClientContext *context) : context_(context) {} GrpcClientCarrier() = default; virtual opentelemetry::nostd::string_view Get( - opentelemetry::nostd::string_view key) const noexcept override + opentelemetry::nostd::string_view /* key */) const noexcept override { return ""; } @@ -60,8 +60,8 @@ class GrpcServerCarrier : public opentelemetry::context::propagation::TextMapCar return ""; } - virtual void Set(opentelemetry::nostd::string_view key, - opentelemetry::nostd::string_view value) noexcept override + virtual void Set(opentelemetry::nostd::string_view /* key */, + opentelemetry::nostd::string_view /* value */) noexcept override { // Not required for server } diff --git a/examples/multithreaded/main.cc b/examples/multithreaded/main.cc index bb6020bf58..33679f8309 100644 --- a/examples/multithreaded/main.cc +++ b/examples/multithreaded/main.cc @@ -46,7 +46,7 @@ void run_threads() // parent spans across threads. threads.push_back(std::thread([=] { trace_api::Scope scope(thread_span); - auto thread_span = + auto thread_span_2 = get_tracer()->StartSpan(std::string("thread ") + std::to_string(thread_num)); })); } diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 1c1b8678ca..55de64438d 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -45,6 +45,10 @@ class Span final : public trace::Span const common::KeyValueIterable & /*attributes*/) noexcept override {} + void AddEvent(nostd::string_view /*name*/, + const common::KeyValueIterable & /*attributes*/) noexcept override + {} + void SetStatus(trace::StatusCode /*code*/, nostd::string_view /*description*/) noexcept override {} diff --git a/exporters/elasticsearch/src/es_log_exporter.cc b/exporters/elasticsearch/src/es_log_exporter.cc index 618f6d6b30..3d7ee72949 100644 --- a/exporters/elasticsearch/src/es_log_exporter.cc +++ b/exporters/elasticsearch/src/es_log_exporter.cc @@ -107,25 +107,61 @@ class ResponseHandler : public http_client::EventHandler } // Callback method when an http event occurs - void OnEvent(http_client::SessionState state, nostd::string_view reason) noexcept override + void OnEvent(http_client::SessionState state, nostd::string_view /* reason */) noexcept override { // If any failure event occurs, release the condition variable to unblock main thread switch (state) { + case http_client::SessionState::CreateFailed: + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Failed to create session"); + cv_.notify_all(); + break; + case http_client::SessionState::Created: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Session created"); + break; + case http_client::SessionState::Destroyed: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Session destroyed"); + break; + case http_client::SessionState::Connecting: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Connecting to peer"); + break; case http_client::SessionState::ConnectFailed: - OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Connection to elasticsearch failed"); + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Failed to connect to peer"); cv_.notify_all(); break; + case http_client::SessionState::Connected: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Connected to peer"); + break; + case http_client::SessionState::Sending: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Sending request"); + break; case http_client::SessionState::SendFailed: - OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Request failed to be sent to elasticsearch"); + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Failed to send request"); + cv_.notify_all(); + break; + case http_client::SessionState::Response: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Received response"); + break; + case http_client::SessionState::SSLHandshakeFailed: + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Failed SSL Handshake"); cv_.notify_all(); break; case http_client::SessionState::TimedOut: - OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Request to elasticsearch timed out"); + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Request timed out"); cv_.notify_all(); break; case http_client::SessionState::NetworkError: - OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Network error to elasticsearch"); + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] Network error"); + cv_.notify_all(); + break; + case http_client::SessionState::ReadError: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Read error"); + break; + case http_client::SessionState::WriteError: + OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Write error"); + break; + case http_client::SessionState::Cancelled: + OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] (manually) cancelled"); cv_.notify_all(); break; } @@ -160,15 +196,15 @@ class AsyncResponseHandler : public http_client::EventHandler std::shared_ptr session, std::function &&result_callback, bool console_debug = false) - : console_debug_{console_debug}, - session_{std::move(session)}, - result_callback_{std::move(result_callback)} + : session_{std::move(session)}, + result_callback_{std::move(result_callback)}, + console_debug_{console_debug} {} /** * Cleans up the session in the destructor. */ - ~AsyncResponseHandler() { session_->FinishSession(); } + ~AsyncResponseHandler() override { session_->FinishSession(); } /** * Automatically called when the response is received @@ -197,7 +233,7 @@ class AsyncResponseHandler : public http_client::EventHandler } // Callback method when an http event occurs - void OnEvent(http_client::SessionState state, nostd::string_view reason) noexcept override + void OnEvent(http_client::SessionState state, nostd::string_view /* reason */) noexcept override { bool need_stop = false; switch (state) @@ -364,7 +400,7 @@ sdk::common::ExportResult ElasticsearchLogExporter::Export( # endif } -bool ElasticsearchLogExporter::Shutdown(std::chrono::microseconds timeout) noexcept +bool ElasticsearchLogExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { const std::lock_guard locked(lock_); is_shutdown_ = true; diff --git a/exporters/elasticsearch/test/es_log_exporter_test.cc b/exporters/elasticsearch/test/es_log_exporter_test.cc index 943f9fa7ba..e256c969e7 100644 --- a/exporters/elasticsearch/test/es_log_exporter_test.cc +++ b/exporters/elasticsearch/test/es_log_exporter_test.cc @@ -83,4 +83,4 @@ TEST(ElasticsearchLogsExporterTests, RecordableCreation) exporter->Export(nostd::span>(&record, 1)); } # endif -#endif \ No newline at end of file +#endif diff --git a/exporters/jaeger/BUILD b/exporters/jaeger/BUILD index 156d7cde62..1937d4457e 100644 --- a/exporters/jaeger/BUILD +++ b/exporters/jaeger/BUILD @@ -177,6 +177,8 @@ cc_library( "include/opentelemetry/exporters/jaeger/jaeger_exporter_factory.h", "include/opentelemetry/exporters/jaeger/jaeger_exporter_options.h", "include/opentelemetry/exporters/jaeger/recordable.h", + "include/opentelemetry/exporters/jaeger/thrift_include_prefix.h", + "include/opentelemetry/exporters/jaeger/thrift_include_suffix.h", ], copts = ["-fexceptions"], strip_include_prefix = "include", diff --git a/exporters/jaeger/CMakeLists.txt b/exporters/jaeger/CMakeLists.txt index 017b43d494..9641300124 100644 --- a/exporters/jaeger/CMakeLists.txt +++ b/exporters/jaeger/CMakeLists.txt @@ -9,6 +9,14 @@ set(JAEGER_THRIFT_GENCPP_SOURCES thrift-gen/Agent.cpp thrift-gen/jaeger_types.cpp thrift-gen/Collector.cpp thrift-gen/zipkincore_types.cpp) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message("Relaxing GCC warnings on thrift-gen") + # THRIFT generated code is not warning clean for gcc. + set_source_files_properties( + ${JAEGER_THRIFT_GENCPP_SOURCES} PROPERTIES COMPILE_OPTIONS + "-Wno-suggest-override") +endif() + set(JAEGER_EXPORTER_SOURCES src/jaeger_exporter.cc src/jaeger_exporter_factory.cc diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h index e604d56d79..b1b944fd07 100644 --- a/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h @@ -3,7 +3,12 @@ #pragma once +#include + #include + +#include + #include #include diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/thrift_include_prefix.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/thrift_include_prefix.h new file mode 100644 index 0000000000..92754d4800 --- /dev/null +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/thrift_include_prefix.h @@ -0,0 +1,11 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// This file may be include multiple times, do not add #pragma once here + +#if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) +# if (__GNUC__ * 100 + __GNUC_MINOR__ * 10) >= 460 +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wsuggest-override" +#endif diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/thrift_include_suffix.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/thrift_include_suffix.h new file mode 100644 index 0000000000..fc276705c3 --- /dev/null +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/thrift_include_suffix.h @@ -0,0 +1,10 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// This file may be include multiple times, do not add #pragma once here + +#if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) +# if (__GNUC__ * 100 + __GNUC_MINOR__ * 10) >= 460 +# pragma GCC diagnostic pop +# endif +#endif diff --git a/exporters/jaeger/src/jaeger_exporter.cc b/exporters/jaeger/src/jaeger_exporter.cc index 9e1dac1162..8e9e75bd73 100644 --- a/exporters/jaeger/src/jaeger_exporter.cc +++ b/exporters/jaeger/src/jaeger_exporter.cc @@ -1,7 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include + #include + +#include + #include #include #include "opentelemetry/sdk_config.h" diff --git a/exporters/jaeger/src/thrift_sender.h b/exporters/jaeger/src/thrift_sender.h index 0ec8d47f11..687f6fac45 100644 --- a/exporters/jaeger/src/thrift_sender.h +++ b/exporters/jaeger/src/thrift_sender.h @@ -3,7 +3,12 @@ #pragma once +#include + #include + +#include + #include #include #include diff --git a/exporters/jaeger/src/transport.h b/exporters/jaeger/src/transport.h index 8121e30076..d7ba8fa604 100644 --- a/exporters/jaeger/src/transport.h +++ b/exporters/jaeger/src/transport.h @@ -5,8 +5,12 @@ #include +#include + #include +#include + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/jaeger/src/udp_transport.h b/exporters/jaeger/src/udp_transport.h index 3e07992f47..ce1f51e647 100644 --- a/exporters/jaeger/src/udp_transport.h +++ b/exporters/jaeger/src/udp_transport.h @@ -6,7 +6,12 @@ #include "TUDPTransport.h" #include "transport.h" +#include + #include + +#include + #include #include #include diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h index f8f0cabfdd..b10898ac3c 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h @@ -30,7 +30,7 @@ namespace otlp class OtlpLogRecordable final : public opentelemetry::sdk::logs::Recordable { public: - virtual ~OtlpLogRecordable() = default; + ~OtlpLogRecordable() override = default; proto::logs::v1::LogRecord &log_record() noexcept { return log_record_; } const proto::logs::v1::LogRecord &log_record() const noexcept { return log_record_; } diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/protobuf_include_prefix.h b/exporters/otlp/include/opentelemetry/exporters/otlp/protobuf_include_prefix.h index ae103b0173..036cb0ae7f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/protobuf_include_prefix.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/protobuf_include_prefix.h @@ -34,4 +34,5 @@ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunused-parameter" # pragma clang diagnostic ignored "-Wtype-limits" -#endif \ No newline at end of file +# pragma clang diagnostic ignored "-Wshadow-field" +#endif diff --git a/exporters/otlp/test/otlp_recordable_test.cc b/exporters/otlp/test/otlp_recordable_test.cc index 03e6a37b99..abad2991b7 100644 --- a/exporters/otlp/test/otlp_recordable_test.cc +++ b/exporters/otlp/test/otlp_recordable_test.cc @@ -2,6 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/otlp/otlp_recordable.h" + +#if defined(__GNUC__) +// GCC raises -Wsuggest-override warnings on GTest, +// in code related to TYPED_TEST() . +# pragma GCC diagnostic ignored "-Wsuggest-override" +#endif + #include OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/zipkin/test/zipkin_exporter_test.cc b/exporters/zipkin/test/zipkin_exporter_test.cc index eec71f43d6..af518d1655 100644 --- a/exporters/zipkin/test/zipkin_exporter_test.cc +++ b/exporters/zipkin/test/zipkin_exporter_test.cc @@ -148,9 +148,9 @@ TEST_F(ZipkinExporterTestPeer, ExportJsonIntegrationTest) auto expected_url = nostd::string_view{"http://localhost:9411/api/v2/spans"}; EXPECT_CALL(*mock_http_client, Post(expected_url, IsValidMessage(report_trace_id), _)) .Times(Exactly(1)) - .WillOnce(Return(ByMove(std::move(ext::http::client::Result{ + .WillOnce(Return(ByMove(ext::http::client::Result{ std::unique_ptr{new ext::http::client::curl::Response()}, - ext::http::client::SessionState::Response})))); + ext::http::client::SessionState::Response}))); child_span->End(); parent_span->End(); @@ -172,9 +172,9 @@ TEST_F(ZipkinExporterTestPeer, ShutdownTest) nostd::span> batch_1(&recordable_1, 1); EXPECT_CALL(*mock_http_client, Post(_, _, _)) .Times(Exactly(1)) - .WillOnce(Return(ByMove(std::move(ext::http::client::Result{ + .WillOnce(Return(ByMove(ext::http::client::Result{ std::unique_ptr{new ext::http::client::curl::Response()}, - ext::http::client::SessionState::Response})))); + ext::http::client::SessionState::Response}))); auto result = exporter->Export(batch_1); EXPECT_EQ(sdk_common::ExportResult::kSuccess, result); diff --git a/exporters/zipkin/test/zipkin_recordable_test.cc b/exporters/zipkin/test/zipkin_recordable_test.cc index 5da618d5b2..630ca332f0 100644 --- a/exporters/zipkin/test/zipkin_recordable_test.cc +++ b/exporters/zipkin/test/zipkin_recordable_test.cc @@ -12,6 +12,12 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/zipkin/recordable.h" +#if defined(__GNUC__) +// GCC raises -Wsuggest-override warnings on GTest, +// in code related to TYPED_TEST() . +# pragma GCC diagnostic ignored "-Wsuggest-override" +#endif + #include namespace trace = opentelemetry::trace; diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h index e942564e28..efeb6dc675 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h @@ -87,7 +87,7 @@ class BatchLogProcessor : public LogProcessor /** * Class destructor which invokes the Shutdown() method. */ - virtual ~BatchLogProcessor(); + ~BatchLogProcessor() override; protected: /** diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index 9afb67ba0c..e91c69040e 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -61,7 +61,7 @@ class LoggerProvider final : public opentelemetry::logs::LoggerProvider */ explicit LoggerProvider(std::shared_ptr context) noexcept; - ~LoggerProvider(); + ~LoggerProvider() override; /** * Creates a logger with the given name, and returns a shared pointer to it. diff --git a/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h b/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h index 227e2e020f..6b23a2652f 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h @@ -29,7 +29,7 @@ class MultiLogProcessor : public LogProcessor { public: MultiLogProcessor(std::vector> &&processors); - ~MultiLogProcessor(); + ~MultiLogProcessor() override; void AddProcessor(std::unique_ptr &&processor); diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h index 8364cedd4c..f8f29542a5 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h @@ -29,7 +29,7 @@ class SimpleLogProcessor : public LogProcessor public: explicit SimpleLogProcessor(std::unique_ptr &&exporter); - virtual ~SimpleLogProcessor() = default; + ~SimpleLogProcessor() override = default; std::unique_ptr MakeRecordable() noexcept override; diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h index 1a0abeb6b6..a809f026b0 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h @@ -32,10 +32,11 @@ class FixedSizeExemplarReservoir : public ExemplarReservoir map_and_reset_cell_(map_and_reset_cell) {} - void OfferMeasurement(long value, - const MetricAttributes &attributes, - const opentelemetry::context::Context &context, - const opentelemetry::common::SystemTimestamp ×tamp) noexcept override + void OfferMeasurement( + long value, + const MetricAttributes &attributes, + const opentelemetry::context::Context &context, + const opentelemetry::common::SystemTimestamp & /* timestamp */) noexcept override { if (!reservoir_cell_selector_) { @@ -49,10 +50,11 @@ class FixedSizeExemplarReservoir : public ExemplarReservoir } } - void OfferMeasurement(double value, - const MetricAttributes &attributes, - const opentelemetry::context::Context &context, - const opentelemetry::common::SystemTimestamp ×tamp) noexcept override + void OfferMeasurement( + double value, + const MetricAttributes &attributes, + const opentelemetry::context::Context &context, + const opentelemetry::common::SystemTimestamp & /* timestamp */) noexcept override { if (!reservoir_cell_selector_) { diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h index 83f410f815..5481327a5a 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/histogram_exemplar_reservoir.h @@ -50,10 +50,10 @@ class HistogramExemplarReservoir : public FixedSizeExemplarReservoir return ReservoirCellIndexFor(cells, (double)value, attributes, context); } - int ReservoirCellIndexFor(const std::vector &cells, + int ReservoirCellIndexFor(const std::vector & /* cells */, double value, - const MetricAttributes &attributes, - const opentelemetry::context::Context &context) override + const MetricAttributes & /* attributes */, + const opentelemetry::context::Context & /* context */) override { for (size_t i = 0; i < boundaries_.size(); ++i) { diff --git a/sdk/include/opentelemetry/sdk/metrics/exemplar/with_trace_sample_filter.h b/sdk/include/opentelemetry/sdk/metrics/exemplar/with_trace_sample_filter.h index b81ccbccb2..46fceb306d 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exemplar/with_trace_sample_filter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exemplar/with_trace_sample_filter.h @@ -15,15 +15,15 @@ namespace metrics class WithTraceSampleFilter final : public ExemplarFilter { public: - bool ShouldSampleMeasurement(long value, - const MetricAttributes &attributes, + bool ShouldSampleMeasurement(long /* value */, + const MetricAttributes & /* attributes */, const opentelemetry::context::Context &context) noexcept override { return hasSampledTrace(context); } - bool ShouldSampleMeasurement(double value, - const MetricAttributes &attributes, + bool ShouldSampleMeasurement(double /* value */, + const MetricAttributes & /* attributes */, const opentelemetry::context::Context &context) noexcept override { return hasSampledTrace(context); diff --git a/sdk/include/opentelemetry/sdk/metrics/instruments.h b/sdk/include/opentelemetry/sdk/metrics/instruments.h index a529095600..b176eabe5e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/instruments.h @@ -62,18 +62,6 @@ struct InstrumentDescriptor using MetricAttributes = opentelemetry::sdk::common::OrderedAttributeMap; using AggregationTemporalitySelector = std::function; -OPENTELEMETRY_MAYBE_UNUSED static InstrumentClass GetInstrumentClass(InstrumentType type) -{ - if (type == InstrumentType::kCounter || type == InstrumentType::kHistogram || - type == InstrumentType::kUpDownCounter) - { - return InstrumentClass::kSync; - } - else - { - return InstrumentClass::kAsync; - } -} /*class InstrumentSelector { public: diff --git a/sdk/test/common/random_test.cc b/sdk/test/common/random_test.cc index 35cfd4a1ee..8132b2d5a4 100644 --- a/sdk/test/common/random_test.cc +++ b/sdk/test/common/random_test.cc @@ -16,20 +16,21 @@ TEST(RandomTest, GenerateRandom64) TEST(RandomTest, GenerateRandomBuffer) { - uint8_t buf1[8] = {0}; - uint8_t buf2[8] = {0}; - Random::GenerateRandomBuffer(buf1); - Random::GenerateRandomBuffer(buf2); - EXPECT_FALSE(std::equal(std::begin(buf1), std::end(buf1), std::begin(buf2))); + uint8_t buf1_array[8] = {0}; + uint8_t buf2_array[8] = {0}; + Random::GenerateRandomBuffer(buf1_array); + Random::GenerateRandomBuffer(buf2_array); + EXPECT_FALSE(std::equal(std::begin(buf1_array), std::end(buf1_array), std::begin(buf2_array))); // Edge cases. for (auto size : {7, 8, 9, 16, 17}) { - std::vector buf1(size); - std::vector buf2(size); + std::vector buf1_vector(size); + std::vector buf2_vector(size); - Random::GenerateRandomBuffer(buf1); - Random::GenerateRandomBuffer(buf2); - EXPECT_FALSE(std::equal(std::begin(buf1), std::end(buf1), std::begin(buf2))); + Random::GenerateRandomBuffer(buf1_vector); + Random::GenerateRandomBuffer(buf2_vector); + EXPECT_FALSE( + std::equal(std::begin(buf1_vector), std::end(buf1_vector), std::begin(buf2_vector))); } } diff --git a/sdk/test/metrics/async_metric_storage_test.cc b/sdk/test/metrics/async_metric_storage_test.cc index 74fff4661d..7e19912353 100644 --- a/sdk/test/metrics/async_metric_storage_test.cc +++ b/sdk/test/metrics/async_metric_storage_test.cc @@ -165,7 +165,6 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) std::shared_ptr{}); long freq_cpu0 = 3l; long freq_cpu1 = 5l; - size_t attribute_count = 2; std::unordered_map measurements1 = { {{{"CPU", "0"}}, freq_cpu0}, {{{"CPU", "1"}}, freq_cpu1}}; storage.RecordLong(measurements1, diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index 77fde74d03..b4cd12416c 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -115,7 +115,7 @@ TEST(MeterTest, StressMultiThread) } if (do_collect.exchange(false)) { - metric_reader_ptr->Collect([](ResourceMetrics &metric_data) { return true; }); + metric_reader_ptr->Collect([](ResourceMetrics & /* metric_data */) { return true; }); do_sync_create.store(true); } }); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 16be43fa6f..3287b39e5d 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -723,10 +723,10 @@ TEST(Tracer, SpanCleanupWithScope) auto span0 = tracer->StartSpan("Span0"); auto span1 = tracer->StartSpan("span1"); { - trace_api::Scope scope(span1); + trace_api::Scope scope1(span1); auto span2 = tracer->StartSpan("span2"); { - trace_api::Scope scope(span2); + trace_api::Scope scope2(span2); auto span3 = tracer->StartSpan("span3"); } }