Skip to content

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

Closed

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

Activity

  1. added
    bugSomething isn't working
    triagePending triage from maintainers
    on Nov 22, 2020
  2. heitorlessa commented on Nov 22, 2020

    @heitorlessa
    Contributor

    Hey Hiroya, thanks for opening up an issue.

    Sampling rate is part of the spec and as you noticed cannot be suppressed.

    For X-Ray, it is automatically suppressed if X-Ray isn't enabled for the function. When X-Ray is enabled, this log entry allows CloudWatch Service Lens to combine Logs, Metrics and Traces in one page.

    Aside for sampling rate, may I ask why you'd like to suppress X-Ray Trace ID field despite enabling it in the function?

    I believe the docs can be clearer on that, so I'll amend it later :)

    Thanks

  3. added
    documentationImprovements or additions to documentation
    and removed
    bugSomething isn't working
    triagePending triage from maintainers
    on Nov 22, 2020
  4. self-assigned this
    on Nov 22, 2020
  5. papi-tokei commented on Nov 23, 2020

    @papi-tokei
    Author

    Hello Heitor.
    Thanks for replying in detail.

    Sampling rate is part of the spec and as you noticed cannot be suppressed.
    For X-Ray, it is automatically suppressed if X-Ray isn't enabled for the function. When X-Ray is enabled, this log entry allows CloudWatch Service Lens to combine Logs, Metrics and Traces in one page.

    Well, I see.

    Aside for sampling rate, may I ask why you'd like to suppress X-Ray Trace ID field despite enabling it in the function?

    So far I've been using x-ray-ids in the cloudwatch log report to do surveys, etc., but I've never found it very inconvenient.
    So I wondered if it was not necessary to add x-ray-ids to all Logger logs.

  6. papi-tokei commented on Nov 23, 2020

    @papi-tokei
    Author

    Let the issue be resolved this time.
    It would be helpful if you could create a separate issue for the documentation modifications

  7. heitorlessa commented on Nov 24, 2020

    @heitorlessa
    Contributor

    Just created an issue to track doc updates for this - Thanks a lot for flagging it @papi-tokei, much appreciated.

  8. heitorlessa commented on Nov 27, 2020

    @heitorlessa
    Contributor

    @papi-tokei letting you know that this is now live in the docs :) We appreciate your feedback very much on helping us improve the docs

  9. papi-tokei commented on Nov 27, 2020

    @papi-tokei
    Author

    @heitorlessa
    Thank you for your kindness
    (^▽^)

  10. removed
    pending-releaseFix or implementation already in dev waiting to be released
    on Jul 2, 2021
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 documentationfeature-requestfeature request

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions