Comments (4)
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.
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.
@emmettbutler any sense of whether this would work as a solution?
from dd-trace-py.
@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)
- The gRPC AIO server integration fails to set the gRPC status code for the span HOT 1
- Langchain patch assumes that you have langchain_community installed HOT 3
- Errors parsing DSNs when using both psycopg2 and psycopg
- Feature Request: [LLMObs] Support Automatic spans for `langchain_community`'s tools and retriever. HOT 3
- High CPU utilization causing kubernetes pod scaling with ddtrace > 2.3.0 HOT 2
- Cannot override the `service_name` for the `requests` integration HOT 1
- Boto3 Bedrock Client - Propogate Http x-datadog headers HOT 2
- Langchain v0.2+: ModuleNotFoundError: No module named 'langchain_community' HOT 2
- How to handle deprecation of `ddtrace.context.Context` when it is still present in public API? HOT 1
- Using ddtrace-run together with `gUnicorn` causes all `Spyne` SOAP endpoints to break. HOT 3
- Python 3.12 / ddtrace-run combined with psycopg3 AsyncConnectionPool leads to `TypeError: 'async for' requires an object with __aiter__ method, got Psycopg3TracedAsyncCursor` when consuming iterator HOT 1
- TypeError: unhashable type: 'dict' thrown from cache HOT 1
- TypeError: expected str, bytes or os.PathLike object, not Path HOT 1
- UnboundLocalError: cannot access local variable 'result' where it is not associated with a value HOT 1
- Add support for faststream HOT 1
- Type-checking rough-edges in LLM Observability HOT 3
- Add admission controller to documentation
- Connexion v3, Flask v3 integration with dd-trace fails: datadog context not present in ASGI request scope, trace middleware may be missing
- AttributeError: 'Path' object has no attribute 'parents' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dd-trace-py.