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

Hide LogRecord attributes Implementation Details from exporters #1985

Merged

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Aug 5, 2024

Changes

Hide the implementation details of LogRecord attributes by:

  • Making the LogRecord attributes private to the opentelemetry-sdk crate.
  • Creating wrapper methods attributes_iter(), attributes_contains(), and attributes_len() to expose the functionality of these attributes to the exporter.

These changes will enable modifications to the internal implementation of these attributes without requiring any changes in the exporter code.

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 August 5, 2024 23:00
self.attributes.as_ref().map_or(0, |attrs| attrs.len())
}

/// Returns true if the `LogRecord` contains the specified attribute.
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not required to be public. If an exporter needs it, then can write a helper function to get this by using the above 2 methods.

Copy link
Member

Choose a reason for hiding this comment

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

I think we need to offer API to modify an existing entry, remove an existing entry too. These are critical to ensure we allow redaction, enrichment capabilities. Lets track it as separate issue for adding in the future.

Copy link

codecov bot commented Aug 5, 2024

Codecov Report

Attention: Patch coverage is 84.93151% with 22 lines in your changes missing coverage. Please review.

Project coverage is 74.9%. Comparing base (9f71652) to head (a85cbaf).

Files Patch % Lines
opentelemetry-stdout/src/logs/transform.rs 0.0% 14 Missing ⚠️
opentelemetry-proto/src/transform/logs.rs 61.5% 5 Missing ⚠️
opentelemetry-sdk/src/logs/record.rs 83.3% 3 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1985   +/-   ##
=====================================
  Coverage   74.8%   74.9%           
=====================================
  Files        122     122           
  Lines      20429   20473   +44     
=====================================
+ Hits       15299   15341   +42     
- Misses      5130    5132    +2     

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

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM.
Its probably better not to expose len() method initially, not a blocker if we expose it as well.

@cijothomas cijothomas merged commit 1719244 into open-telemetry:main Aug 6, 2024
25 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.

3 participants