Skip to content

[API] Fix Logger.Enabled() #4011

Merged
marcalff merged 40 commits intoopen-telemetry:mainfrom
proost:fix-respect-severity
May 7, 2026
Merged

[API] Fix Logger.Enabled() #4011
marcalff merged 40 commits intoopen-telemetry:mainfrom
proost:fix-respect-severity

Conversation

@proost
Copy link
Copy Markdown
Contributor

@proost proost commented Apr 18, 2026

Fixes #2667

Changes

fix to Logger.Enabled() use severity. so it changes to default behavior that enabled all logs to emit.

I fix it as minimal what original issue mentioned. But the issue reported two years ago, spec is changed.

do I need to follow "DEVELOPMENT" status spec?(https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#enabled)

I think adding features to "LoggerConfig" is correct to me(default behavior can be annoyed because all logs enabled). But this is my first time, so I don't know what is rule in this project.

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

@proost proost requested a review from a team as a code owner April 18, 2026 15:17
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 18, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 87.67123% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.09%. Comparing base (0d35a81) to head (be7dae0).

Files with missing lines Patch % Lines
api/include/opentelemetry/logs/logger.h 50.00% 6 Missing ⚠️
sdk/src/logs/logger.cc 91.67% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4011      +/-   ##
==========================================
+ Coverage   82.05%   82.09%   +0.04%     
==========================================
  Files         385      385              
  Lines       15909    15989      +80     
==========================================
+ Hits        13053    13124      +71     
- Misses       2856     2865       +9     
Files with missing lines Coverage Δ
sdk/include/opentelemetry/sdk/logs/logger_config.h 100.00% <100.00%> (ø)
sdk/include/opentelemetry/sdk/logs/processor.h 100.00% <100.00%> (ø)
sdk/src/logs/logger_config.cc 100.00% <100.00%> (ø)
sdk/src/logs/multi_log_record_processor.cc 93.25% <100.00%> (+0.82%) ⬆️
sdk/src/logs/multi_recordable.cc 90.55% <ø> (ø)
sdk/src/logs/logger.cc 89.42% <91.67%> (+1.42%) ⬆️
api/include/opentelemetry/logs/logger.h 68.86% <50.00%> (+3.99%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcalff
Copy link
Copy Markdown
Member

do I need to follow "DEVELOPMENT" status spec?(https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#enabled)

Yes.

The spec in "development" status means some changes are still possible before it reaches a stable state.

SDK like opentelemetry-cpp needs to implement these specs early (so, now), to discover possible issues with the spec, so it can be adjusted if needed before reaching the stable status.

Thanks for the contribution.

Comment thread api/include/opentelemetry/logs/logger.h Outdated
@proost
Copy link
Copy Markdown
Contributor Author

proost commented Apr 26, 2026

@marcalff @lalitb
I changed code to follow current api/sdk specs. If community is ok, can I divide fixing "EmitLogRecord" another PR? Because I think current change is meaningful and big enough.

// YAML-NODE: SeverityNumber
enum class SeverityNumber : std::uint8_t
{
unspecified = 0,
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.

current code default is trace. if this is intended, I will rollback to current code.

@proost proost requested a review from lalitb April 27, 2026 15:59
@dbarker
Copy link
Copy Markdown
Member

dbarker commented May 1, 2026

@proost Thanks for the PR! Both the LoggerConfig and YAML parsing/building features are very much needed :)

The PR has grown a bit beyond the initial issue. To facilitate review please break out the yaml config parsing to a separate PR as follow up to this one.

@proost proost force-pushed the fix-respect-severity branch from 03e3214 to 22c01e3 Compare May 1, 2026 11:46
Comment thread api/include/opentelemetry/logs/logger.h
@marcalff marcalff added the discuss To discuss in SIG meeting label May 2, 2026
@marcalff marcalff self-requested a review May 4, 2026 22:24
Comment thread api/include/opentelemetry/logs/logger.h Outdated
Comment thread api/include/opentelemetry/logs/logger.h Outdated
*/
bool IsEnabled() const noexcept;

#if OPENTELEMETRY_ABI_VERSION_NO >= 2
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.

Here, we are under sdk/include, not api/include.

It is ok to break the SDK ABI (with new data member), only the API ABI must be preserved at all costs.

Please remove OPENTELEMETRY_ABI_VERSION_NO >= 2, and have the minimum severity and trace based flag always defined in the SDK.

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.

Oh, I got it. 5aaab3d

@proost proost requested a review from marcalff May 5, 2026 14:24
@marcalff marcalff dismissed their stale review May 7, 2026 08:09

Comments addressed.

@lalitb
Copy link
Copy Markdown
Member

lalitb commented May 7, 2026

This looks good to me. Just to reiterate if my understanding is correct now:

  • v1: The API is safe. No API ABI break. The SDK binary layout changes, so old SDK-built binaries may need a rebuild, but normal source code should not need changes.
  • v2: The API intentionally includes the new Enabled() methods. The SDK also changes binary layout, but normal source code should still just recompile without code changes.

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, thanks for the fix.

@marcalff marcalff removed the discuss To discuss in SIG meeting label May 7, 2026
@marcalff marcalff changed the title fix: Logger.Enabled() [API] Fix Logger.Enabled() May 7, 2026
@marcalff marcalff merged commit 93fae28 into open-telemetry:main May 7, 2026
70 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.

[API] Support for Logger::Enabled() is incomplete

4 participants