Skip to content

Commit

Permalink
Log at debug when completeSpan methods are used with no active trace (
Browse files Browse the repository at this point in the history
#1016)

Log at debug when `completeSpan` methods are used with no active trace
  • Loading branch information
carterkozak authored Mar 15, 2023
1 parent 3dacba3 commit ee89d8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1016.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Log at debug when `completeSpan` methods are used with no active trace
links:
- https://github.com/palantir/tracing-java/pull/1016
11 changes: 11 additions & 0 deletions tracing/src/main/java/com/palantir/tracing/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ public static <T> void fastCompleteSpan(TagTranslator<? super T> tag, T state) {
if (trace.isObservable()) {
completeSpanAndNotifyObservers(span, tag, state, trace.getTraceId());
}
} else if (log.isDebugEnabled()) {
log.debug(
"Attempted to complete spans when there is no active Trace. This may be the "
+ "result of calling completeSpan more times than startSpan",
new SafeRuntimeException("not a real exception"));
}
}

Expand Down Expand Up @@ -671,6 +676,12 @@ public static Optional<Span> completeSpan() {
public static Optional<Span> completeSpan(@Safe Map<String, String> metadata) {
Trace trace = currentTrace.get();
if (trace == null) {
if (log.isDebugEnabled()) {
log.debug(
"Attempted to complete spans when there is no active Trace. This may be the "
+ "result of calling completeSpan more times than startSpan",
new SafeRuntimeException("not a real exception"));
}
return Optional.empty();
}
Optional<Span> maybeSpan = popCurrentSpan(trace)
Expand Down

0 comments on commit ee89d8e

Please sign in to comment.