Skip to content

Commit

Permalink
Upgrade clang-format to 10.x, run ./tools/format.sh (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdandrutu authored Feb 1, 2021
1 parent 2836677 commit 20db113
Show file tree
Hide file tree
Showing 29 changed files with 166 additions and 213 deletions.
5 changes: 2 additions & 3 deletions api/include/opentelemetry/common/key_value_iterable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ class KeyValueIterable
* the iteration is aborted.
* @return true if every key-value pair was iterated over
*/
virtual bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> callback) const
noexcept = 0;
virtual bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, common::AttributeValue)>
callback) const noexcept = 0;

/**
* @return the number of key-value pairs
Expand Down
5 changes: 2 additions & 3 deletions api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ class KeyValueIterableView final : public KeyValueIterable
explicit KeyValueIterableView(const T &container) noexcept : container_{&container} {}

// KeyValueIterable
bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> callback) const
noexcept override
bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, common::AttributeValue)>
callback) const noexcept override
{
auto iter = std::begin(*container_);
auto last = std::end(*container_);
Expand Down
5 changes: 3 additions & 2 deletions api/include/opentelemetry/nostd/mpark/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,9 @@ namespace detail
{

template <std::size_t I, typename V>
inline constexpr /* auto * */ auto generic_get_if(V *v) noexcept AUTO_RETURN(
v &&holds_alternative<I>(*v) ? std::addressof(access::variant::get_alt<I>(*v).value) : nullptr)
inline constexpr /* auto * */ auto generic_get_if(V *v) noexcept
AUTO_RETURN(v &&holds_alternative<I>(*v) ? std::addressof(access::variant::get_alt<I>(*v).value)
: nullptr)

} // namespace detail

Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/nostd/unique_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class unique_ptr
return *this;
}

operator std::unique_ptr<T>() && noexcept { return std::unique_ptr<T>{release()}; }
operator std::unique_ptr<T>() &&noexcept { return std::unique_ptr<T>{release()}; }

operator bool() const noexcept { return ptr_ != nullptr; }

Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/plugin/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class Factory final
* @param error_message on failure this will contain an error message.
* @return a Tracer on success or nullptr on failure.
*/
std::shared_ptr<opentelemetry::trace::Tracer> MakeTracer(nostd::string_view tracer_config,
std::string &error_message) const
noexcept
std::shared_ptr<opentelemetry::trace::Tracer> MakeTracer(
nostd::string_view tracer_config,
std::string &error_message) const noexcept
{
nostd::unique_ptr<char[]> plugin_error_message;
auto tracer_handle = factory_impl_->MakeTracerHandle(tracer_config, plugin_error_message);
Expand Down
13 changes: 6 additions & 7 deletions api/include/opentelemetry/trace/span_context_kv_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,19 @@ class SpanContextKeyValueIterableView final : public SpanContextKeyValueIterable

template <class U,
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
bool do_callback(
SpanContext span_context,
const U &attributes,
nostd::function_ref<bool(SpanContext, const common::KeyValueIterable &)> callback) const
noexcept
bool do_callback(SpanContext span_context,
const U &attributes,
nostd::function_ref<bool(SpanContext, const common::KeyValueIterable &)>
callback) const noexcept
{
return do_callback(span_context, common::KeyValueIterableView<U>(attributes), callback);
}

bool do_callback(
SpanContext span_context,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
nostd::function_ref<bool(SpanContext, const common::KeyValueIterable &)> callback) const
noexcept
nostd::function_ref<bool(SpanContext, const common::KeyValueIterable &)> callback)
const noexcept
{
return do_callback(span_context,
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
Expand Down
10 changes: 5 additions & 5 deletions api/test/trace/key_value_iterable_view_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ TEST(KeyValueIterableViewTest, ForEachKeyValueWithExit)
M m1 = {{"abc", "123"}, {"xyz", "456"}};
common::KeyValueIterableView<M> iterable{m1};
int count = 0;
auto exit = iterable.ForEachKeyValue([&count](nostd::string_view /*key*/,
common::AttributeValue /*value*/) noexcept {
++count;
return false;
});
auto exit = iterable.ForEachKeyValue(
[&count](nostd::string_view /*key*/, common::AttributeValue /*value*/) noexcept {
++count;
return false;
});
EXPECT_EQ(count, 1);
EXPECT_FALSE(exit);
}
3 changes: 1 addition & 2 deletions bazel/otel_cc_benchmark.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def otel_cc_benchmark(name, srcs, deps):
tools = [":" + name],
tags = ["benchmark_result", "manual"],
testonly = True,
cmd = "$(location :" + name + (") --benchmark_color=false " +
"--benchmark_min_time=.1 &> $@"),
cmd = "$(location :" + name + (") --benchmark_color=false --benchmark_min_time=.1 &> $@"),
)

# This is run as part of "bazel test ..." to smoke-test benchmarks. It's
Expand Down
2 changes: 1 addition & 1 deletion ci/install_format_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

apt install -y clang-format-8 python3-pip git curl
apt-get install -y clang-format-10 python3-pip git curl
pip3 install cmake_format==0.6.13
curl -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/2.2.1/buildifier
chmod +x /usr/local/bin/buildifier
4 changes: 2 additions & 2 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ class ETWSpanData final : public sdk::trace::Recordable
* Get the attributes for this span
* @return the attributes for this span
*/
const std::unordered_map<std::string, sdk::common::OwnedAttributeValue> &GetAttributes() const
noexcept
const std::unordered_map<std::string, sdk::common::OwnedAttributeValue> &GetAttributes()
const noexcept
{
return attribute_map_.GetAttributes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ class ETWProvider
{
#ifdef HAVE_TLD
// Register with TraceLoggingDynamic facility - dynamic manifest ETW events.
case EventFormat::ETW_MANIFEST:
{
case EventFormat::ETW_MANIFEST: {
tld::ProviderMetadataBuilder<std::vector<BYTE>> providerMetaBuilder(
data.providerMetaVector);

Expand All @@ -171,8 +170,7 @@ class ETWProvider

#ifdef HAVE_MSGPACK
// Register for MsgPack payload ETW events.
case EventFormat::ETW_MSGPACK:
{
case EventFormat::ETW_MSGPACK: {
REGHANDLE hProvider = 0;
if (EventRegister(&data.providerGuid, NULL, NULL, &hProvider) != ERROR_SUCCESS)
{
Expand Down Expand Up @@ -293,60 +291,51 @@ class ETWProvider
auto &value = kv.second;
switch (value.index())
{
case common::AttributeType::TYPE_BOOL:
{
case common::AttributeType::TYPE_BOOL: {
UINT8 temp = static_cast<UINT8>(nostd::get<bool>(value));
jObj[name] = temp;
break;
}
case common::AttributeType::TYPE_INT:
{
case common::AttributeType::TYPE_INT: {
auto temp = nostd::get<int32_t>(value);
jObj[name] = temp;
break;
}
case common::AttributeType::TYPE_INT64:
{
case common::AttributeType::TYPE_INT64: {
auto temp = nostd::get<int64_t>(value);
jObj[name] = temp;
break;
}
case common::AttributeType::TYPE_UINT:
{
case common::AttributeType::TYPE_UINT: {
auto temp = nostd::get<uint32_t>(value);
jObj[name] = temp;
break;
}
case common::AttributeType::TYPE_UINT64:
{
case common::AttributeType::TYPE_UINT64: {
auto temp = nostd::get<uint64_t>(value);
jObj[name] = temp;
break;
}
case common::AttributeType::TYPE_DOUBLE:
{
case common::AttributeType::TYPE_DOUBLE: {
auto temp = nostd::get<double>(value);
jObj[name] = temp;
break;
}
case common::AttributeType::TYPE_STRING:
{
case common::AttributeType::TYPE_STRING: {
auto temp = nostd::get<nostd::string_view>(value);
jObj[name] = temp;
break;
}
# ifdef HAVE_CSTRING_TYPE
case common::AttributeType::TYPE_CSTRING:
{
case common::AttributeType::TYPE_CSTRING: {
auto temp = nostd::get<const char *>(value);
jObj[name] = temp;
break;
}
# endif
# if HAVE_TYPE_GUID
// TODO: consider adding UUID/GUID to spec
case common::AttributeType::TYPE_GUID:
{
case common::AttributeType::TYPE_GUID: {
auto temp = nostd::get<GUID>(value);
// TODO: add transform from GUID type to string?
jObj[name] = temp;
Expand Down Expand Up @@ -491,58 +480,50 @@ class ETWProvider
auto &value = kv.second;
switch (value.index())
{
case common::AttributeType::TYPE_BOOL:
{
case common::AttributeType::TYPE_BOOL: {
builder.AddField(name, tld::TypeBool8);
UINT8 temp = static_cast<UINT8>(nostd::get<bool>(value));
dbuilder.AddByte(temp);
break;
}
case common::AttributeType::TYPE_INT:
{
case common::AttributeType::TYPE_INT: {
builder.AddField(name, tld::TypeInt32);
auto temp = nostd::get<int32_t>(value);
dbuilder.AddValue(temp);
break;
}
case common::AttributeType::TYPE_INT64:
{
case common::AttributeType::TYPE_INT64: {
builder.AddField(name, tld::TypeInt64);
auto temp = nostd::get<int64_t>(value);
dbuilder.AddValue(temp);
break;
}
case common::AttributeType::TYPE_UINT:
{
case common::AttributeType::TYPE_UINT: {
builder.AddField(name, tld::TypeUInt32);
auto temp = nostd::get<uint32_t>(value);
dbuilder.AddValue(temp);
break;
}
case common::AttributeType::TYPE_UINT64:
{
case common::AttributeType::TYPE_UINT64: {
builder.AddField(name, tld::TypeUInt64);
auto temp = nostd::get<uint64_t>(value);
dbuilder.AddValue(temp);
break;
}
case common::AttributeType::TYPE_DOUBLE:
{
case common::AttributeType::TYPE_DOUBLE: {
builder.AddField(name, tld::TypeDouble);
auto temp = nostd::get<double>(value);
dbuilder.AddValue(temp);
break;
}
case common::AttributeType::TYPE_STRING:
{
case common::AttributeType::TYPE_STRING: {
builder.AddField(name, tld::TypeUtf8String);
auto temp = nostd::get<nostd::string_view>(value);
dbuilder.AddString(temp.data());
break;
}
# ifdef HAVE_CSTRING_TYPE
case common::AttributeType::TYPE_CSTRING:
{
case common::AttributeType::TYPE_CSTRING: {
builder.AddField(name, tld::TypeUtf8String);
auto temp = nostd::get<const char *>(value);
dbuilder.AddString(temp);
Expand All @@ -551,8 +532,7 @@ class ETWProvider
# endif
# if HAVE_TYPE_GUID
// TODO: consider adding UUID/GUID to spec
case common::AttributeType::TYPE_GUID:
{
case common::AttributeType::TYPE_GUID: {
builder.AddField(name.c_str(), TypeGuid);
auto temp = nostd::get<GUID>(value);
dbuilder.AddBytes(&temp, sizeof(GUID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ class InMemorySpanData final
// Pointer swap is required because the Consume function requires that the
// AtomicUniquePointer be set to null
spans_received_.Consume(
spans_received_.size(), [&](opentelemetry::sdk::common::CircularBufferRange<
opentelemetry::sdk::common::AtomicUniquePtr<
opentelemetry::sdk::trace::SpanData>> range) noexcept {
range.ForEach([&](
opentelemetry::sdk::common::AtomicUniquePtr<opentelemetry::sdk::trace::SpanData> &
ptr) noexcept {
std::unique_ptr<opentelemetry::sdk::trace::SpanData> swap_ptr =
std::unique_ptr<opentelemetry::sdk::trace::SpanData>(nullptr);
ptr.Swap(swap_ptr);
res.push_back(std::unique_ptr<opentelemetry::sdk::trace::SpanData>(swap_ptr.release()));
return true;
});
spans_received_.size(),
[&](opentelemetry::sdk::common::CircularBufferRange<
opentelemetry::sdk::common::AtomicUniquePtr<opentelemetry::sdk::trace::SpanData>>
range) noexcept {
range.ForEach(
[&](opentelemetry::sdk::common::AtomicUniquePtr<opentelemetry::sdk::trace::SpanData>
&ptr) noexcept {
std::unique_ptr<opentelemetry::sdk::trace::SpanData> swap_ptr =
std::unique_ptr<opentelemetry::sdk::trace::SpanData>(nullptr);
ptr.Swap(swap_ptr);
res.push_back(
std::unique_ptr<opentelemetry::sdk::trace::SpanData>(swap_ptr.release()));
return true;
});
});

return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class OStreamLogExporter final : public opentelemetry::sdk::logs::LogExporter
* Exports a span of logs sent from the processor.
*/
opentelemetry::sdk::logs::ExportResult Export(
const opentelemetry::nostd::span<std::unique_ptr<sdk::logs::Recordable>>
&records) noexcept override;
const opentelemetry::nostd::span<std::unique_ptr<sdk::logs::Recordable>> &records) noexcept
override;

/**
* Marks the OStream Log Exporter as shut down.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,24 @@ class OStreamMetricsExporter final : public sdkmetrics::MetricsExporter
return;
switch (aggKind)
{
case sdkmetrics::AggregatorKind::Counter:
{
case sdkmetrics::AggregatorKind::Counter: {
sout_ << "\n sum : " << agg->get_checkpoint()[0];
}
break;
case sdkmetrics::AggregatorKind::MinMaxSumCount:
{
case sdkmetrics::AggregatorKind::MinMaxSumCount: {
auto mmsc = agg->get_checkpoint();
sout_ << "\n min : " << mmsc[0] << "\n max : " << mmsc[1]
<< "\n sum : " << mmsc[2] << "\n count : " << mmsc[3];
}
break;
case sdkmetrics::AggregatorKind::Gauge:
{
case sdkmetrics::AggregatorKind::Gauge: {
auto timestamp = agg->get_checkpoint_timestamp();

sout_ << "\n last value : " << agg->get_checkpoint()[0]
<< "\n timestamp : " << std::to_string(timestamp.time_since_epoch().count());
}
break;
case sdkmetrics::AggregatorKind::Exact:
{
case sdkmetrics::AggregatorKind::Exact: {
// TODO: Find better way to print quantiles
if (agg->get_quant_estimation())
{
Expand Down Expand Up @@ -100,8 +96,7 @@ class OStreamMetricsExporter final : public sdkmetrics::MetricsExporter
}
}
break;
case sdkmetrics::AggregatorKind::Histogram:
{
case sdkmetrics::AggregatorKind::Histogram: {
auto boundaries = agg->get_boundaries();
auto counts = agg->get_counts();

Expand Down Expand Up @@ -130,8 +125,7 @@ class OStreamMetricsExporter final : public sdkmetrics::MetricsExporter
sout_ << ']';
}
break;
case sdkmetrics::AggregatorKind::Sketch:
{
case sdkmetrics::AggregatorKind::Sketch: {
auto boundaries = agg->get_boundaries();
auto counts = agg->get_counts();

Expand Down
Loading

0 comments on commit 20db113

Please sign in to comment.