jaegertracing / jaeger-client-csharp

🛑 This library is DEPRECATED!
https://jaegertracing.io/
Apache License 2.0
302 stars 67 forks source link

how trace with log level like tracing only error #175

Closed EngRajabi closed 4 years ago

EngRajabi commented 4 years ago

how trace with log level like tracing only error. For example, if the level Error was set, only save the erroneous requests

Falco20019 commented 4 years ago

I don't really understand what you mean with "log level". The logs that are part of Span don't have a log level. Span itself also has no log level. A Span can have an error tag, which is for example set if an exception was thrown. Traces itself don't have a notation of log level neither.

There are multiple points where you can decide if a span get's sampled or not:

It is not possible to only store traces that might contain an error, as spans are reported early. So spans that are part of the trace up until the error would already be stored.

You have the option to filter the traces that are stored for ones that contain at least one span with error tagged.

As Traces are never explicitly finished (only Spans are), you have no way to find out if there won't be another Span added at any point containing an error. So there is AFAIK also no way how you could implement it in IReporter or ISender by using caches or anything as the Flushing would have to be guessed.

If it's just to avoid storing data for "good" requests, I fear that's not possible by design. As it's possible to add new Spans to a trace even after hours, there is no definitive end to a Trace that could be used to check if the trace was good or not. If you only want to trace the erroneous Span, writing an IReporter that checks the tags before calling the real reporter would be your best option. But this would only log the span, not the whole trace.

Feel free to add more information about your use case and we might be able to help you more on how to fulfill this need.

Falco20019 commented 4 years ago

@EngRajabi Were you able to solve your problem?

EngRajabi commented 4 years ago

No I just want the http != 200 requests to be tracked

Falco20019 commented 4 years ago

This should be hard to do apriori, since all Spans that are part of the trace are reported individually. Even before the HTTP Response is created. So you can only clean up after the complete trace is done. There is no notion about when the „complete trace“ is done as OpenTracing is not bound to HTTP or web itself. It would only be possible if you have just one single span for the whole handling without any children or follow-ups. Is this your use-case?

It seems that you are using OpenTracing.Contrib.Netcore. So maybe @cwe1ss knows more about if there are flags or specific ways to achieve this in that library (as this is a standalone project and not part of Jaeger).

Maybe also @yurishkuro has an idea on how to achieve this goal.

yurishkuro commented 4 years ago

In a distributed system, this is only possible with Tail Based Sampling (see https://www.jaegertracing.io/roadmap/)

yurishkuro commented 4 years ago

If you're tracing a single monolith service, than it's possible to sample on errors, Jaeger Go/Node clients partially support it (but not fully, spans that are already finished will still he lost).