https://signoz.io logo
Title
d

Devops Netapp

11/08/2022, 4:34 PM
Hello, I see that in the built in signoz logs there are trace_id and span_id fields but they are always empty. How can I enrich my log with the actual trace ids and connect log to trace and vice versa. Thanks!
p

Pranay

11/08/2022, 11:48 PM
@nitya-signoz may have more insights on this
n

nitya-signoz

11/09/2022, 4:25 AM
d

Devops Netapp

11/09/2022, 9:30 AM
Thanks @nitya-signoz. I’m still failing to understand who should be the initiator who should create these span_id and trace_parser fields where and at what point in flow.
n

nitya-signoz

11/09/2022, 9:40 AM
Okay so your application should create the spans and the logger has to take care that it is adding trace_id and span_id to the logs that are getting generated. If you can describe what stack you are using for your applications we might be able to help you.
d

Devops Netapp

11/09/2022, 9:49 AM
nestjs
n

nitya-signoz

11/09/2022, 9:51 AM
So I am assuming that you have already instrumented your application with opentelemtry and already getting traces and spans, but you need that in logs as well.
d

Devops Netapp

11/09/2022, 9:52 AM
Correct.
Just to ask another question closely related is there any way to view HTTP headers and body in UI trace view?
n

nitya-signoz

11/09/2022, 9:56 AM
I think you should be able to do that by adding your headers and body as events in the span. @Vishal Sharma correct me if I am wrong here.
v

Vishal Sharma

11/09/2022, 11:02 AM
You can add them as attributes/tags @Devops Netapp
d

Devops Netapp

11/10/2022, 9:31 AM
Thanks, this is very helpful.
n

nitya-signoz

11/11/2022, 7:40 AM
Hi @Devops Netapp you can create a logger like this https://github.com/pragmaticivan/nestjs-otel-prom-grafana-tempo/tree/main/src/logger to add traceId and spanId to your logs
We have updated our example as well you can check the changes here https://github.com/SigNoz/sample-NestJs-app/pull/5/files