Skip to content

Docs: Issue in Sampling example #7131

@trevmt

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.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions