-
Notifications
You must be signed in to change notification settings - Fork 40
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
How can I integrate trace with log? #90
Comments
At the moment, the C++ tracer only exposes the opentracing interface, and not the inner workings and details of the tracer. Also the Log method that opentracing provides has not been implemented yet. For better understanding, which of these approaches were you interested in? |
@cgilmour If you look at detail view of a tracing on the DD, there is a Logs tab where it allows us to see tracing's related log entries. They are linked together via trace ID/span ID and I haven't seen how to do it with this library, no example provide on above link too. Thanks, |
Yup, understood. Right now, it's not possible. Generally, the way that works is the application produces logs that include the trace ID and span ID. I don't have a solution for this yet. |
If I understood correctly, this issue needs to be addressed first in opentracing-cpp to add support for retrieval of spanID/traceID in the opentracing::Span abstraction. |
2 virtual functions for returning TraceID and SpanID have now been added to the span interface in opentracing-cpp -> https://github.com/opentracing/opentracing-cpp/pull/114/files |
opentracing-cpp v1.6.0 has now been released: https://github.com/opentracing/opentracing-cpp/releases/tag/v1.6.0 |
Thanks @tomthomson! Just FYI I got an alert for the release and already prepared some code changes to use it. It might take a little while because for some downstream projects (eg: envoy, nginx-opentracing, etc) it'll need a similar update from other tracers they support before they can update to opentracing 1.6.0 |
Thanks for the quick adaption |
What about NGINX integration (via
I have tried Use case here is integrating nginx logs with APM traces. |
Is there an update on this? |
Is there any recent progress on this issue? We need it pretty badly. |
@juniorz @alnr @sergiodelacruz see below and let me know if that covers what you need for integrating nginx tracing and logs. For NGINX, the trace and span IDs are available via the special variables:
Although it says "parent" there, it's actually the current span ID. These values are taken from propagation headers for distributed tracing. When datadog tracing injects those headers, it uses There are extra steps for those values to be picked up by NGINX logs. In addition to configuring NGINX logs collection by the agent, a new pipeline needs to be created to understand a log format that includes trace and span IDs. This is easier after traces are already being collected and the NGINX integration has already been added. It should show up in the list of pipelines. First, clone the
Expand
Save the rule changes. Next, use
The exact settings for the
|
Thanks for your response, @cgilmour. I'm still trying to wrap my head around it. What does NGINX has to do with this? Our service is running in a Kubernetes pod and the DataDog agent picks up its stdout for the logs. As far as I can tell, there's no NGINX anywhere. We do have have the dd-opentracing-cpp library sending traces to the DataDog agents through HTTPS by setting up env vars like Can you clarify how your latest comment would be relevant to our use case? |
Sorry for the confusion @sergiodelacruz , other comments had referenced nginx which did have a workaround already available. In your case, is it a C++ service using opentracing-cpp and dd-opentracing-cpp directly, and you want your logs from that to connect with traces? It can be done with opentracing v1.5.1, but is a bit cumbersome. |
Thanks, @cgilmour for your prompt reply.
Yes, that is correct. I'm using your cgilmour/opentracing-1.6.0 branch that integrates with opentracing-cpp v1.6 but the If I'm understanding correctly from DataDog's documentation, all that is needed is a log entry in JSON with the following there: "dd": {
"trace_id": "<the trace ID>",
"span_id": "<the span ID>"
} which is kinda hard to provide in the client code since IIRC those IDs are private to the Tracer class. Am I missing something here? |
Great, I can prepare an end-to-end example for that. The opentracing In earlier opentracing versions, there were no methods to get trace and span IDs. They existed but hidden by the abstraction layers of opentracing. In v1.6.0 they are available, eg: auto& ctx = span->context();
auto trace_id = ctx.ToTraceID();
auto span_id = ctx.ToSpanID();
// do things with trace_id and span_id I'll make sure an end-to-end example covers both the usage and the format(s) you can use. |
Hi all, is there an example available for connecting logs to traces in C++? Thanks. |
Hi there! auto jobSpan = m_tracer->StartSpan(taskRegister.jobType);
jobSpan->Log({ {"error", "this is a test"} });
jobSpan->SetTag("tag test", 42);
jobSpan->Finish(); Trace is being sent to datadog but I can't see any log in the Thanks in advance 😃 |
Hi, IS the end-to-end example of combining logs with the traces using the trace and log ids there yet? Could you share the link in here? Thanks in advance |
Currently I see this in the documentation :)
https://docs.datadoghq.com/tracing/advanced/connect_logs_and_traces/?tab=c
The text was updated successfully, but these errors were encountered: