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

feat(api-logs): Add delegating no-op logger provider #4861

Merged
merged 15 commits into from
Sep 9, 2024

Conversation

hectorhdzg
Copy link
Member

@hectorhdzg hectorhdzg commented Jul 11, 2024

Which problem is this PR solving?

Fixes #4399

Adding ProxyLoggerProvider and ProxyLogger

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

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

@hectorhdzg hectorhdzg requested a review from a team July 11, 2024 18:44
@hectorhdzg hectorhdzg changed the title feat(api): Add delegating no-op logger provider feat(api-logs): Add delegating no-op logger provider Jul 11, 2024
Copy link
Contributor

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

@maryliag
Copy link
Contributor

Hey Hector, I see that you marked this as "Breaking change", would you mind providing more info on that?

@hectorhdzg
Copy link
Member Author

@maryliag same as ProxyMeter Provider PR #4858 this is a breaking change because the behavior of logs.getLoggerProvider will return a ProxyLoggerProvider instead of the actual registered logger provider, same as current behavior for tracerProvider

Copy link
Member

@blumamir blumamir left a comment

Choose a reason for hiding this comment

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

LGTM 🥇 thank you for working on this

Added 2 nits about argument names, to make the code consistent with the trace equivalent.

experimental/packages/api-logs/src/ProxyLogger.ts Outdated Show resolved Hide resolved
experimental/packages/api-logs/src/ProxyLoggerProvider.ts Outdated Show resolved Hide resolved
Comment on lines 24 to 25
export * from './ProxyLogger';
export * from './ProxyLoggerProvider';
Copy link
Member

Choose a reason for hiding this comment

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

after #4880 landed, this should be changed to named exports

@@ -48,6 +51,7 @@ export class LogsAPI {
provider,
NOOP_LOGGER_PROVIDER
);
this._proxyLoggerProvider.setDelegate(provider);

return provider;
Copy link
Contributor

Choose a reason for hiding this comment

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

Aside: I was comparing this setGlobal... to the equivalent for the TracerProvider and noticed that the internal/global-utils.ts and global registration handling is very different in api-logs from what it is in the "api" package. Apparently the code here was copied from api-metrics when that was a separate package ... but before the api-metrics package's global-registration handling was changed to #3357

When the api-logs package is merged into the "api" package, it will have to adapt to this new global-utils handling. That could be done before or after this PR. Until then, the global registration handling is subtley different between them.

(api-events will want to change as well)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I was planning to take care of that with api-logs migration to api package PR but that one got complicated, I will take care of using same global utils in different PR.

@@ -7,6 +7,7 @@ All notable changes to experimental packages in this project will be documented

### :boom: Breaking Change

* feat(api-logs): Add delegating no-op logger provider [#4861](https://github.com/open-telemetry/opentelemetry-js/pull/4861) @hectorhdzg
Copy link
Contributor

Choose a reason for hiding this comment

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

[marylia]

Hey Hector, I see that you marked this as "Breaking change", would you mind providing more info on that?

[Hector]

this is a breaking change because the behavior of logs.getLoggerProvider will return a ProxyLoggerProvider instead of the actual registered logger provider, same as current behavior for tracerProvider

Is that really a breaking change? logs.getLoggerProvider returns an object of type interface LoggerProvider both before and after, so I wonder (and hope) this could be considered not a breaking change.

A breaking change isn't so big a deal for this package, because it is still 0.x. However, a breaking change for the delegating MeterProvider in #4858, which is part of the "api" package, would be a very big deal: there is a VERY strong disincentive to have a major version bump for the "api" package.

Copy link
Contributor

Choose a reason for hiding this comment

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

@hectorhdzg We discussed in the SIG today (I brought it up). We agreed that we do not need to consider this a breaking change, because the exported types for these APIs are interfaces.

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 @trentm would update changelog then

@hectorhdzg
Copy link
Member Author

@trentm any other feedback in this PR?, I believe this one is ready to be merged

Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

Just a nit on the changelog message positioning. Otherwise LGTM.

experimental/CHANGELOG.md Outdated Show resolved Hide resolved
@hectorhdzg hectorhdzg added this pull request to the merge queue Sep 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 9, 2024
@hectorhdzg hectorhdzg added this pull request to the merge queue Sep 9, 2024
Merged via the queue into open-telemetry:main with commit f7dc8ff Sep 9, 2024
19 checks passed
@hectorhdzg hectorhdzg deleted the hectorhdzg/dellogprov branch September 9, 2024 22:03
Zirak pushed a commit to Zirak/opentelemetry-js that referenced this pull request Sep 14, 2024
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.

Implement a delegating no-op LoggerProvider
5 participants