Skip to content
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

Ignore tracing for certain Urls /hostname #35

Closed
sudhirpandey opened this issue Aug 4, 2021 · 9 comments
Closed

Ignore tracing for certain Urls /hostname #35

sudhirpandey opened this issue Aug 4, 2021 · 9 comments
Labels
all_runtimes Changes that should be applied to all runtimes Proposed Community submited Tracer

Comments

@sudhirpandey
Copy link

Is your feature request related to a problem? Please describe.
We are using a capture lambda handler decorations, but unfortunately our lambda is making a large amount of api calls to ec2.amazon.com, which we dont want any trace(segements) for. Since a large amount of trace subsegment is generate due to this api call( that happens in loop), we run out of xray limit for a signel trace which is 500Kb .
https://docs.aws.amazon.com/general/latest/gr/xray.html#limits_xray.

Describe the solution you'd like
If we could avoid generating trace segements for a known URL /hostname as described here https://github.com/aws/aws-xray-sdk-python#ignoring-httplib-requests, while using tracer , we would be able to get our trace limit under the limit and still use tracer. Its possible for us to use xray sdk directly and start tracing only methods we wanted but, it would be very useful to have such ignore capability in tracer too.

@boring-cyborg
Copy link

boring-cyborg bot commented Aug 4, 2021

Thanks for opening your first issue here! We'll come back to you as soon as we can.

@heitorlessa
Copy link
Contributor

Hey @sudhirpandey thanks a lot for using Lambda Powertools and for this feature I didn't know ;-)

As this is part of X-Ray extensions, perhaps we could simply export them directly here, then you have full control to follow X-Ray docs as they suggest

https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/aws_lambda_powertools/tracing/extensions.py

If you'd like to take a stab at it, I'm happy to provide any guidance and write docs for it.

I'm working heavily on completing the new feature flags utility to launch either this Friday evening or Monday. If you can help with this feature I can make sure it's part of the next release already ;-), otherwise I can work on that later for 1.20.

Thank you!!

@heitorlessa
Copy link
Contributor

heitorlessa commented Aug 4, 2021

Edit: Scratch that, this helps with trace metadata size not amount of subsegments as you described. Added that to the list of papercuts we should fix for the next release!

Forgot to share that in the meantime you can disable Tracer auto-capturing your method's response: https://awslabs.github.io/aws-lambda-powertools-python/latest/core/tracer/#disabling-response-auto-capture

from aws_lambda_powertools import Tracer

@tracer.capture_method(capture_response=False)
def fetch_sensitive_information():
    return "sensitive_information"

@tracer.capture_lambda_handler(capture_response=False)
def handler(event, context):
    sensitive_information = fetch_sensitive_information()

@heitorlessa
Copy link
Contributor

Transferring to Roadmap to improve visibility of what's being worked on.

@heitorlessa heitorlessa transferred this issue from aws-powertools/powertools-lambda-python Aug 15, 2021
@heitorlessa heitorlessa added all_runtimes Changes that should be applied to all runtimes Tracer labels Aug 15, 2021
@michaelbrewer
Copy link
Contributor

michaelbrewer commented Dec 9, 2021

@heitorlessa - would the UX be something like this?

from aws_lambda_powertools import Tracer

tracer = Tracer()
tracer.ignore_endpoint(hostname="ec2.amazon.com")

def ec2_api_calls():
    return "suppress_api_responses"

@tracer.capture_lambda_handler
def handler(event, context):
    for x in long_list:
        ec2_api_calls()

alternatively your suggestion is also useful to suppress the responses:

from aws_lambda_powertools import Tracer

tracer = Tracer()

@tracer.capture_method(capture_response=False)
def ec2_api_calls():
    return "suppress_api_responses"

@tracer.capture_lambda_handler(capture_response=False)
def handler(event, context):
    for x in long_list:
        ec2_api_calls()

@heitorlessa
Copy link
Contributor

I think it needs something more explicit for naming, like

tracer.ignore_endpoints(hostnames=[...])

But to make it future proof, it'd be interesting to see how and whether OpenTelemetry has this capability too.

@michaelbrewer
Copy link
Contributor

@heitorlessa
Copy link
Contributor

this is now merged - it'll be available in the next release!

@heitorlessa heitorlessa added the Proposed Community submited label Dec 22, 2021
@heitorlessa
Copy link
Contributor

hey @sudhirpandey thanks a lot for the feature request, @michaelbrewer for the implementation - this is available in the 1.24 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
all_runtimes Changes that should be applied to all runtimes Proposed Community submited Tracer
Projects
None yet
Development

No branches or pull requests

3 participants