dd-trace-js
dd-trace-js copied to clipboard
Trace missing error message and stack trace
I have a Node app that uses dd-trace for everything. Internally we use Pino to log (but it is wrapped inside our own custom library) json output. We also use custom Error types (basically we are extending the default Error object and we create others like APIError or something simmilar).
It works perfectly fine I can see traces and logs and errors and routes and everything.
The problem I am having is that every time I log an error when I open the trace in Datadog I can see the info and I can see the logs associated with it but under the errors tab, or even on the Info tab on the top it says Missing error message and stack trace
.
I initially thought that our custom Pino wrapper lib is doing something wrong and the output is not in the format it needs to be. But reading the docs it says:
To enable Error Tracking, logs must include both of the following: either an error.type or error.stack field a status level of ERROR, CRITICAL, ALERT, or EMERGENCY
Looking at my logs, I can see in the sent json the correct level (this is clear from the fact that even the trace is logged as an error), the err key that has inside a message a stack and a type key also. So all of the expected info is there. I tried to log only a default Error object not an extended one, but its the same issue.
I checked everything again, we have a service name, a version, the spans are attached all is working because I can see data everywhere, the one thing that is missing is the stack in the trace.
If I open the logs from the trace then that log items have the correct format:
First it shows the error as bunyan error, but I use pino, so not sure how that is determined. Then all the info is there for a stack to be shown.
What am I missing, I can't figure it out? How does a json output need to look like for it to be shown in a trace? Can we use custom error types that extend the global JS Error object?