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(logger): reset log level after sampling refresh #2673

Merged
merged 2 commits into from
Jun 19, 2024
Merged

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Jun 19, 2024

Summary

Changes

Please provide a summary of what's being changed

This PR fixes a bug with the log sampling feature in Logger that was introduced in v2 and that caused log sampling to stay enabled within the same execution environment after the first time an invocation was sampled.

I fixed the bug by storing the initial log level in a private property within the logger instance and then using this initial log level to restore the log level whenever the sampling calculation is not sampled.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: #2668


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Jun 19, 2024
@dreamorosi dreamorosi requested review from a team as code owners June 19, 2024 09:02
@boring-cyborg boring-cyborg bot added logger This item relates to the Logger Utility tests PRs that add or change tests labels Jun 19, 2024
@pull-request-size pull-request-size bot added the size/S PR between 10-29 LOC label Jun 19, 2024
@github-actions github-actions bot added the bug Something isn't working label Jun 19, 2024
@dreamorosi
Copy link
Contributor Author

@dreamorosi dreamorosi linked an issue Jun 19, 2024 that may be closed by this pull request
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

suuuperb investigation of one those bugs that look obvious when we find the root cause, but difficult without customer feedback and/or maintainer having quality time to get a feature scrutinized and peer reviewed.

As we briefly discussed on a call, two things we need to keep in mind:

  1. This feature will be superseded by a proper well established solution -- buffering debug logs (have and eat the cake too)

  2. It looks like Logger for TS could beneift from a "Handler" responsibility to eventually keep the Logger interface cleaner

Copy link

@dreamorosi dreamorosi merged commit 618faec into main Jun 19, 2024
11 checks passed
@dreamorosi dreamorosi deleted the fix/log_sampling branch June 19, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logger This item relates to the Logger Utility size/S PR between 10-29 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: log sampling is not working in v2
2 participants