Skip to content

Docs: Issue in Sampling example #7131

Closed

Description

@trevmt

What were you searching in the docs?

I was reviewing the documentation on sampling and testing out the example code. While running the example code I noticed that my sampling was not properly working. I eventually was able to get sampling to work by using sampling_rate instead of sample_rate when creating my logger. Additionally, in the source code sampling_rate is used and not sample_rate.

from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext

# Sample 10% of debug logs e.g. 0.1
logger = Logger(service="payment", sample_rate=0.1)


def lambda_handler(event: dict, context: LambdaContext):
    logger.debug("Verifying whether order_id is present")
    logger.info("Collecting payment")

    logger.refresh_sample_rate_calculation()

    return "hello world"

Is this related to an existing documentation section?

https://docs.powertools.aws.dev/lambda/python/latest/core/logger/#sampling-debug-logs

How can we improve?

See above

Got a suggestion in mind?

See above

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.

Activity

  1. added
    documentationImprovements or additions to documentation
    triagePending triage from maintainers
    on Aug 6, 2025
  2. boring-cyborg commented on Aug 6, 2025

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  3. leandrodamascena commented on Aug 6, 2025

    @leandrodamascena
    Contributor

    Hi @trevmt, thanks so much for opening this issue! You nailed it, our example is broken and using a wrong field name. Do you want to submit a PR to fix this? I'd love to have your contribution here. If you can't, no worries, I can fix it by end of this week.

  4. trevmt commented on Aug 7, 2025

    @trevmt
    ContributorAuthor

    Submitted a PR

  5. moved this from Backlog to Working on it in Powertools for AWS Lambda (Python)on Aug 7, 2025
  6. powertools-for-aws-oss-automation commented on Aug 7, 2025

    @powertools-for-aws-oss-automation

    Warning

    This issue is now closed. Please be mindful that future comments are hard for our team to see.
    If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions