Skip to content

Commit

Permalink
Fix more build warnings (open-telemetry#1616) (open-telemetry#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored and yxue committed Dec 5, 2022
1 parent 28fa090 commit 6aed2da
Show file tree
Hide file tree
Showing 37 changed files with 159 additions and 65 deletions.
2 changes: 1 addition & 1 deletion api/include/opentelemetry/context/runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Token
public:
bool operator==(const Context &other) const noexcept { return context_ == other; }

~Token();
~Token() noexcept;

private:
friend class RuntimeContextStorage;
Expand Down
10 changes: 10 additions & 0 deletions api/include/opentelemetry/logs/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ class NoopLogger final : public Logger
trace::TraceFlags /* trace_flags */,
common::SystemTimestamp /* timestamp */) noexcept override
{}

void Log(Severity /* severity */,
nostd::string_view /* name */,
nostd::string_view /* body */,
const common::KeyValueIterable & /* attributes */,
trace::TraceId /* trace_id */,
trace::SpanId /* span_id */,
trace::TraceFlags /* trace_flags */,
common::SystemTimestamp /* timestamp */) noexcept override
{}
};

/**
Expand Down
3 changes: 3 additions & 0 deletions api/include/opentelemetry/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ using ObservableCallbackPtr = void (*)(ObserverResult, void *);
class ObservableInstrument
{
public:
ObservableInstrument() = default;
virtual ~ObservableInstrument() = default;

/**
* Sets up a function that will be called whenever a metric collection is initiated.
*/
Expand Down
1 change: 1 addition & 0 deletions api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class NoopUpDownCounter : public UpDownCounter<T>
nostd::string_view /* description */,
nostd::string_view /* unit */) noexcept
{}
~NoopUpDownCounter() = default;
void Add(T /* value */) noexcept override {}
void Add(T /* value */, const opentelemetry::context::Context & /* context */) noexcept override
{}
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/metrics/observer_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ObserverResultT
{

public:
virtual ~ObserverResultT() = default;

virtual void Observe(T value) noexcept = 0;

virtual void Observe(T value, const common::KeyValueIterable &attributes) noexcept = 0;
Expand Down
6 changes: 5 additions & 1 deletion api/include/opentelemetry/metrics/sync_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ namespace metrics
{

class SynchronousInstrument
{};
{
public:
SynchronousInstrument() = default;
virtual ~SynchronousInstrument() = default;
};

template <class T>
class Counter : public SynchronousInstrument
Expand Down
23 changes: 12 additions & 11 deletions api/include/opentelemetry/nostd/detail/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,25 @@ inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&... args)
#endif
} // namespace detail

/* clang-format off */
template <typename F, typename... Args>
inline constexpr auto invoke(F &&f, Args &&... args)
OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward<F>(f), std::forward<Args>(args)...));
OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward<F>(f), std::forward<Args>(args)...))

namespace detail
/* clang-format on */
{

template <typename Void, typename, typename...>
struct invoke_result
{};
template <typename Void, typename, typename...>
struct invoke_result
{};

template <typename F, typename... Args>
struct invoke_result<void_t<decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...))>,
F,
Args...>
{
using type = decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...));
};
template <typename F, typename... Args>
struct invoke_result<void_t<decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...))>,
F, Args...>
{
using type = decltype(nostd::invoke(std::declval<F>(), std::declval<Args>()...));
};

} // namespace detail

Expand Down
6 changes: 6 additions & 0 deletions api/include/opentelemetry/plugin/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class Span final : public trace::Span
span_->AddEvent(name, timestamp);
}

void AddEvent(nostd::string_view name,
const common::KeyValueIterable &attributes) noexcept override
{
span_->AddEvent(name, attributes);
}

void AddEvent(nostd::string_view name,
common::SystemTimestamp timestamp,
const common::KeyValueIterable &attributes) noexcept override
Expand Down
29 changes: 15 additions & 14 deletions api/include/opentelemetry/trace/default_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,34 @@ class DefaultSpan : public Span
// Returns an invalid span.
static DefaultSpan GetInvalid() { return DefaultSpan(SpanContext::GetInvalid()); }

trace::SpanContext GetContext() const noexcept { return span_context_; }
trace::SpanContext GetContext() const noexcept override { return span_context_; }

bool IsRecording() const noexcept { return false; }
bool IsRecording() const noexcept override { return false; }

void SetAttribute(nostd::string_view /* key */,
const common::AttributeValue & /* value */) noexcept
const common::AttributeValue & /* value */) noexcept override
{}

void AddEvent(nostd::string_view /* name */) noexcept {}
void AddEvent(nostd::string_view /* name */) noexcept override {}

void AddEvent(nostd::string_view /* name */, common::SystemTimestamp /* timestamp */) noexcept {}
void AddEvent(nostd::string_view /* name */,
common::SystemTimestamp /* timestamp */) noexcept override
{}

void AddEvent(nostd::string_view /* name */,
common::SystemTimestamp /* timestamp */,
const common::KeyValueIterable & /* attributes */) noexcept
const common::KeyValueIterable & /* attributes */) noexcept override
{}

void AddEvent(nostd::string_view name, const common::KeyValueIterable &attributes) noexcept
{
this->AddEvent(name, std::chrono::system_clock::now(), attributes);
}
void AddEvent(nostd::string_view /* name */,
common::SystemTimestamp /* timestamp */,
const common::KeyValueIterable & /* attributes */) noexcept override
{}

void SetStatus(StatusCode /* status */, nostd::string_view /* description */) noexcept {}
void SetStatus(StatusCode /* status */, nostd::string_view /* description */) noexcept override {}

void UpdateName(nostd::string_view /* name */) noexcept {}
void UpdateName(nostd::string_view /* name */) noexcept override {}

void End(const EndSpanOptions & /* options */ = {}) noexcept {}
void End(const EndSpanOptions & /* options */) noexcept override {}

nostd::string_view ToString() const noexcept { return "DefaultSpan"; }

Expand Down
4 changes: 4 additions & 0 deletions api/include/opentelemetry/trace/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class NoopSpan final : public Span
common::SystemTimestamp /*timestamp*/) noexcept override
{}

void AddEvent(nostd::string_view /* name */,
const common::KeyValueIterable & /* attributes */) noexcept override
{}

void AddEvent(nostd::string_view /*name*/,
common::SystemTimestamp /*timestamp*/,
const common::KeyValueIterable & /*attributes*/) noexcept override
Expand Down
10 changes: 10 additions & 0 deletions api/test/logs/logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ class TestLogger : public Logger
trace::TraceFlags /* trace_flags */,
common::SystemTimestamp /* timestamp */) noexcept override
{}

void Log(Severity /* severity */,
nostd::string_view /* name */,
nostd::string_view /* body */,
const common::KeyValueIterable & /* attributes */,
trace::TraceId /* trace_id */,
trace::SpanId /* span_id */,
trace::TraceFlags /* trace_flags */,
common::SystemTimestamp /* timestamp */) noexcept override
{}
};

// Define a basic LoggerProvider class that returns an instance of the logger class defined above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte
std::shared_ptr<InMemorySpanData> data_;
bool is_shutdown_ = false;
mutable opentelemetry::common::SpinLockMutex lock_;
const bool isShutdown() const noexcept
bool isShutdown() const noexcept
{
const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_);
return is_shutdown_;
Expand Down
2 changes: 1 addition & 1 deletion ext/test/http/curl_http_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CustomEventHandler : public http_client::EventHandler
break;
}
}
virtual void OnConnecting(const http_client::SSLCertificate &) noexcept {}
virtual void OnConnecting(const http_client::SSLCertificate &) noexcept override {}
virtual ~CustomEventHandler() = default;
bool is_called_ = false;
bool got_response_ = false;
Expand Down
2 changes: 1 addition & 1 deletion ext/test/http/url_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace http_common = opentelemetry::ext::http::common;

inline const char *const BoolToString(bool b)
inline const char *BoolToString(bool b)
{
return b ? "true" : "false";
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/log_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class LogRecord final : public Recordable
* @param instrumentation_scope the instrumentation scope to set
*/
void SetInstrumentationScope(const opentelemetry::sdk::instrumentationscope::InstrumentationScope
&instrumentation_scope) noexcept
&instrumentation_scope) noexcept override
{
instrumentation_scope_ = &instrumentation_scope;
}
Expand Down
13 changes: 13 additions & 0 deletions sdk/include/opentelemetry/sdk/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ class Logger final : public opentelemetry::logs::Logger
opentelemetry::trace::TraceFlags trace_flags,
opentelemetry::common::SystemTimestamp timestamp) noexcept override;

// Deprecated
void Log(opentelemetry::logs::Severity severity,
nostd::string_view /* name */,
nostd::string_view body,
const opentelemetry::common::KeyValueIterable &attributes,
opentelemetry::trace::TraceId trace_id,
opentelemetry::trace::SpanId span_id,
opentelemetry::trace::TraceFlags trace_flags,
opentelemetry::common::SystemTimestamp timestamp) noexcept override
{
Log(severity, body, attributes, trace_id, span_id, trace_flags, timestamp);
}

/** Returns the associated instrumentation scope */
const opentelemetry::sdk::instrumentationscope::InstrumentationScope &GetInstrumentationScope()
const noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DefaultAggregation
: std::move(std::unique_ptr<Aggregation>(new DoubleLastValueAggregation()));
break;
default:
return std::move(std::unique_ptr<Aggregation>(new DropAggregation()));
return std::unique_ptr<Aggregation>(new DropAggregation());
};
}

Expand Down Expand Up @@ -154,4 +154,4 @@ class DefaultAggregation
} // namespace metrics
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
#endif
#endif
2 changes: 2 additions & 0 deletions sdk/include/opentelemetry/sdk/metrics/observer_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ObserverResultT final : public opentelemetry::metrics::ObserverResultT<T>
: attributes_processor_(attributes_processor)
{}

virtual ~ObserverResultT() = default;

void Observe(T value) noexcept override { data_.insert({{}, value}); }

void Observe(T value, const opentelemetry::common::KeyValueIterable &attributes) noexcept override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AttributesHashMap
return it->second.get();
}

hash_map_[attributes] = std::move(aggregation_callback());
hash_map_[attributes] = aggregation_callback();
return hash_map_[attributes].get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class MetricCollector : public MetricProducer, public CollectorHandle
public:
MetricCollector(MeterContext *context, std::unique_ptr<MetricReader> metric_reader);

virtual ~MetricCollector() = default;

AggregationTemporality GetAggregationTemporality(
InstrumentType instrument_type) noexcept override;

Expand Down
5 changes: 4 additions & 1 deletion sdk/include/opentelemetry/sdk/metrics/state/metric_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class SyncWritableMetricStorage
class AsyncWritableMetricStorage
{
public:
AsyncWritableMetricStorage() = default;
virtual ~AsyncWritableMetricStorage() = default;

/* Records a batch of measurements */
virtual void RecordLong(
const std::unordered_map<MetricAttributes, long, AttributeHashGenerator> &measurements,
Expand Down Expand Up @@ -81,7 +84,7 @@ class NoopMetricStorage : public MetricStorage
class NoopWritableMetricStorage : public SyncWritableMetricStorage
{
public:
void RecordLong(long value, const opentelemetry::context::Context &context) noexcept = 0;
void RecordLong(long value, const opentelemetry::context::Context &context) noexcept override = 0;

void RecordLong(long /* value */,
const opentelemetry::common::KeyValueIterable & /* attributes */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage

{
create_default_aggregation_ = [&]() -> std::unique_ptr<Aggregation> {
return std::move(
DefaultAggregation::CreateAggregation(aggregation_type_, instrument_descriptor_));
return DefaultAggregation::CreateAggregation(aggregation_type_, instrument_descriptor_);
};
}

Expand Down Expand Up @@ -123,4 +122,4 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage
} // namespace metrics
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class InstrumentSelector
public:
InstrumentSelector(opentelemetry::sdk::metrics::InstrumentType instrument_type,
opentelemetry::nostd::string_view name)
: name_filter_{std::move(PredicateFactory::GetPredicate(name, PredicateType::kPattern))},
: name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kPattern)},
instrument_type_{instrument_type}
{}

// Returns name filter predicate. This shouldn't be deleted
const opentelemetry::sdk::metrics::Predicate *const GetNameFilter() { return name_filter_.get(); }
const opentelemetry::sdk::metrics::Predicate *GetNameFilter() const { return name_filter_.get(); }

// Returns instrument filter.
InstrumentType GetInstrumentType() { return instrument_type_; }
Expand All @@ -33,4 +33,4 @@ class InstrumentSelector
} // namespace metrics
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
#endif
#endif
14 changes: 7 additions & 7 deletions sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ class MeterSelector
MeterSelector(opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view version,
opentelemetry::nostd::string_view schema)
: name_filter_{std::move(PredicateFactory::GetPredicate(name, PredicateType::kExact))},
version_filter_{std::move(PredicateFactory::GetPredicate(version, PredicateType::kExact))},
schema_filter_{std::move(PredicateFactory::GetPredicate(schema, PredicateType::kExact))}
: name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kExact)},
version_filter_{PredicateFactory::GetPredicate(version, PredicateType::kExact)},
schema_filter_{PredicateFactory::GetPredicate(schema, PredicateType::kExact)}
{}

// Returns name filter predicate. This shouldn't be deleted
const opentelemetry::sdk::metrics::Predicate *const GetNameFilter() { return name_filter_.get(); }
const opentelemetry::sdk::metrics::Predicate *GetNameFilter() const { return name_filter_.get(); }

// Returns version filter predicate. This shouldn't be deleted
const opentelemetry::sdk::metrics::Predicate *const GetVersionFilter()
const opentelemetry::sdk::metrics::Predicate *GetVersionFilter() const
{
return version_filter_.get();
}

// Returns schema filter predicate. This shouldn't be deleted
const opentelemetry::sdk::metrics::Predicate *const GetSchemaFilter()
const opentelemetry::sdk::metrics::Predicate *GetSchemaFilter() const
{
return schema_filter_.get();
}
Expand All @@ -44,4 +44,4 @@ class MeterSelector
} // namespace metrics
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
#endif
#endif
Loading

0 comments on commit 6aed2da

Please sign in to comment.