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 9e36d31 commit 7aaca5a
Show file tree
Hide file tree
Showing 39 changed files with 101 additions and 84 deletions.
5 changes: 3 additions & 2 deletions api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <cstring>
#include <utility>
#include "opentelemetry/context/context_value.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
Expand Down Expand Up @@ -32,7 +33,7 @@ class Context

// Creates a context object from a key and value, this will
// hold a shared_ptr to the head of the DataList linked list
Context(nostd::string_view key, ContextValue value) noexcept
Context(nostd::string_view key, const ContextValue &value) noexcept
{
head_ = nostd::shared_ptr<DataList>{new DataList(key, value)};
}
Expand All @@ -58,7 +59,7 @@ class Context
// exisiting list to the end of the new list.
Context SetValue(nostd::string_view key, ContextValue value) noexcept
{
Context context = Context(key, value);
Context context = Context(key, std::move(value));
context.head_->next_ = head_;
return context;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <mutex>
#include <utility>

#include "opentelemetry/context/propagation/noop_propagator.h"

Expand Down Expand Up @@ -35,7 +36,7 @@ class OPENTELEMETRY_EXPORT GlobalTextMapPropagator
static void SetGlobalPropagator(nostd::shared_ptr<TextMapPropagator> prop) noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
GetPropagator() = prop;
GetPropagator() = std::move(prop);
}

private:
Expand Down
4 changes: 3 additions & 1 deletion api/include/opentelemetry/context/runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <utility>

#include "opentelemetry/common/macros.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/shared_ptr.h"
Expand Down Expand Up @@ -150,7 +152,7 @@ class OPENTELEMETRY_EXPORT RuntimeContext
*/
static void SetRuntimeContextStorage(nostd::shared_ptr<RuntimeContextStorage> storage) noexcept
{
GetStorage() = storage;
GetStorage() = std::move(storage);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions api/include/opentelemetry/logs/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <mutex>
#include <utility>

#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"
Expand Down Expand Up @@ -42,7 +43,7 @@ class OPENTELEMETRY_EXPORT Provider
static void SetLoggerProvider(nostd::shared_ptr<LoggerProvider> tp) noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
GetProvider() = tp;
GetProvider() = std::move(tp);
}

/**
Expand All @@ -63,7 +64,7 @@ class OPENTELEMETRY_EXPORT Provider
static void SetEventLoggerProvider(nostd::shared_ptr<EventLoggerProvider> tp) noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
GetEventProvider() = tp;
GetEventProvider() = std::move(tp);
}

private:
Expand Down
3 changes: 2 additions & 1 deletion api/include/opentelemetry/metrics/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <mutex>
#include <utility>

#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ class Provider
static void SetMeterProvider(nostd::shared_ptr<MeterProvider> tp) noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
GetProvider() = tp;
GetProvider() = std::move(tp);
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@
// types, etc..
#if defined(__clang__)
#define OTABSL_INTERNAL_EXTERN_DECL(type, name) \
extern const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t<type> name;
extern const ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t<type> (name);
#else // Otherwise, just define the macro to do nothing.
#define OTABSL_INTERNAL_EXTERN_DECL(type, name)
#endif // defined(__clang__)

// See above comment at top of file for details.
#define OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \
OTABSL_INTERNAL_EXTERN_DECL(type, name) \
inline constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t<type> name = init
inline constexpr ::absl::OTABSL_OPTION_INLINE_NAMESPACE_NAME::internal::identity_t<type> (name) = init

#else

Expand Down
3 changes: 2 additions & 1 deletion api/include/opentelemetry/plugin/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <memory>
#include <utility>

#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/plugin/detail/tracer_handle.h" // IWYU pragma: export
Expand All @@ -21,7 +22,7 @@ class Span final : public trace::Span
{
public:
Span(std::shared_ptr<trace::Tracer> &&tracer, nostd::shared_ptr<trace::Span> span) noexcept
: tracer_{std::move(tracer)}, span_{span}
: tracer_{std::move(tracer)}, span_{std::move(span)}
{}

// trace::Span
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/default_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DefaultSpan : public Span

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

DefaultSpan(SpanContext span_context) noexcept : span_context_(span_context) {}
DefaultSpan(const SpanContext &span_context) noexcept : span_context_(span_context) {}

// movable and copiable
DefaultSpan(DefaultSpan &&spn) noexcept : span_context_(spn.GetContext()) {}
Expand Down
3 changes: 2 additions & 1 deletion api/include/opentelemetry/trace/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <mutex>
#include <utility>

#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ class OPENTELEMETRY_EXPORT Provider
static void SetTracerProvider(nostd::shared_ptr<TracerProvider> tp) noexcept
{
std::lock_guard<common::SpinLockMutex> guard(GetLock());
GetProvider() = tp;
GetProvider() = std::move(tp);
}

private:
Expand Down
4 changes: 3 additions & 1 deletion api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <utility>

#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/trace_flags.h"
Expand Down Expand Up @@ -44,7 +46,7 @@ class SpanContext final
span_id_(span_id),
trace_flags_(trace_flags),
is_remote_(is_remote),
trace_state_(trace_state)
trace_state_(std::move(trace_state))
{}

SpanContext(const SpanContext &ctx) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline void take_span_context_kv(SpanContext, T &)
{}

inline void take_span_context_kv(
SpanContext,
const SpanContext &,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>)
{}

Expand Down Expand Up @@ -81,7 +81,7 @@ class SpanContextKeyValueIterableView final : public SpanContextKeyValueIterable
private:
const T *container_;

bool do_callback(SpanContext span_context,
bool do_callback(const SpanContext &span_context,
const common::KeyValueIterable &attributes,
nostd::function_ref<bool(SpanContext, const common::KeyValueIterable &)>
callback) const noexcept
Expand Down
2 changes: 1 addition & 1 deletion api/test/baggage/propagation/baggage_propagator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TEST(BaggagePropagatorTest, ExtractAndInjectBaggage)
{"invalid_header", ""}, // invalid header
{very_large_baggage_header, ""}}; // baggage header larger than allowed size.

for (auto baggage : baggages)
for (const auto &baggage : baggages)
{
BaggageCarrierTest carrier1;
carrier1.headers_[baggage::kBaggageHeader.data()] = baggage.first;
Expand Down
2 changes: 1 addition & 1 deletion api/test/common/kv_properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ TEST(EntryTest, KeyValueConstruction)
TEST(EntryTest, Copy)
{
KeyValueProperties::Entry e("test_key", "test_value");
KeyValueProperties::Entry copy(e);
const KeyValueProperties::Entry &copy(e);
EXPECT_EQ(copy.GetKey(), e.GetKey());
EXPECT_EQ(copy.GetValue(), e.GetValue());
}
Expand Down
6 changes: 3 additions & 3 deletions api/test/context/context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ TEST(ContextTest, ContextCopyOperator)
{"foo_key", static_cast<int64_t>(456)},
{"other_key", static_cast<int64_t>(789)}};

context::Context test_context = context::Context(test_map);
context::Context copied_context = test_context;
context::Context test_context = context::Context(test_map);
const context::Context &copied_context = test_context;

EXPECT_EQ(nostd::get<int64_t>(copied_context.GetValue("test_key")), 123);
EXPECT_EQ(nostd::get<int64_t>(copied_context.GetValue("foo_key")), 456);
Expand Down Expand Up @@ -135,7 +135,7 @@ TEST(ContextTest, ContextCopyCompare)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context context_test = context::Context(map_test);
context::Context copied_test = context_test;
const context::Context &copied_test = context_test;
EXPECT_TRUE(context_test == copied_test);
}

Expand Down
2 changes: 2 additions & 0 deletions api/test/context/runtime_context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder)
indices.push_back(3);

std::vector<context::Context> contexts;
contexts.reserve(indices.size());
for (auto i : indices)
{
contexts.push_back(context::Context("index", static_cast<int64_t>(i)));
Expand All @@ -122,6 +123,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder)
{
std::vector<nostd::unique_ptr<context::Token>> tokens;

tokens.reserve(contexts.size());
for (auto &c : contexts)
{
tokens.push_back(context::RuntimeContext::Attach(c));
Expand Down
5 changes: 3 additions & 2 deletions api/test/logs/logger_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Barrier
static void ThreadRoutine(Barrier &barrier,
benchmark::State &state,
int thread_id,
std::function<void()> func)
const std::function<void()> &func)
{
barrier.Wait();

Expand All @@ -87,14 +87,15 @@ static void ThreadRoutine(Barrier &barrier,
barrier.Wait();
}

void MultiThreadRunner(benchmark::State &state, std::function<void()> func)
void MultiThreadRunner(benchmark::State &state, const std::function<void()> &func)
{
int num_threads = std::thread::hardware_concurrency();

Barrier barrier(num_threads);

std::vector<std::thread> threads;

threads.reserve(num_threads);
for (int i = 0; i < num_threads; i++)
{
threads.emplace_back(ThreadRoutine, std::ref(barrier), std::ref(state), i, func);
Expand Down
2 changes: 1 addition & 1 deletion api/test/trace/trace_state_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const char *kLongString =

// -------------------------- TraceState class tests ---------------------------

std::string create_ts_return_header(std::string header)
std::string create_ts_return_header(const std::string &header)
{
auto ts = TraceState::FromHeader(header);
return ts->ToHeader();
Expand Down
4 changes: 2 additions & 2 deletions examples/http/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class HttpServer : public HTTP_SERVER_NS::HttpRequestCallback
std::atomic<bool> is_running_{false};

public:
HttpServer(std::string server_name = "test_server", uint16_t port = 8800) : port_(port)
HttpServer(const std::string &server_name = "test_server", uint16_t port = 8800) : port_(port)
{
server_.setServerName(server_name);
server_.setKeepalive(false);
}

void AddHandler(std::string path, HTTP_SERVER_NS::HttpRequestCallback *request_handler)
void AddHandler(const std::string &path, HTTP_SERVER_NS::HttpRequestCallback *request_handler)
{
server_.addHandler(path, *request_handler);
}
Expand Down
3 changes: 2 additions & 1 deletion examples/http/tracer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,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
4 changes: 2 additions & 2 deletions examples/logs_simple/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void InitTracer()
#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */

// Set the global trace provider
std::shared_ptr<trace_api::TracerProvider> api_provider = provider;
const std::shared_ptr<trace_api::TracerProvider> &api_provider = provider;
trace_api::Provider::SetTracerProvider(api_provider);
}

Expand All @@ -79,7 +79,7 @@ void InitLogger()
#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */

// Set the global logger provider
std::shared_ptr<logs_api::LoggerProvider> api_provider = provider;
const std::shared_ptr<logs_api::LoggerProvider> &api_provider = provider;
logs_api::Provider::SetLoggerProvider(api_provider);
}

Expand Down
18 changes: 9 additions & 9 deletions examples/multi_processor/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,29 @@ void dumpSpans(std::vector<std::unique_ptr<trace_sdk::SpanData>> &spans)
char span_buf[trace_api::SpanId::kSize * 2];
char trace_buf[trace_api::TraceId::kSize * 2];
char parent_span_buf[trace_api::SpanId::kSize * 2];
std::cout << "\nSpans from memory :" << std::endl;
std::cout << "\nSpans from memory :" << '\n';

for (auto &span : spans)
{
std::cout << "\n\tSpan: " << std::endl;
std::cout << "\t\tName: " << span->GetName() << std::endl;
std::cout << "\n\tSpan: " << '\n';
std::cout << "\t\tName: " << span->GetName() << '\n';
span->GetSpanId().ToLowerBase16(span_buf);
span->GetTraceId().ToLowerBase16(trace_buf);
span->GetParentSpanId().ToLowerBase16(parent_span_buf);
std::cout << "\t\tTraceId: " << std::string(trace_buf, sizeof(trace_buf)) << std::endl;
std::cout << "\t\tSpanId: " << std::string(span_buf, sizeof(span_buf)) << std::endl;
std::cout << "\t\tTraceId: " << std::string(trace_buf, sizeof(trace_buf)) << '\n';
std::cout << "\t\tSpanId: " << std::string(span_buf, sizeof(span_buf)) << '\n';
std::cout << "\t\tParentSpanId: " << std::string(parent_span_buf, sizeof(parent_span_buf))
<< std::endl;
<< '\n';

std::cout << "\t\tDescription: " << span->GetDescription() << std::endl;
std::cout << "\t\tDescription: " << span->GetDescription() << '\n';
std::cout << "\t\tSpan kind:"
<< static_cast<typename std::underlying_type<trace_api::SpanKind>::type>(
span->GetSpanKind())
<< std::endl;
<< '\n';
std::cout << "\t\tSpan Status: "
<< static_cast<typename std::underlying_type<trace_api::StatusCode>::type>(
span->GetStatus())
<< std::endl;
<< '\n';
}
}
} // namespace
Expand Down
1 change: 1 addition & 0 deletions examples/multithreaded/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void run_threads()
auto thread_span = get_tracer()->StartSpan(__func__);

std::vector<std::thread> threads;
threads.reserve(5);
for (int thread_num = 0; thread_num < 5; ++thread_num)
{
// This shows how one can effectively use Scope objects to correctly
Expand Down
4 changes: 2 additions & 2 deletions examples/otlp/http_log_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void InitTracer()
trace_opts.url = opentelemetry::exporter::otlp::GetOtlpDefaultHttpTracesEndpoint();
}
}
std::cout << "Using " << trace_opts.url << " to export trace spans." << std::endl;
std::cout << "Using " << trace_opts.url << " to export trace spans." << '\n';

// Create OTLP exporter instance
auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts);
Expand Down Expand Up @@ -100,7 +100,7 @@ std::shared_ptr<opentelemetry::sdk::logs::LoggerProvider> logger_provider;

void InitLogger()
{
std::cout << "Using " << logger_opts.url << " to export log records." << std::endl;
std::cout << "Using " << logger_opts.url << " to export log records." << '\n';
logger_opts.console_debug = true;
// Create OTLP exporter instance
auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts);
Expand Down
Loading

0 comments on commit 7aaca5a

Please sign in to comment.