Skip to content

'sampling_rate' and 'xray_trace_id' cannot be suppressed #215

Closed
@papi-tokei

Description

@papi-tokei

Thanks for the useful tools.
I use aws-lambda-powertools-python in Lambda python 3.8.

for document

Logger allows you to either change the format or suppress the following keys altogether at the initialization: location, timestamp, level, xray_trace_id, and datefmt

but I can't suppress the 'sampling_rate' and 'xray_trace_id'
(Is it a specification that 'sampling_rate' cannot be suppressed?)

I want to suppress the 'sampling_rate' and 'xray_trace_id'.

Expected Behavior

logger = Logger(
    service="payment",
    level="INFO",
    sampling_rate=None,
    xray_trace_id=None,
    timestamp=None,
    location=None,
)

Expected output is below.

{"level": "INFO", "message": {"test": 123}, "service": "payment"}

Current Behavior

I write below code.

logger = Logger(
    service="payment",
    level="INFO",
    sampling_rate=None,
    xray_trace_id=None,
    timestamp=None,
    location=None,
)

The actual output is below.
(xray_trace_id is masked)

{"level": "INFO", "message": {"test": 123}, "service": "payment", "sampling_rate": 0.0, "xray_trace_id": "1-xxxxxxx"}

Steps to Reproduce (for bugs)

  1. I write code for Lambda function.
  2. I invoke Lambda function.
  3. Display the output.(but not the output I expected)

Environment

  • Powertools version used: 1.8.0
  • Packaging format (Layers, PyPi): Layers
  • AWS Lambda function runtime: Python 3.8
  • Debugging logs

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationfeature-requestfeature request

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions