Skip to content

[BUILD] Suppress deprecated warnings in generated semconv metric headers#4088

Merged
marcalff merged 5 commits into
open-telemetry:mainfrom
RaviTriv:ravtrive/fix-semconv-deprecation-warnings
May 23, 2026
Merged

[BUILD] Suppress deprecated warnings in generated semconv metric headers#4088
marcalff merged 5 commits into
open-telemetry:mainfrom
RaviTriv:ravtrive/fix-semconv-deprecation-warnings

Conversation

@RaviTriv
Copy link
Copy Markdown
Contributor

@RaviTriv RaviTriv commented May 18, 2026

Fixes #3986

Changes

Attempting fix for issue 3986, deprecation warnings reported from metrics_foo_library example.

When some of the semconv generated headers are included, deprecated warnings for functions are produced even if the function is not used. This occurs because the function uses deprecated variables in its body. That's triggers -Wdeprecated-declarations and since these helpers are static inline in a header, every file that includes the header gets the warning. This PR proposes adding new macros, OPENTELEMETRY_SUPPRESS_DEPRECATED_BEGIN and OPENTELEMETRY_SUPPRESS_DEPRECATED_END to manually wrap these deprecated variables in the generator.

Appreciate time and effort for review. Happy to discuss / update to a more approriate solution.

Thank you :)

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

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 18, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: RaviTriv / name: Ravi (1b6be97)

@RaviTriv RaviTriv changed the title Suppress deprecated warnings in generated semconv metric headers Fix: Suppress deprecated warnings in generated semconv metric headers May 18, 2026
@RaviTriv RaviTriv marked this pull request as ready for review May 20, 2026 21:38
@RaviTriv RaviTriv requested a review from a team as a code owner May 20, 2026 21:38
# define OPENTELEMETRY_SUPPRESS_DEPRECATED_END _Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
# define OPENTELEMETRY_SUPPRESS_DEPRECATED_BEGIN \
__pragma(warning(push)) __pragma(warning(disable : 4996))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Optional nit: if clang-format allows it, could we keep one pragma per macro line for readability in the GCC and MSVC branches, similar to the Clang branch? The current formatting is correct, but th push/disable sequence is a little harder to scan when it gets collapsed onto one line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look :)

Good idea, updated to make it a bit more readable. Had to wrap the block in clang-format off because the formatting rules collapse anything under the 100-col limit onto one line.

Can go back to previous formatting if we don't want to use clang-format off here.

Copy link
Copy Markdown
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM. Nice work.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.00%. Comparing base (678e011) to head (edb3e3e).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4088   +/-   ##
=======================================
  Coverage   82.00%   82.00%           
=======================================
  Files         385      385           
  Lines       16030    16030           
=======================================
  Hits        13143    13143           
  Misses       2887     2887           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
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.

LGTM.

Nicely done, this will suppress a lot of noise.

@marcalff marcalff changed the title Fix: Suppress deprecated warnings in generated semconv metric headers [BUILD] Suppress deprecated warnings in generated semconv metric headers May 23, 2026
@marcalff marcalff merged commit 72953ea into open-telemetry:main May 23, 2026
171 of 178 checks passed
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.

Deprecation warnings reported from metrics_foo_library example

4 participants