Expose isSampled on TraceContext; fixes gh-1799

This commit is contained in:
Marcin Grzejszczak
2020-12-10 10:19:40 +01:00
parent 0c91065996
commit d547386cb5
4 changed files with 20 additions and 0 deletions

View File

@@ -45,4 +45,9 @@ public interface TraceContext {
*/
String spanId();
/**
* @return {@code true} when sampled
*/
boolean isSampled();
}

View File

@@ -41,4 +41,9 @@ class NoOpTraceContext implements TraceContext {
return "";
}
@Override
public boolean isSampled() {
return false;
}
}

View File

@@ -51,6 +51,11 @@ class BraveTraceContext implements TraceContext {
return this.traceContext.spanIdString();
}
@Override
public boolean isSampled() {
return this.traceContext.sampled();
}
@Override
public String toString() {
return this.traceContext != null ? this.traceContext.toString() : "null";

View File

@@ -99,6 +99,11 @@ class OtelTraceContext implements TraceContext {
return this.delegate.getSpanIdAsHexString();
}
@Override
public boolean isSampled() {
return this.delegate.isSampled();
}
@Override
public String toString() {
return this.delegate != null ? this.delegate.toString() : "null";