-
Notifications
You must be signed in to change notification settings - Fork 344
Correct way how to not report fast spans #363
Comments
I don't know how to do that (I hope someone else can answer how to not report fast spans). The Closing the scope and finishing the span are separate concerns. It is generally a bad idea to mix them. Probably what you want is to close the scope but not finish the span (don't know if this will accomplish your goal though) like so: final long startTime = System.nanoTime();
final Span span = tracer.buildSpan(operationName).start();
try (Scope scope = tracer.scopeManager().activate(span)) {
// ...
} finally {
long durationInMillis = (System.nanoTime() - startTime) / 1000000;
if (durationInMillis >= THE_THRESHOLD_IN_MILLIS) {
span.finish();
} else {
// I doubt whether this prevents a report of the span ...
}
} |
My issue is still unresolved. @sjoerdtalsma 's solution has two problems/questions to discuss:
|
I don't think most tracing systems will allow this since there is no way to know if a distributed request was made. My suggestion would be to look for a way to discard the span after it's finished. |
The semantic conventions define
If I read this correctly you could add I also have no clue which implementations actually make use of that. |
Jaeger clients will respect |
As a workaround, I am collecting all the operations under the trace by myself. My solution requires O(n) additional space and O(n) complexity to collect data and parse it in case we're reporting the trace, but it gives me much more flexibility. It still looks like there should be a more convenient solution to filter some traces when they're finishing to avoid redundant traffic and db memory consuming. Probably it can be my feature request. @yurishkuro , my request duplicates https://github.com/jaegertracing/jaeger/issuesd/1861 , right? |
Where do you do that? |
To clarify: I do not use the tracing library API until all the data is collected and the decision is made. |
How do you deal with the distributed nature of tracing? I mean your trace might span multiple services before it ends. |
Currently, I do not have the problem - the infrastructure of my application is made in such a way, that all long operations are reported(not in real-time, but it doesn't matter for my case) in one place so I can catch them there and do not deal with solving distributed services problem. |
Is the proposed way to handle this via sampling.priority tag? My use case is we have a library that wraps around JDBC calls to database. We are creating a span around the JDBC call. But when system is running normally these calls are fast enough and we don't need to see these spans in the trace. We want to see if we can enhance the code so it creates a span only if the time is above a threshold. As far as I can tell there is no API to abort/cancel a span. Setting sampling.priority would affect all subsequent spans and in this use case I just want this span not to be emitted. I am not sure if it's the right thing to do to constantly flip sampling.priority. |
Well.. I've been googling for a while now trying to figure this out. We have a similar use-case with JDBC. In our case, we want to write a |
I would like to trace slow operations only.
There is a manually chosen threshold to determine whether operation slow or not.
I haven't found any description about the correct way to implement it in your documentation, but what came to my mind is:
Is it the correct way to drop the spans? If not, what is the correct one?
The text was updated successfully, but these errors were encountered: