Skip to content

Commit

Permalink
Tentative: apply clang-format-10
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Dec 5, 2023
1 parent 2d3cd10 commit a7e482c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,10 @@ class LoggerProvider : public opentelemetry::logs::LoggerProvider
nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
opentelemetry::nostd::string_view logger_name,
opentelemetry::nostd::string_view library_name,
opentelemetry::nostd::string_view version = "",
opentelemetry::nostd::string_view schema_url = "",
const opentelemetry::common::KeyValueIterable &attributes = opentelemetry::common::NoopKeyValueIterable()) override
opentelemetry::nostd::string_view version = "",
opentelemetry::nostd::string_view schema_url = "",
const opentelemetry::common::KeyValueIterable &attributes =
opentelemetry::common::NoopKeyValueIterable()) override
{
UNREFERENCED_PARAMETER(library_name);
UNREFERENCED_PARAMETER(version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,12 @@ class Properties : public opentelemetry::common::KeyValueIterable, public Proper
Properties &operator=(const opentelemetry::common::KeyValueIterable &other)
{
clear();
other.ForEachKeyValue([&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept {
std::string k(key.data(), key.length());
(*this)[k].FromAttributeValue(value);
return true;
});
other.ForEachKeyValue(
[&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept {
std::string k(key.data(), key.length());
(*this)[k].FromAttributeValue(value);
return true;
});
return (*this);
}

Expand All @@ -431,8 +432,9 @@ class Properties : public opentelemetry::common::KeyValueIterable, public Proper
* the iteration is aborted.
* @return true if every key-value pair was iterated over
*/
bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, opentelemetry::common::AttributeValue)>
callback) const noexcept override
bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, opentelemetry::common::AttributeValue)> callback)
const noexcept override
{
for (const auto &kv : (*this))
{
Expand Down
39 changes: 22 additions & 17 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ class Tracer : public opentelemetry::trace::Tracer,
{
size_t idx = 0;
std::string linksValue;
links.ForEachKeyValue(
[&](opentelemetry::trace::SpanContext ctx, const opentelemetry::common::KeyValueIterable &) {
if (!linksValue.empty())
{
linksValue += ',';
linksValue += ToLowerBase16(ctx.span_id());
}
idx++;
return true;
});
links.ForEachKeyValue([&](opentelemetry::trace::SpanContext ctx,
const opentelemetry::common::KeyValueIterable &) {
if (!linksValue.empty())
{
linksValue += ',';
linksValue += ToLowerBase16(ctx.span_id());
}
idx++;
return true;
});
attributes[ETW_FIELD_SPAN_LINKS] = linksValue;
}
}
Expand Down Expand Up @@ -425,8 +425,9 @@ class Tracer : public opentelemetry::trace::Tracer,
Properties evtCopy = attributes;
return StartSpan(name, evtCopy, links, options);
#else // OPENTELEMETRY_RTTI_ENABLED is defined
opentelemetry::common::KeyValueIterable &attribs = const_cast<opentelemetry::common::KeyValueIterable &>(attributes);
Properties *evt = dynamic_cast<Properties *>(&attribs);
opentelemetry::common::KeyValueIterable &attribs =
const_cast<opentelemetry::common::KeyValueIterable &>(attributes);
Properties *evt = dynamic_cast<Properties *>(&attribs);
if (evt != nullptr)
{
// Pass as a reference to original modifyable collection without creating a copy
Expand Down Expand Up @@ -492,7 +493,8 @@ class Tracer : public opentelemetry::trace::Tracer,
if (sampling_result.decision == sdk::trace::Decision::DROP)
{
auto noopSpan = nostd::shared_ptr<opentelemetry::trace::Span>{
new (std::nothrow) opentelemetry::trace::NoopSpan(this->shared_from_this(), std::move(spanContext))};
new (std::nothrow)
opentelemetry::trace::NoopSpan(this->shared_from_this(), std::move(spanContext))};
return noopSpan;
}

Expand Down Expand Up @@ -614,8 +616,9 @@ class Tracer : public opentelemetry::trace::Tracer,
Properties evtCopy = attributes;
return AddEvent(span, name, timestamp, evtCopy);
#else // OPENTELEMETRY_RTTI_ENABLED is defined
opentelemetry::common::KeyValueIterable &attribs = const_cast<opentelemetry::common::KeyValueIterable &>(attributes);
Properties *evt = dynamic_cast<Properties *>(&attribs);
opentelemetry::common::KeyValueIterable &attribs =
const_cast<opentelemetry::common::KeyValueIterable &>(attributes);
Properties *evt = dynamic_cast<Properties *>(&attribs);
if (evt != nullptr)
{
// Pass as a reference to original modifyable collection without creating a copy
Expand Down Expand Up @@ -849,7 +852,8 @@ class Span : public opentelemetry::trace::Span
* @param timestamp
* @return
*/
void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp) noexcept override
void AddEvent(nostd::string_view name,
opentelemetry::common::SystemTimestamp timestamp) noexcept override
{
owner_.AddEvent(*this, name, timestamp);
}
Expand Down Expand Up @@ -901,7 +905,8 @@ class Span : public opentelemetry::trace::Span
* @param value
* @return
*/
void SetAttribute(nostd::string_view key, const opentelemetry::common::AttributeValue &value) noexcept override
void SetAttribute(nostd::string_view key,
const opentelemetry::common::AttributeValue &value) noexcept override
{
// don't override fields propagated from span data.
if (key == ETW_FIELD_NAME || key == ETW_FIELD_SPAN_ID || key == ETW_FIELD_TRACE_ID ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class OtlpRecordable final : public opentelemetry::sdk::trace::Recordable
void AddLink(const opentelemetry::trace::SpanContext &span_context,
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;

void SetStatus(opentelemetry::trace::StatusCode code, nostd::string_view description) noexcept override;
void SetStatus(opentelemetry::trace::StatusCode code,
nostd::string_view description) noexcept override;

void SetName(nostd::string_view name) noexcept override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class InstrumentationScope
void SetAttribute(nostd::string_view key,
const opentelemetry::common::AttributeValue &value) noexcept
{
attributes_[std::string(key)] = nostd::visit(opentelemetry::sdk::common::AttributeConverter(), value);
attributes_[std::string(key)] =
nostd::visit(opentelemetry::sdk::common::AttributeConverter(), value);
}

private:
Expand Down
9 changes: 6 additions & 3 deletions sdk/include/opentelemetry/sdk/trace/span_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class SpanDataEvent
* Get the attributes for this event
* @return the attributes for this event
*/
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> &GetAttributes() const noexcept
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>
&GetAttributes() const noexcept
{
return attribute_map_.GetAttributes();
}
Expand All @@ -81,7 +82,8 @@ class SpanDataLink
* Get the attributes for this link
* @return the attributes for this link
*/
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> &GetAttributes() const noexcept
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>
&GetAttributes() const noexcept
{
return attribute_map_.GetAttributes();
}
Expand Down Expand Up @@ -210,7 +212,8 @@ class SpanData final : public Recordable
* Get the attributes for this span
* @return the attributes for this span
*/
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> &GetAttributes() const noexcept
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>
&GetAttributes() const noexcept
{
return attribute_map_.GetAttributes();
}
Expand Down

0 comments on commit a7e482c

Please sign in to comment.