Code Monkey home page Code Monkey logo

Comments (10)

haotianw465 avatar haotianw465 commented on July 18, 2024 1

Yes you can definitely do that with a PR. That doesn't conflict with any of our internal work. Please stay tuned. Thanks.

from aws-xray-sdk-python.

thehesiod avatar thehesiod commented on July 18, 2024

if I have any free time I'll try working on a PR, however guidance and recommendations are welcome

from aws-xray-sdk-python.

haotianw465 avatar haotianw465 commented on July 18, 2024

We have some improvement plan on this matter internally but right now we cannot provide more details. I will leave this open to gather feedback from broader audience. But a PR is always welcome for a quick improvement.

Also keep in mind that it doesn't matter whether you disable tracing or not if the application is not the starting point on your microserivces, as any X-Ray integrated service (apps instrumented with X-Ray SDK, AWS Lambda etc) respects the sampling decision passed from upstream. So if you have a full call path all integrated you will just need to change your frontend sampling to rate=0 and fixed_target=0 to completely disable X-Ray tracing.

from aws-xray-sdk-python.

thehesiod avatar thehesiod commented on July 18, 2024

ah, perhaps if enabled=False it just does that?

from aws-xray-sdk-python.

jaysonsantos avatar jaysonsantos commented on July 18, 2024

Hey there, this feature is quite important especially if you are running tests as TargetPoller and RulePoller's threads will never die if there is no agent running.
The dirty fix i made was a fixture to kill those threads after pytest finishes testing.

@pytest.yield_fixture('session', autouse=True)
def fix_xray_threads():
    # TODO: This should be removed after https://github.com/aws/aws-xray-sdk-python/issues/26 is solved
    yield
    import ctypes
    import threading
    main_thread = threading.main_thread()
    for thread in threading.enumerate():
        if thread.daemon or thread == main_thread:
            continue

        ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(thread.ident), ctypes.py_object(SystemExit))

from aws-xray-sdk-python.

haotianw465 avatar haotianw465 commented on July 18, 2024

Thank you for your feedback. We will prioritize this work.

To better understand your use case, are you talking about testing your own application where it triggers the sampling code path of the SDK? For unit test you can turn off the sampling on SDK so it doesn't make outbound calls while still go through all the code path on segments generation so you can make sure the instrumentation is working. Having said that, an extra option to completely shut off the code path on SDK is definitely valuable.

from aws-xray-sdk-python.

thehesiod avatar thehesiod commented on July 18, 2024

i forget why we didn't merge my "enabled" param support.

from aws-xray-sdk-python.

jaysonsantos avatar jaysonsantos commented on July 18, 2024

Hi @haotianw465 our app initializes xray in our root module __init__.py which would be the first thing imported by the tests and it already starts the two threads. I saw the option to disable the sampling but that would still spin up the threads, no?

from aws-xray-sdk-python.

jaysonsantos avatar jaysonsantos commented on July 18, 2024

Never mind @haotianw465 checking the code again I saw that the threads are initialized when the first segment is sent. If I call configure before the first segment is sent they will never start.
Thank you!

from aws-xray-sdk-python.

chanchiem avatar chanchiem commented on July 18, 2024

PR merged into main branch

from aws-xray-sdk-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.