Skip to content

Commit

Permalink
Added directories excluding tools, .git, third_party, opentelemetry_l…
Browse files Browse the repository at this point in the history
…ogo.png, TraceLoggingDynamic.h,

Included formatting changes from tools/format.sh
  • Loading branch information
msiddhu committed Jul 3, 2024
1 parent 7aaca5a commit 43d52b2
Show file tree
Hide file tree
Showing 37 changed files with 347 additions and 304 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Checks: 'clang-analyzer-*,performance-*,bugprone-*'
Checks: 'clang-analyzer-*,performance-*,bugprone-*,google-*,concurrency-*'
2 changes: 2 additions & 0 deletions api/include/opentelemetry/baggage/baggage.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ class OPENTELEMETRY_EXPORT Baggage
kv_properties_->GetAllEntries(
[&baggage, &key](nostd::string_view e_key, nostd::string_view e_value) {
if (key != e_key)
{
baggage->kv_properties_->AddEntry(e_key, e_value);
}
return true;
});
return baggage;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/baggage/baggage_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inline nostd::shared_ptr<Baggage> GetBaggage(const context::Context &context) no
}

inline context::Context SetBaggage(context::Context &context,
nostd::shared_ptr<Baggage> baggage) noexcept
const nostd::shared_ptr<Baggage> &baggage) noexcept
{
return context.SetValue(kBaggageHeader, baggage);
}
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Context
// Accepts a new iterable and then returns a new context that
// contains the new key and value data. It attaches the
// exisiting list to the end of the new list.
Context SetValue(nostd::string_view key, ContextValue value) noexcept
Context SetValue(nostd::string_view key, const ContextValue &value) noexcept
{
Context context = Context(key, std::move(value));
Context context = Context(key, value);
context.head_->next_ = head_;
return context;
}
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/nostd/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class string_view
size_type len = (std::min)(size(), v.size());
int result = Traits::compare(data(), v.data(), len);
if (result == 0)
{
result = size() == v.size() ? 0 : (size() < v.size() ? -1 : 1);
}
return result;
}

Expand Down
3 changes: 2 additions & 1 deletion api/include/opentelemetry/trace/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ inline bool IsRootSpan(const context::Context &context) noexcept
}

// Set Span into explicit context
inline context::Context SetSpan(context::Context &context, nostd::shared_ptr<Span> span) noexcept
inline context::Context SetSpan(context::Context &context,
const nostd::shared_ptr<Span> &span) noexcept
{
return context.SetValue(kSpanKey, span);
}
Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/trace/propagation/detail/hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ constexpr int8_t kHexDigits[256] = {

inline int8_t HexToInt(char c)
{
return kHexDigits[uint8_t(c)];
return kHexDigits[static_cast<uint8_t>(c)];
}

inline bool IsValidHex(nostd::string_view s)
Expand All @@ -57,8 +57,8 @@ inline bool HexToBinary(nostd::string_view hex, uint8_t *buffer, size_t buffer_s
return false;
}

int64_t hex_size = int64_t(hex.size());
int64_t buffer_pos = int64_t(buffer_size) - (hex_size + 1) / 2;
int64_t hex_size = static_cast<int64_t>(hex.size());
int64_t buffer_pos = static_cast<int64_t>(buffer_size) - (hex_size + 1) / 2;
int64_t last_hex_pos = hex_size - 1;

bool is_hex_size_odd = (hex_size % 2) == 1;
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/trace/trace_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ class OPENTELEMETRY_EXPORT TraceState
kv_properties_->GetAllEntries(
[&ts, &key](nostd::string_view e_key, nostd::string_view e_value) {
if (key != e_key)
{
ts->kv_properties_->AddEntry(e_key, e_value);
}
return true;
});
return ts;
Expand Down
2 changes: 2 additions & 0 deletions api/test/common/spinlock_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ inline void SpinThrash(benchmark::State &s, SpinLockType &spinlock, LockF lock,
}
// Join threads
for (auto &thread : threads)
{
thread.join();
}
threads.clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/test/nostd/shared_ptr_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static void SharedPtrTest_Sort(size_t size = 10)
auto nums2 = nums;

std::sort(nums.begin(), nums.end(),
[](shared_ptr<const int> a, shared_ptr<const int> b) { return *a < *b; });
[](const shared_ptr<const int> &a, const shared_ptr<const int> &b) { return *a < *b; });

EXPECT_NE(nums, nums2);

Expand Down
2 changes: 2 additions & 0 deletions examples/etw_threads/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ int main(int arc, char **argv)
try
{
if (th.joinable())
{
th.join();
}
}
catch (...)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GreeterClient
public:
GreeterClient(std::shared_ptr<Channel> channel) : stub_(Greeter::NewStub(channel)) {}

std::string Greet(std::string ip, uint16_t port)
std::string Greet(const std::string &ip, uint16_t port)
{
// Build gRPC Context objects and protobuf message containers
GreetRequest request;
Expand Down
3 changes: 2 additions & 1 deletion examples/grpc/tracer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ void CleanupTracer()
opentelemetry::trace::Provider::SetTracerProvider(none);
}

opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> get_tracer(std::string tracer_name)
opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> get_tracer(
const std::string &tracer_name)
{
auto provider = opentelemetry::trace::Provider::GetTracerProvider();
return provider->GetTracer(tracer_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class PropertyValue : public PropertyVariant
* @param v
* @return
*/
PropertyValue() : PropertyVariant(int32_t(0)) {}
PropertyValue() : PropertyVariant(static_cast<int32_t>(0)) {}

/**
* @brief PropertyValue from array of characters as string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Tracer : public opentelemetry::trace::Tracer,
{
size_t idx = 0;
std::string linksValue;
links.ForEachKeyValue([&](opentelemetry::trace::SpanContext ctx,
links.ForEachKeyValue([&](const opentelemetry::trace::SpanContext &ctx,
const opentelemetry::common::KeyValueIterable &) {
if (!linksValue.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions exporters/etw/include/opentelemetry/exporters/etw/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ namespace utils
/// </summary>
static constexpr uint32_t hashCode(const char *str, uint32_t h = 0)
{
return (uint32_t)(!str[h] ? 5381 : ((uint32_t)hashCode(str, h + 1) * (uint32_t)33) ^ str[h]);
return (!str[h] ? 5381 : (hashCode(str, h + 1) * static_cast<uint32_t>(33)) ^ str[h]);
}

#define CONST_UINT32_T(x) std::integral_constant<uint32_t, (uint32_t)x>::value
#define CONST_UINT32_T(x) std::integral_constant<uint32_t, (uint32_t)(x)>::value

#define CONST_HASHCODE(name) CONST_UINT32_T(OPENTELEMETRY_NAMESPACE::utils::hashCode(#name))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ void print_value(const std::vector<T> &vec, std::ostream &sout)
{
sout << v;
if (i != sz)
{
sout << ',';
}
i++;
};
sout << ']';
Expand All @@ -51,7 +53,9 @@ void print_value(const nostd::span<T> &vec, std::ostream &sout)
{
sout << v;
if (i != sz)
{
sout << ',';
}
i++;
};
sout << ']';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class OStreamLogRecordExporter final : public opentelemetry::sdk::logs::LogRecor
bool isShutdown() const noexcept;
void printAttributes(
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> &map,
const std::string prefix = "\n\t");
const std::string &prefix = "\n\t");
void printAttributes(
const std::unordered_map<std::string, opentelemetry::common::AttributeValue> &map,
const std::string prefix = "\n\t");
const std::string &prefix = "\n\t");
};
} // namespace logs
} // namespace exporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class OStreamMetricExporter final : public opentelemetry::sdk::metrics::PushMetr
void printPointData(const opentelemetry::sdk::metrics::PointType &point_data);
void printPointAttributes(const opentelemetry::sdk::metrics::PointAttributes &point_attributes);
void printAttributes(const std::map<std::string, sdk::common::OwnedAttributeValue> &map,
const std::string prefix);
const std::string &prefix);
void printResources(const opentelemetry::sdk::resource::Resource &resources);
};
} // namespace metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter
// various print helpers
void printAttributes(
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> &map,
const std::string prefix = "\n\t");
const std::string &prefix = "\n\t");

void printEvents(const std::vector<opentelemetry::sdk::trace::SpanDataEvent> &events);

Expand Down
10 changes: 5 additions & 5 deletions exporters/ostream/src/log_record_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export(

// Convert trace, spanid, traceflags into exportable representation
constexpr int trace_id_len = 32;
constexpr int span_id__len = 16;
constexpr int span_id_len = 16;
constexpr int trace_flags_len = 2;

char trace_id[trace_id_len] = {0};
char span_id[span_id__len] = {0};
char span_id[span_id_len] = {0};
char trace_flags[trace_flags_len] = {0};

log_record->GetTraceId().ToLowerBase16(trace_id);
Expand Down Expand Up @@ -120,7 +120,7 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export(
<< " event_id : " << event_id << "\n"
<< " event_name : " << log_record->GetEventName() << "\n"
<< " trace_id : " << std::string(trace_id, trace_id_len) << "\n"
<< " span_id : " << std::string(span_id, span_id__len) << "\n"
<< " span_id : " << std::string(span_id, span_id_len) << "\n"
<< " trace_flags : " << std::string(trace_flags, trace_flags_len) << "\n"
<< " scope : \n"
<< " name : " << log_record->GetInstrumentationScope().GetName() << "\n"
Expand Down Expand Up @@ -155,7 +155,7 @@ bool OStreamLogRecordExporter::isShutdown() const noexcept

void OStreamLogRecordExporter::printAttributes(
const std::unordered_map<std::string, sdkcommon::OwnedAttributeValue> &map,
const std::string prefix)
const std::string &prefix)
{
for (const auto &kv : map)
{
Expand All @@ -166,7 +166,7 @@ void OStreamLogRecordExporter::printAttributes(

void OStreamLogRecordExporter::printAttributes(
const std::unordered_map<std::string, opentelemetry::common::AttributeValue> &map,
const std::string prefix)
const std::string &prefix)
{
for (const auto &kv : map)
{
Expand Down
4 changes: 3 additions & 1 deletion exporters/ostream/src/metric_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sdk::common::ExportResult OStreamMetricExporter::Export(

void OStreamMetricExporter::printAttributes(
const std::map<std::string, sdk::common::OwnedAttributeValue> &map,
const std::string prefix)
const std::string &prefix)
{
for (const auto &kv : map)
{
Expand All @@ -135,7 +135,9 @@ void OStreamMetricExporter::printResources(const opentelemetry::sdk::resource::R
// order is guaranteed.
std::map<std::string, sdk::common::OwnedAttributeValue> attr_map;
for (auto &kv : attributes)
{
attr_map[kv.first] = std::move(kv.second);
}
printAttributes(attr_map, "\n\t");
}
}
Expand Down
8 changes: 4 additions & 4 deletions exporters/ostream/src/span_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ sdk::common::ExportResult OStreamSpanExporter::Export(
<< "\n duration : " << span->GetDuration().count()
<< "\n description : " << span->GetDescription()
<< "\n span kind : " << span->GetSpanKind()
<< "\n status : " << statusMap[int(span->GetStatus())]
<< "\n status : " << statusMap[static_cast<int>(span->GetStatus())]
<< "\n attributes : ";
printAttributes(span->GetAttributes());
sout_ << "\n events : ";
Expand Down Expand Up @@ -138,7 +138,7 @@ bool OStreamSpanExporter::isShutdown() const noexcept

void OStreamSpanExporter::printAttributes(
const std::unordered_map<std::string, sdkcommon::OwnedAttributeValue> &map,
const std::string prefix)
const std::string &prefix)
{
for (const auto &kv : map)
{
Expand Down Expand Up @@ -178,7 +178,7 @@ void OStreamSpanExporter::printLinks(const std::vector<trace_sdk::SpanDataLink>

void OStreamSpanExporter::printResources(const opentelemetry::sdk::resource::Resource &resources)
{
auto attributes = resources.GetAttributes();
const auto &attributes = resources.GetAttributes();
if (attributes.size())
{
printAttributes(attributes, "\n\t");
Expand All @@ -189,7 +189,7 @@ void OStreamSpanExporter::printInstrumentationScope(
const opentelemetry::sdk::instrumentationscope::InstrumentationScope &instrumentation_scope)
{
sout_ << instrumentation_scope.GetName();
auto version = instrumentation_scope.GetVersion();
const auto &version = instrumentation_scope.GetVersion();
if (version.size())
{
sout_ << "-" << version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ enum class PreferredAggregationTemporality
kLowMemory,
};

}
} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
4 changes: 2 additions & 2 deletions exporters/otlp/src/otlp_file_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ static std::size_t FormatPath(char *buff,
{ \
tm_obj_cache = GetLocalTime(); \
tm_obj_ptr = &tm_obj_cache; \
VAR = tm_obj_ptr->EXPRESS; \
(VAR) = tm_obj_ptr->EXPRESS; \
} \
else \
{ \
VAR = tm_obj_ptr->EXPRESS; \
(VAR) = tm_obj_ptr->EXPRESS; \
}

for (size_t i = 0; i < fmt.size() && ret < bufz && running; ++i)
Expand Down
7 changes: 6 additions & 1 deletion exporters/otlp/src/otlp_http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <mutex>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#ifdef GetMessage
Expand Down Expand Up @@ -685,12 +686,14 @@ OtlpHttpClient::~OtlpHttpClient()

// And then remove all session datas
while (cleanupGCSessions())
{
;
}
}

OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options,
std::shared_ptr<ext::http::client::HttpClient> http_client)
: is_shutdown_(false), options_(options), http_client_(http_client)
: is_shutdown_(false), options_(options), http_client_(std::move(http_client))
{
http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection);
}
Expand Down Expand Up @@ -831,7 +834,9 @@ bool OtlpHttpClient::Shutdown(std::chrono::microseconds timeout) noexcept
ForceFlush(timeout);

while (cleanupGCSessions())
{
;
}
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions exporters/otlp/src/otlp_metric_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ proto::metrics::v1::AggregationTemporality OtlpMetricUtils::GetProtoAggregationT
const opentelemetry::sdk::metrics::AggregationTemporality &aggregation_temporality) noexcept
{
if (aggregation_temporality == opentelemetry::sdk::metrics::AggregationTemporality::kCumulative)
{
return proto::metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE;
}
else if (aggregation_temporality == opentelemetry::sdk::metrics::AggregationTemporality::kDelta)
{
return proto::metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_DELTA;
}
else
{
return proto::metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_UNSPECIFIED;
}
}

metric_sdk::AggregationType OtlpMetricUtils::GetAggregationType(
Expand Down
Loading

0 comments on commit 43d52b2

Please sign in to comment.