Skip to content

feat(api-logs)!: Marked private methods as "conventionally private". #5789

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

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

Conversation

svetlanabrennan
Copy link
Contributor

@svetlanabrennan svetlanabrennan commented Jul 9, 2025

Which problem is this PR solving?

Reviewed properties and methods that are suppose to be private and changed the delegate methods to private.

Fixes #5734

Short description of the changes

  • Removed getDelegate since it's not being used
  • Updated setDelegate to be private
  • Updated getDelegateLogger to be private
  • Updated tests

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Updated tests

Checklist:

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

Copy link

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.01%. Comparing base (cb42f7d) to head (d4381b9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5789   +/-   ##
=======================================
  Coverage   95.01%   95.01%           
=======================================
  Files         303      303           
  Lines        7946     7946           
  Branches     1607     1607           
=======================================
  Hits         7550     7550           
  Misses        396      396           
Files with missing lines Coverage Δ
experimental/packages/api-logs/src/ProxyLogger.ts 87.50% <100.00%> (ø)
...ental/packages/api-logs/src/ProxyLoggerProvider.ts 100.00% <100.00%> (ø)
experimental/packages/api-logs/src/api/logs.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@svetlanabrennan svetlanabrennan marked this pull request as ready for review July 11, 2025 15:25
@svetlanabrennan svetlanabrennan requested a review from a team as a code owner July 11, 2025 15:25
new ProxyLogger(this, name, version, options)
);
}

getDelegate(): LoggerProvider {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this one was added for testing purposes only, why removing the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I didn't know that we add methods for testing purposes only. I can make it private then and add it back to the tests.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the original purpose, it may be that this logic was duplicated from ProxyTracerProvider, but I can see is only used in the project for testing :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put this method back and added a note that it's used for tests only. And added an @internal annotation to it.

/**
* Set the delegate logger provider
*/
setDelegate(delegate: LoggerProvider) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not making these as private as well?

Copy link
Member

Choose a reason for hiding this comment

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

I can see the code is being used outside, and not really easy to refactor the code to support it, then the question is about package-private @pichlermarc mentioned in the bug, is it sufficient to add the underscore in the method names? this will not prevent people to use it

Copy link
Member

Choose a reason for hiding this comment

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

I know that what it means to have them as "conventially private" but not sure if this really useful, if we take this approach, we need to add typedoc @internal annotations to avoid having these methods exposed in docs
https://open-telemetry.github.io/opentelemetry-js/classes/_opentelemetry_api-logs.ProxyLoggerProvider.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with what the issue recommended we do but we can discuss alternatives if you like. I added the @internal annotation in the meantime

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 adding @internal is good enough for this here. The goal is to actually remove this whole class from exports eventually, since our end users are not expected to use it directly. This means that the types won't be available, see #5733.

@svetlanabrennan svetlanabrennan added this to the Logs API/SDK GA milestone Jul 15, 2025
@svetlanabrennan svetlanabrennan added the api:logs Issues and PRs related to the Logs API label Jul 15, 2025
* Used by tests only.
* @internal
*/
_getDelegate(): LoggerProvider {
Copy link
Member

Choose a reason for hiding this comment

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

you can also make it private and it will not be exposed in intellisense, but you can still access it with provider['_getDelegate'](). Not sure if we need to go that far though? @open-telemetry/javascript-maintainers what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dyladan Should I make this change or wait for a reply back from others?

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 would be addressed by #5733, if we don't export it it does not necessarily have to be private. (so good to leave it as-is for now) :)

/**
* Set the delegate logger provider
*/
setDelegate(delegate: LoggerProvider) {
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 adding @internal is good enough for this here. The goal is to actually remove this whole class from exports eventually, since our end users are not expected to use it directly. This means that the types won't be available, see #5733.

* Used by tests only.
* @internal
*/
_getDelegate(): LoggerProvider {
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 would be addressed by #5733, if we don't export it it does not necessarily have to be private. (so good to leave it as-is for now) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:logs Issues and PRs related to the Logs API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[api-logs] ensure all "private" properties/methods/functions are marked as "conventially private"
4 participants