zio / zio-telemetry

ZIO-powered OpenTelemetry library
https://zio.dev/zio-telemetry
Apache License 2.0
113 stars 55 forks source link

Log a Throwable rather than a Cause in OpenTracing's logError #786

Closed ghostdogpr closed 11 months ago

ghostdogpr commented 11 months ago

Some tracer libraries such as dd-trace (Datadog) have special logic when the error type is a Throwable, but are not able to do anything with a Cause.

Before I would see this with no details about the error:

Screen Shot 2023-11-24 at 10 20 33 AM

After that change, I would get the error details with the full stack trace:

Screen Shot 2023-11-24 at 10 21 29 AM

The spec says "For languages that support such a thing (e.g., Java, Python), the actual Throwable/Exception/Error object instance itself." so I think it makes sense not just for Datadog.

Relevant logic in dd-trace: https://github.com/DataDog/dd-trace-java/blob/a760c687369c971fa38d95c103883ed672394e6c/dd-trace-ot/src/main/java/datadog/opentracing/DefaultLogHandler.java#L45

grouzen commented 11 months ago

Thanks for the contribution! It is definitely a reasonable change and I'm happy to merge it!

ghostdogpr commented 11 months ago

Thanks! Would it be possible to do a release in the near future? 🙏

grouzen commented 11 months ago

Sure, I'll cut the next release tomorrow.