openzipkin / zipkin-support

repository for support questions raised as issues
4 stars 2 forks source link

Question about the default logging handler in Brave #22

Closed codefromthecrypt closed 4 years ago

codefromthecrypt commented 4 years ago

@usulkies asked here https://github.com/openzipkin/brave/pull/1159#discussion_r446969960

I suggest that it should be a lower level of logging (not INFO) or (and maybe in addition) let the logger be logger of LogFinishedSpanHandler and not the main Tracer.class logger so we can configure this logger specifically. Currently the only way to reduce the noise is to change the Tracer logger to log only WARN and above.

codefromthecrypt commented 4 years ago

The log span handler is only used when nothing else is configured. It is here only to allow people playing around to know they haven't setup the tracer, or to see data without setup. If you configure anything, it should disable the logger (others would have noticed if it didn't)

Can you mention how it is that you are using Brave, and sampling (as opposed to setting Sampler.NEVER_SAMPLE) intentionally? Maybe paste your setup code?

usulkies commented 4 years ago

Hi @adriancole and thanks for your answer, In fact, I checked our configuration again. We're using Zipkin, and in some development environments, we're enabling the tracing but not collecting/sending it anywhere. It is done using the EmptyZipkinFactory instance, which is using a SpanHandler.NOOP handler. So I believe my soution is to wither disable the tracing on these envs, or to configure the brave.Tracing logger to WARN on these envs.

codefromthecrypt commented 4 years ago

@usulkies it is a strange case to load brave, but not actually use tracing. It is intentional that logging is default (so that people can stop accidental tracing by noticing, or they can just toy with it)

The options for your env depend on how you configure things. For example, if you configure sampling, easiest is to use Sampler.NEVER_SAMPLE or the equivalent. If you can reach the Tracing object, you can call Tracing.setNoop(true). You can also fake out the default span handler by adding an anonymous instance as SpanHandler.NOOP is intentionally dropped.

Ex if Spring, it would look like this:

  @Bean SpanHandler zipkinSpanHandler() {
    return new SpanHandler() { // intentionally drop everything
    };
  }

Finally, you can certainly disable that logger as log configuration typically doesn't require recompiling. There would be no reason to log if you are dropping all data anyway.

Hope this helps.