-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to pass trace_id to pino transport #160
Comments
Hello @Dhruv-Garg79, are you using the pino instrumentation for tracing? Here is an example of how to use the transport with context propagation: https://github.com/Vunovati/pino-opentelemetry-transport/tree/main/examples/trace-context Do you have some different use case that prevents you from using pino instrumentation? If so, please describe. |
My use case is simple, I don't want to use async hooks, and that's why I am passing these values manually. I can pass it as attribute or anything else that might be required @Vunovati |
@Vunovati I have explained my use case. is it possible to tell any way around? I just want simply pass these values manually |
Hello, Can you explain what's the problem with async hooks? What is the current output of the logs in the collector? Can you add an example? Thanks |
Hey @Vunovati this is the sample I am getting. I have already added how I am sending logs in the main post. like this:
As, you can see the trace_id is coming empty, when I have already passed it. problem with async hooks is simple, they are big performance killer. up to 50% in many cases. |
Would it work for you to try passing We need all three to be there in order to add them to the context: |
yes, that will work, let me try that. can you tell what exactly is trace_flags? |
Yes, it is described here: https://www.w3.org/TR/trace-context/#trace-flags You can put '01' as a value which means sampled: The sampled flag can be used to ensure that information about requests that were marked for recording by the caller will also be recorded by SaaS service downstream so that the caller can troubleshoot the behavior of every recorded request. |
Hey I tried, passing same value for both span_id and trace_id and sent
I am getting the funcName value, but not the others related to trace_id and all |
@Dhruv-Garg79, can you try giving me the output of the We need to isolate and confirm that this is the issue with this transport and not with signoz. I haven't tried signoz yet. p.s. You are using the same value for trace_id and span_id. I don't think that's a good idea. If you are not using ready-made instrumentations, you should try to implement a similar mechanism manually. For each span within the same trace, you need to create a unique span_id. |
I am not able to see any file getting generated in this location
And in my terminal, I am getting these values
is there some other way to check what exactly is sent by Also I am using these env variables for sending logs
I am using After that, I use below code to create a logger per API request.
Now, in this, I am getting That's why I had to pass same One more thing, it works if I send |
I am unable to really understand what is going on with your code so can you please help me out? I see from your env vars that you are sending the traces to some external collector. We could debug much more easily if you sent those to a local collector like in all examples in this repo. In the examples, we are sending logs to a collector on localhost. I need you to do the same thing so that I can reproduce the potential issue. We need to eliminate the external factors here like your collector on http://123.123.123.123:4317 My suggestion. Remove the env vars OTEL_EXPORTER_OTLP_LOGS_ENDPOINT and OTEL_EXPORTER_OTLP_LOGS_PROTOCOL. This way the transport will use localhost and http as a default. Then clone this repo and run |
Here is a working example of what I think you want:
It will send the logs to the http collector locally and will log what it would be sending to stdout
Please also note that the values for span_id and the trace_id that we are sending are spec compliant. The trace_id is a 16 byte array, while the span_id is a 8-byte array. If you send just any string as those values, the traceId and spanId will not be displayed. The values need to be as per spec. What I can see in your comment above you were sending an 16 byte array as span_id, while it should've been 8 |
@Vunovati it worked, thanks for taking time to help me out with this. |
I am trying to associate trace with logs, but trace_id field is not getting sent to OTEL collector.
traceId
field, it was coming in attributestrace_id
, it is not coming anywhere in the JSON.version used - ^0.4.1
node version - v20.12.0
The text was updated successfully, but these errors were encountered: