-
Notifications
You must be signed in to change notification settings - Fork 500
[BUILD] Remove duplicated deprecated warnings in logs headers #3592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUILD] Remove duplicated deprecated warnings in logs headers #3592
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes duplicated deprecated warnings in the logs headers by adding pragma directives to suppress deprecation warnings around code that uses deprecated APIs. The changes ensure that deprecation warnings are properly silenced during compilation across different compiler platforms (MSVC, GCC, and Clang).
- Adds compiler-specific pragma directives to suppress deprecation warnings
- Wraps usage of deprecated APIs with warning suppression blocks
- Ensures consistent warning suppression across MSVC, GCC, and Clang compilers
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
api/include/opentelemetry/logs/provider.h | Adds pragma directives around NoopEventLoggerProvider instantiation to suppress deprecation warnings |
api/include/opentelemetry/logs/noop.h | Adds pragma directives around NoopEventLoggerProvider constructor to suppress deprecation warnings |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
# pragma GCC diagnostic pop | ||
# elif defined(__clang__) || defined(__apple_build_version__) | ||
# pragma clang diagnostic pop | ||
# endif |
Copilot
AI
Aug 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pragma directive blocks are duplicated across multiple files. Consider creating a macro or header file to define OPENTELEMETRY_SUPPRESS_DEPRECATED_START and OPENTELEMETRY_SUPPRESS_DEPRECATED_END to reduce code duplication and improve maintainability.
# endif | |
OPENTELEMETRY_SUPPRESS_DEPRECATED_START | |
static nostd::shared_ptr<EventLoggerProvider> provider(new NoopEventLoggerProvider); | |
return provider; | |
OPENTELEMETRY_SUPPRESS_DEPRECATED_END |
Copilot uses AI. Check for mistakes.
# elif defined(__clang__) || defined(__apple_build_version__) | ||
# pragma clang diagnostic pop | ||
# endif | ||
|
Copilot
AI
Aug 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pragma directive blocks are duplicated across multiple files. Consider creating a macro or header file to define OPENTELEMETRY_SUPPRESS_DEPRECATED_START and OPENTELEMETRY_SUPPRESS_DEPRECATED_END to reduce code duplication and improve maintainability.
OPENTELEMETRY_SUPPRESS_DEPRECATED_START | |
NoopEventLoggerProvider() : event_logger_{nostd::shared_ptr<EventLogger>(new NoopEventLogger())} | |
{} | |
OPENTELEMETRY_SUPPRESS_DEPRECATED_END |
Copilot uses AI. Check for mistakes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3592 +/- ##
==========================================
+ Coverage 90.02% 90.03% +0.02%
==========================================
Files 220 220
Lines 7069 7069
==========================================
+ Hits 6363 6364 +1
+ Misses 706 705 -1
🚀 New features to boost your workflow:
|
@owent The same test of CI / Bazel on MacOS fails on my pull request too with the same log, sorry but I'm not able to understand why it fails, can you please tell the fix for it. Thanks ! |
Not for sure, but the bazel cache could be corrupted here. If so, a nit PR deleting the cache should fix it. I believe the PR needn't be merged, just run on the main build to clean the cache. Or else, provide a custom CI action (through workflow_dispatch) to let maintainers delete the cache manually on such errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix.
The only limitation with this change is that anyone using EventLogger won’t see a deprecation warning, so they may never realize it’s deprecated. That said, I think the current PR is still the best path forward. Splitting EventLogger into its own header could address this, but that would be an API-breaking change. |
In provider.h, warnings are silenced only in the implementation of GetEventProvider(), because it uses deprecated code, which was the reported issue. Not tested, but I think anyone calling GetEventProvider() will still see a deprecation warning, because warnings are raised when using a deprecated api, not just when declaring an api deprecated.. |
Seen in CI:
So, calling deprecated api |
[BUILD] Remove duplicated deprecated warnings in logs headers (open-telemetry#3592)
Fixes #3588
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes