[PR #1] improving logging

This commit is contained in:
Guillaume Polaert 2017-05-02 17:25:09 +02:00
parent 6aa6ac32db
commit 7031ff1976
4 changed files with 38 additions and 22 deletions

View File

@ -97,7 +97,7 @@ public class DDSpan implements io.opentracing.Span {
* @see io.opentracing.Span#finish(long)
*/
public void finish(long stoptimeMicros) {
this.durationNano = TimeUnit.MICROSECONDS.toNanos(stoptimeMicros- this.startTimeMicro);
this.durationNano = TimeUnit.MICROSECONDS.toNanos(stoptimeMicros - this.startTimeMicro);
afterFinish();
}
@ -173,22 +173,6 @@ public class DDSpan implements io.opentracing.Span {
return this;
}
public Span log(Map<String, ?> map) {
return null;
}
public Span log(long l, Map<String, ?> map) {
return null;
}
public Span log(String s) {
return null;
}
public Span log(long l, String s) {
return null;
}
/* (non-Javadoc)
* @see io.opentracing.Span#context()
*/
@ -223,6 +207,38 @@ public class DDSpan implements io.opentracing.Span {
return this;
}
/* (non-Javadoc)
* @see io.opentracing.Span#log(java.lang.String, java.lang.Object)
*/
public Span log(Map<String, ?> map) {
logger.debug("`log` method is not implemented. Doing nothing");
return this;
}
/* (non-Javadoc)
* @see io.opentracing.Span#log(java.lang.String, java.lang.Object)
*/
public Span log(long l, Map<String, ?> map) {
logger.debug("`log` method is not implemented. Doing nothing");
return this;
}
/* (non-Javadoc)
* @see io.opentracing.Span#log(java.lang.String, java.lang.Object)
*/
public Span log(String s) {
logger.debug("`log` method is not implemented. Doing nothing");
return this;
}
/* (non-Javadoc)
* @see io.opentracing.Span#log(java.lang.String, java.lang.Object)
*/
public Span log(long l, String s) {
logger.debug("`log` method is not implemented. Doing nothing");
return this;
}
/* (non-Javadoc)
* @see io.opentracing.Span#log(java.lang.String, java.lang.Object)
*/

View File

@ -106,7 +106,7 @@ public class DDTracer implements io.opentracing.Tracer {
DDSpanContext context = buildSpanContext();
DDSpan span = new DDSpan(this.operationName, this.tags, this.timestamp, context);
logger.debug("Starting a new span. " + span.toString());
logger.debug("{} - Starting a new span.", span);
return span;
}
@ -224,7 +224,7 @@ public class DDTracer implements io.opentracing.Tracer {
DDTracer.this
);
logger.debug("Building a new span context. " + context.toString());
logger.debug("Building a new span context. {}", context);
return context;
}

View File

@ -36,14 +36,14 @@ public class RateSampler implements Sampler {
}
this.sampleRate = sampleRate;
logger.debug("Initializing the RateSampler, sampleRate=" + this.sampleRate * 100 + "%");
logger.debug("Initializing the RateSampler, sampleRate: {} %", this.sampleRate * 100);
}
@Override
public boolean sample(DDSpan span) {
boolean sample = Math.random() <= this.sampleRate;
logger.debug(span + " - Span is sampled: " + sample);
logger.debug("{} - Span is sampled: {}", span, sample);
return sample;
}

View File

@ -15,7 +15,7 @@ public class LoggingWritter implements Writer{
@Override
public void write(List<Span> trace) {
logger.info("write(trace): "+trace);
logger.info("write(trace): {}", trace);
}
@Override