Skip to content
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

Restrict LogRecord creation access outside opentelemetry_sdk crate. #2549

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Jan 24, 2025

Changes

The only way to create LogRecord outside the opentelemetry_sdk should be using Logger::create_log_record() method.
So,

  • Removed the Default implementation for LogRecord.
  • Added a crate-level constructor LogRecord::new.
  • Ensured LogRecord creation is restricted to Logger::create_log_record().
  • Updated tests to use LogRecord::new() or Logger::create_log_record() for record creation where applicable.

Note: It is not possible to make Default implementation private, so it was removed, and crate private constructor was added instead.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@lalitb lalitb requested a review from a team as a code owner January 24, 2025 05:53
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 86.27451% with 7 lines in your changes missing coverage. Please review.

Project coverage is 77.8%. Comparing base (6a8db83) to head (fbd12e5).

Files with missing lines Patch % Lines
opentelemetry-proto/src/transform/logs.rs 69.2% 4 Missing ⚠️
opentelemetry-sdk/src/logs/log_processor.rs 81.8% 2 Missing ⚠️
...y-sdk/src/logs/log_processor_with_async_runtime.rs 50.0% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2549   +/-   ##
=====================================
  Coverage   77.8%   77.8%           
=====================================
  Files        122     122           
  Lines      23030   23055   +25     
=====================================
+ Hits       17931   17952   +21     
- Misses      5099    5103    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant