Logging improvements + automated error flag assignation
This commit is contained in:
parent
33d001b722
commit
6735eaf32c
|
@ -91,9 +91,7 @@ public class DDSpan implements io.opentracing.Span {
|
||||||
|
|
||||||
// warn if one of the parent's children is not finished
|
// warn if one of the parent's children is not finished
|
||||||
if (this.isRootSpan()) {
|
if (this.isRootSpan()) {
|
||||||
logger.debug("{} - The current span is marked as a root span", this);
|
|
||||||
List<Span> spans = this.context.getTrace();
|
List<Span> spans = this.context.getTrace();
|
||||||
logger.debug("{} - Checking {} children attached to the current span", this, spans.size());
|
|
||||||
|
|
||||||
for (Span span : spans) {
|
for (Span span : spans) {
|
||||||
if (((DDSpan) span).getDurationNano() == 0L) {
|
if (((DDSpan) span).getDurationNano() == 0L) {
|
||||||
|
@ -101,7 +99,7 @@ public class DDSpan implements io.opentracing.Span {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.context.getTracer().write(this.context.getTrace());
|
this.context.getTracer().write(this.context.getTrace());
|
||||||
logger.debug("{} - Sending the trace to the writer", this);
|
logger.debug("{} - Write the trace", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.datadoghq.trace;
|
package com.datadoghq.trace;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.print.Book;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -11,6 +12,7 @@ import com.datadoghq.trace.integration.DDSpanContextDecorator;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import io.opentracing.Span;
|
import io.opentracing.Span;
|
||||||
|
import io.opentracing.tag.Tags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpanContext represents Span state that must propagate to descendant Spans and across process boundaries.
|
* SpanContext represents Span state that must propagate to descendant Spans and across process boundaries.
|
||||||
|
@ -39,7 +41,7 @@ public class DDSpanContext implements io.opentracing.SpanContext {
|
||||||
/**
|
/**
|
||||||
* True indicates that the span reports an error
|
* True indicates that the span reports an error
|
||||||
*/
|
*/
|
||||||
private final boolean errorFlag;
|
private boolean errorFlag;
|
||||||
/**
|
/**
|
||||||
* The type of the span. If null, the Datadog Agent will report as a custom
|
* The type of the span. If null, the Datadog Agent will report as a custom
|
||||||
*/
|
*/
|
||||||
|
@ -178,6 +180,10 @@ public class DDSpanContext implements io.opentracing.SpanContext {
|
||||||
for(DDSpanContextDecorator decorator:tracer.getSpanContextDecorators()){
|
for(DDSpanContextDecorator decorator:tracer.getSpanContextDecorators()){
|
||||||
decorator.afterSetTag(this, tag, value);
|
decorator.afterSetTag(this, tag, value);
|
||||||
}
|
}
|
||||||
|
//Error management
|
||||||
|
if(Tags.ERROR.getKey().equals(tag) && Boolean.TRUE.equals(value)){
|
||||||
|
this.errorFlag = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Map<String, Object> getTags() {
|
public synchronized Map<String, Object> getTags() {
|
||||||
|
@ -186,9 +192,7 @@ public class DDSpanContext implements io.opentracing.SpanContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Span [traceId=" + traceId
|
return "Span [ "+traceId+" ] [ "+spanId+" | "+parentId+" ] [ "+getServiceName()+" | "+getOperationName()+" | "+getResourceName()+" ]";
|
||||||
+ ", spanId=" + spanId
|
|
||||||
+ ", parentId=" + parentId + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOperationName(String operationName) {
|
public void setOperationName(String operationName) {
|
||||||
|
|
|
@ -310,7 +310,6 @@ public class DDTracer implements io.opentracing.Tracer {
|
||||||
DDTracer.this
|
DDTracer.this
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.debug("Building a new span context. {}", context);
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ public class DDAgentWriter implements Writer {
|
||||||
|
|
||||||
//The thread was interrupted, we break the LOOP
|
//The thread was interrupted, we break the LOOP
|
||||||
break;
|
break;
|
||||||
|
} catch(Throwable e){
|
||||||
|
logger.error("Unexpected error! Some traces may have been dropped.",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue