Skip to content

feat(logger): refresh sample rate calculation before each invocation #3672

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

Merged

Conversation

am29d
Copy link
Contributor

@am29d am29d commented Feb 27, 2025

…in logger context## Summary

Changes

Please provide a summary of what's being changed

This PR modifies the sampleRate behaviour for the logger and will now sample per invocation, instead of execution environment. When using injectLambdaContext either as decorator or as middleware, we now automatically refresh sample rate.

As discussed in #3278 we avoid duplicate sample decision during cold starts, as it might happen in the Logger constructor. To make this possible, I have exposed coldStart field from the Utility class.

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

Issue number: closes #3278


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.

@am29d am29d requested a review from dreamorosi February 27, 2025 13:36
@am29d am29d requested review from a team as code owners February 27, 2025 13:36
@boring-cyborg boring-cyborg bot added commons This item relates to the Commons Utility documentation Improvements or additions to documentation logger This item relates to the Logger Utility tests PRs that add or change tests labels Feb 27, 2025
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Feb 27, 2025
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Feb 27, 2025
@am29d am29d changed the title feat(logger): refresh sample rate calculation before each invocation … feat(logger): refresh sample rate calculation before each invocation Feb 27, 2025
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Left one comment about a docstring, other than that I have built and tested the package and it works, same for e2e tests which are green.

@am29d am29d requested a review from dreamorosi February 27, 2025 14:04
dreamorosi
dreamorosi previously approved these changes Feb 27, 2025
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@dreamorosi dreamorosi self-requested a review February 27, 2025 14:43
@dreamorosi dreamorosi dismissed their stale review February 27, 2025 14:43

Need to check another case

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Good to go

@am29d am29d merged commit 8c8d6b2 into main Feb 27, 2025
41 checks passed
@am29d am29d deleted the issue3278/Feature-request-Calculate-Log-Sampling-Per-Request branch February 27, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commons This item relates to the Commons Utility documentation Improvements or additions to documentation feature PRs that introduce new features or minor changes logger This item relates to the Logger Utility size/M PR between 30-99 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Calculate Log Sampling Per Request
2 participants