-
Notifications
You must be signed in to change notification settings - Fork 327
Get SpanData of spans #1007
Comments
For log correlation you only need the SpanContext which holds items like TraceID and SpanID which is sufficient for correlation purposes and also propagated in cases when a Trace is not sampled. Span.data does not hold any required information to allow for log correlation and is only available for Spans that are sampled. |
I think Parent Span ID is very useful for rebuilding structure of traces/spans from logs when traces are not sampled. Span Name further adds useful info to the rebuilded results. |
if log data is used to rebuild traces then why not sample the trace? |
@rghetia Because whether a trace will be sampled is determined at the time when the trace/span is created, but that's not where logging happens. When later the program decides to do some logging, there's no way to make sure this trace will be sampled and exported. |
My bad of pressing close button. |
unless log is created for every span rebuilding trace from log is not going to be useful. At that point it is as good as turning on always-sampling mode. Logging every span is probably more expensive then turning on sampling. |
Always-sampling would be a waste of resources apparently. But when error happens, it would be nice to recover/rebuild more information as much as possible. Of course we can't recover the whole trace/span structure, but still, things like span name can provide valuable info for diagnosing problems, since not all the people in a team are familiar with the source code. And, we are planning to relate span names to the metrics names, so we can process and diagnose problems automatically in the future. |
Any update on this? This would be really useful to have so that one could implement log correlation yourself. |
Use https://github.com/census-instrumentation/opencensus-go/blob/master/trace/trace.go to get the SpanContext then the Span/trace IDs. |
Oh look at how I missed that! Didn't see the function where you could get the SpanContext from the span. Thanks! |
how does it going? I need to get parent span id too. |
We want to implement log correlation for go(#950), so we need to access Span.data for parent span id and span name etc, and log them.
Is there a way to access Span.data? We can access it in Exporters, but only sampled trace/span can reach Exporter, while we want to log span info even if trace/span is NOT sampled.
Thanks!
The text was updated successfully, but these errors were encountered: