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

fix(sdk-logs): hide internal methods with internal shared state #3865

Merged
merged 8 commits into from
Sep 26, 2023

Conversation

legendecas
Copy link
Member

Which problem is this PR solving?

This change hides the internal methods with a LoggerProviderSharedState struct.

Short description of the changes

  • Removes the configuration on Logger instances as the spec explicitly states that "Loggers should not be responsible for configuration" (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#logger).
  • Removes the redundant MultiLogRecordProcessor with a single NoopLogRecordProcessor when no LogRecordProcessor is registered. This can be replaced by a single NoopLogrecordProcessor instead.
  • Fixes that MultiLogRecordProcessor didn't pass the second argument context to its processors' onEmit.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

This un-exposes the internal methods as public so it is a breaking change.

How Has This Been Tested?

  • Existing tests all passed with internal refactoring.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@legendecas legendecas requested a review from a team June 6, 2023 03:51
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #3865 (2b945ba) into main (f2fc0d8) will increase coverage by 0.29%.
The diff coverage is 100.00%.

❗ Current head 2b945ba differs from pull request most recent head 98da36a. Consider uploading reports for the commit 98da36a to get more accurate results

@@            Coverage Diff             @@
##             main    #3865      +/-   ##
==========================================
+ Coverage   92.30%   92.60%   +0.29%     
==========================================
  Files         328      295      -33     
  Lines        9385     8249    -1136     
  Branches     1993     1712     -281     
==========================================
- Hits         8663     7639    -1024     
+ Misses        722      610     -112     
Files Changed Coverage
experimental/packages/sdk-logs/src/LogRecord.ts 100.00%
experimental/packages/sdk-logs/src/Logger.ts 100.00%
...perimental/packages/sdk-logs/src/LoggerProvider.ts 100.00%
...l/packages/sdk-logs/src/MultiLogRecordProcessor.ts 100.00%
experimental/packages/sdk-logs/src/config.ts 100.00%
...ages/sdk-logs/src/export/NoopLogRecordProcessor.ts 100.00%
...sdk-logs/src/internal/LoggerProviderSharedState.ts 100.00%

@legendecas legendecas added the sdk:logs Issues and PRs related to the Logs SDK label Jun 8, 2023
@github-actions
Copy link

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Sep 18, 2023
experimental/CHANGELOG.md Outdated Show resolved Hide resolved
experimental/packages/sdk-logs/src/config.ts Outdated Show resolved Hide resolved
experimental/packages/sdk-logs/src/LoggerProvider.ts Outdated Show resolved Hide resolved
@@ -15,7 +15,6 @@
*/

Copy link
Member

Choose a reason for hiding this comment

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

We may want to remove LogRecord and Logger from the exports in this file. Logger should only be be aquired though LoggerProvider, and the only api.LogRecord should be passed to emit IIUC, so no need to let users create instances (now impossible anyway as we don't export LoggerProviderSharedState) 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for suggestion, removed!

@pichlermarc pichlermarc removed the stale label Sep 20, 2023
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. 🙂

@legendecas legendecas merged commit 2b9832e into open-telemetry:main Sep 26, 2023
17 checks passed
@legendecas legendecas deleted the logs/internal-state branch October 5, 2023 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk:logs Issues and PRs related to the Logs SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants