Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
papi-tokei opened this issue Nov 22, 2020 · 6 comments
Closed

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

papi-tokei opened this issue Nov 22, 2020 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation feature-request feature request

Comments

@papi-tokei
Copy link

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
@papi-tokei papi-tokei added bug Something isn't working triage Pending triage from maintainers labels Nov 22, 2020
@heitorlessa
Copy link
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

@heitorlessa heitorlessa added documentation Improvements or additions to documentation area/logger feature-request feature request and removed bug Something isn't working triage Pending triage from maintainers labels Nov 22, 2020
@heitorlessa heitorlessa self-assigned this Nov 22, 2020
@papi-tokei
Copy link
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.

@papi-tokei
Copy link
Author

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

@heitorlessa
Copy link
Contributor

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

@heitorlessa
Copy link
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

@papi-tokei
Copy link
Author

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

@heitorlessa heitorlessa added the pending-release Fix or implementation already in dev waiting to be released label Apr 19, 2021
@heitorlessa heitorlessa removed the pending-release Fix or implementation already in dev waiting to be released label Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature-request feature request
Projects
Development

No branches or pull requests

2 participants