Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
matrix:
include:
- cmake_options: all-options-abiv1-preview
warning_limit: 330
warning_limit: 220
- cmake_options: all-options-abiv2-preview
warning_limit: 332
warning_limit: 222
env:
CC: /usr/bin/clang-18
CXX: /usr/bin/clang++-18
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ Increment the:
* [CODE HEALTH] Fix clang-tidy unnecessary value param warnings
[#3931](https://github.com/open-telemetry/opentelemetry-cpp/pull/3931)

* [CODE HEALTH] Fix clang-tidy cppcoreguidelines-init-variables warnings
[#3919](https://github.com/open-telemetry/opentelemetry-cpp/pull/3919)

* [CODE HEALTH] Fix clang-tidy warnings in nostd files
[#3924](https://github.com/open-telemetry/opentelemetry-cpp/pull/3924)

* [CODE HEALTH] Fix clang-tidy performance-for-range-copy warnings
[#3932](https://github.com/open-telemetry/opentelemetry-cpp/pull/3932)

* [CODE HEALTH] Fix clang-tidy bugprone warnings
[#3933](https://github.com/open-telemetry/opentelemetry-cpp/pull/3933)

* [CODE HEALTH] Fix clang-tidy special-member-functions warnings in trace
Comment thread
dbarker marked this conversation as resolved.
[#3668](https://github.com/open-telemetry/opentelemetry-cpp/pull/3668)

Important changes:

* [BUILD] Revisit EventLogger deprecation
Expand Down
27 changes: 25 additions & 2 deletions api/include/opentelemetry/trace/default_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace trace
class DefaultSpan : public Span
{
public:
~DefaultSpan() noexcept override = default;

// Returns an invalid span.
static DefaultSpan GetInvalid() { return DefaultSpan(SpanContext::GetInvalid()); }

Expand Down Expand Up @@ -66,8 +68,29 @@ class DefaultSpan : public Span
DefaultSpan(SpanContext span_context) noexcept : span_context_(std::move(span_context)) {}

// movable and copiable
DefaultSpan(DefaultSpan &&spn) noexcept : Span(), span_context_(spn.GetContext()) {}
DefaultSpan(const DefaultSpan &spn) noexcept : Span(), span_context_(spn.GetContext()) {}
DefaultSpan(const DefaultSpan &other) noexcept : span_context_(other.span_context_) {}

DefaultSpan &operator=(const DefaultSpan &other)
Comment thread
dbarker marked this conversation as resolved.
Outdated
{
Comment thread
dbarker marked this conversation as resolved.
if (this == &other)
{
return *this;
}
span_context_ = other.span_context_;
return *this;
}

DefaultSpan(DefaultSpan &&other) noexcept : span_context_(std::move(other.span_context_)) {}

DefaultSpan &operator=(DefaultSpan &&other) noexcept
{
if (this == &other)
{
return *this;
}
span_context_ = std::move(other.span_context_);
return *this;
}

private:
SpanContext span_context_;
Expand Down
4 changes: 0 additions & 4 deletions api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class SpanContext final
trace_state_(std::move(trace_state))
{}

SpanContext(const SpanContext &ctx) = default;

// @returns whether this context is valid
bool IsValid() const noexcept { return trace_id_.IsValid() && span_id_.IsValid(); }

Expand All @@ -79,8 +77,6 @@ class SpanContext final
trace_flags() == that.trace_flags();
}

SpanContext &operator=(const SpanContext &ctx) = default;

bool IsRemote() const noexcept { return is_remote_; }

static SpanContext GetInvalid() noexcept { return SpanContext(false, false); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ namespace trace
class SpanContextKeyValueIterable
{
public:
virtual ~SpanContextKeyValueIterable() = default;
SpanContextKeyValueIterable() = default;
virtual ~SpanContextKeyValueIterable() = default;
SpanContextKeyValueIterable(const SpanContextKeyValueIterable &) = default;
SpanContextKeyValueIterable &operator=(const SpanContextKeyValueIterable &) = default;
SpanContextKeyValueIterable(SpanContextKeyValueIterable &&) = default;
SpanContextKeyValueIterable &operator=(SpanContextKeyValueIterable &&) = default;

/**
* Iterate over SpanContext/key-value pairs
Expand Down
8 changes: 7 additions & 1 deletion api/include/opentelemetry/trace/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ namespace trace
class Tracer
{
public:
virtual ~Tracer() = default;
Tracer() = default;
virtual ~Tracer() = default;
Tracer(const Tracer &) = default;
Tracer &operator=(const Tracer &) = default;
Tracer(Tracer &&) = default;
Tracer &operator=(Tracer &&) = default;

/**
* Starts a span.
*
Expand Down
7 changes: 6 additions & 1 deletion api/include/opentelemetry/trace/tracer_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ class Tracer;
class OPENTELEMETRY_EXPORT TracerProvider
{
public:
virtual ~TracerProvider() = default;
TracerProvider() = default;
virtual ~TracerProvider() = default;
TracerProvider(const TracerProvider &) = default;
TracerProvider &operator=(const TracerProvider &) = default;
TracerProvider(TracerProvider &&) = default;
TracerProvider &operator=(TracerProvider &&) = default;

#if OPENTELEMETRY_ABI_VERSION_NO >= 2

Expand Down
46 changes: 46 additions & 0 deletions api/test/trace/default_span_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,50 @@ TEST(DefaultSpanTest, GetContext)
DefaultSpan sp = DefaultSpan(span_context);
EXPECT_EQ(span_context, sp.GetContext());
}

TEST(DefaultSpanTest, CopyConstructor)
{
SpanContext span_context = SpanContext(true, false);
DefaultSpan original(span_context);

DefaultSpan copied(original);

EXPECT_EQ(span_context, copied.GetContext());
}

TEST(DefaultSpanTest, MoveConstructor)
{
SpanContext span_context = SpanContext(true, false);
DefaultSpan original(span_context);

DefaultSpan moved(std::move(original));

EXPECT_EQ(span_context, moved.GetContext());
}

TEST(DefaultSpanTest, CopyAssignment)
{
SpanContext source_context = SpanContext(true, false);
DefaultSpan source(source_context);
DefaultSpan target(SpanContext(false, false));

target = source;
EXPECT_EQ(source_context, target.GetContext());

target = target;
EXPECT_EQ(source_context, target.GetContext());
}

TEST(DefaultSpanTest, MoveAssignment)
{
SpanContext source_context = SpanContext(true, false);
DefaultSpan source(source_context);
DefaultSpan target(SpanContext(false, false));

target = std::move(source);
EXPECT_EQ(source_context, target.GetContext());

target = std::move(target);
EXPECT_EQ(source_context, target.GetContext());
}
} // namespace
Loading