Skip to content

[CODE HEALTH] Fix clang-tidy cppcoreguidelines-special-member-functions warnings in trace API#3934

Open
dbarker wants to merge 2 commits intoopen-telemetry:mainfrom
dbarker:fix_clang_tidy_trace_special_member_functions
Open

[CODE HEALTH] Fix clang-tidy cppcoreguidelines-special-member-functions warnings in trace API#3934
dbarker wants to merge 2 commits intoopen-telemetry:mainfrom
dbarker:fix_clang_tidy_trace_special_member_functions

Conversation

@dbarker
Copy link
Member

@dbarker dbarker commented Mar 14, 2026

Fixes cppcoreguidelines-special-member-functions warnings in opentelemetry/trace

Changes

Fixes the following warnings:

cppcoreguidelines-special-member-functions (5 warnings)

File Line Message
opentelemetry-cpp/api/include/opentelemetry/trace/default_span.h 21 class 'DefaultSpan' defines a copy constructor and a move constructor but does not define a destructor, a copy assignment operator or a move assignment operator
opentelemetry-cpp/api/include/opentelemetry/trace/span_context.h 24 class 'SpanContext' defines a copy constructor and a copy assignment operator but does not define a destructor, a move constructor or a move assignment operator
opentelemetry-cpp/api/include/opentelemetry/trace/span_context_kv_iterable.h 18 class 'SpanContextKeyValueIterable' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
opentelemetry-cpp/api/include/opentelemetry/trace/tracer.h 27 class 'Tracer' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
opentelemetry-cpp/api/include/opentelemetry/trace/tracer_provider.h 21 class 'TracerProvider' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@dbarker dbarker force-pushed the fix_clang_tidy_trace_special_member_functions branch from 9f55e0d to ed586ee Compare March 14, 2026 16:44
@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.06%. Comparing base (4307862) to head (21622f3).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3934      +/-   ##
==========================================
+ Coverage   90.06%   90.06%   +0.01%     
==========================================
  Files         226      226              
  Lines        7227     7229       +2     
==========================================
+ Hits         6508     6510       +2     
  Misses        719      719              
Files with missing lines Coverage Δ
api/include/opentelemetry/trace/default_span.h 18.75% <100.00%> (+5.42%) ⬆️
api/include/opentelemetry/trace/span_context.h 100.00% <ø> (ø)
...ude/opentelemetry/trace/span_context_kv_iterable.h 100.00% <100.00%> (ø)
api/include/opentelemetry/trace/tracer.h 100.00% <100.00%> (ø)
api/include/opentelemetry/trace/tracer_provider.h 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbarker dbarker marked this pull request as ready for review March 14, 2026 17:58
@dbarker dbarker requested a review from a team as a code owner March 14, 2026 17:58
DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.span_context_) {}

DefaultSpan &operator=(const DefaultSpan &spn)
{
Copy link
Member

@marcalff marcalff Mar 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, should the code test assignment of a DefaultSpan to itself ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I don't think we really need a self-assignment test here. DefaultSpan assignment only assigns SpanContext, and SpanContext is made of self-safe value members.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbarker

Thanks for the investigations.

Please add a self-assignment test then, for robustness, so we don't have to think about it again.

This code is not likely to be in any critical path anyway.

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants