aws-powertools/powertools-lambda-python

Docs: Issue in Sampling example

trevmt opened this issue · 4 comments

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.

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

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.

Submitted a PR

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.