GithubHelp home page GithubHelp logo

Comments (4)

emmettbutler avatar emmettbutler commented on June 26, 2024

Hi @lminer, and thanks for getting in touch. I'll see if I can help.

The Span class includes a method set_exc_info, which you can call with an exception tuple to add that exception's details to the span as a tag.

I think this might be "manually adding it to the span" as you mentioned. Could you say more about how you'd like caught exceptions to behave with spans if add_exc_info isn't called?

Thanks again!

from dd-trace-py.

lminer avatar lminer commented on June 26, 2024

We were using sentry before and in sentry there was the ability to run sentry_sdk.capture_exception(err) on a caught exception. This would give you not only the stack trace, but also all the locals that were in memory at the time that the exception was thrown. There doesn't appear to be an equivalent in datadog. Am I correct that in order to get the same functionality, I would need to do something like this, where I store the locals in the exception at the time that it is raised?

def trace_exception(ex: MyExceptionWithLocals):
    span = tracer.current_span()
    if span is None:
        return
    span.set_traceback()
    span.set_tag("error", True)
    span.set_tag("error.type", type(ex).__name__)
    span.set_tag("error.message", str(ex))
    span.set_tag("error.stack", "".join(traceback.format_tb(ex.__traceback__)))
    locals_dict = getattr(ex, "locals", {})
    for var_name, var_value in locals_dict.items():
        span.set_tag(f"local.{var_name}", str(var_value))

from dd-trace-py.

lminer avatar lminer commented on June 26, 2024

@emmettbutler any sense of whether this would work as a solution?

from dd-trace-py.

emmettbutler avatar emmettbutler commented on June 26, 2024

@lminer yes, I believe that solution would work if your goal is to capture all of the locals. It's also interesting for us to consider adding locals capture to set_traceback.

from dd-trace-py.

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.