Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
self-cr
  • Loading branch information
carterkozak committed Jul 13, 2020
commit 446c8b2176b668b19f42fd518b5e6d431cf88b48
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.base.Strings;
import com.palantir.tracing.Observability;
import com.palantir.tracing.TraceMetadata;
import com.palantir.tracing.Tracer;
import com.palantir.tracing.Tracers;
import com.palantir.tracing.api.Span;
Expand Down Expand Up @@ -86,7 +87,9 @@ public void filter(ContainerRequestContext requestContext) throws IOException {
// Give asynchronous downstream handlers access to the trace id
requestContext.setProperty(TRACE_ID_PROPERTY_NAME, Tracer.getTraceId());
requestContext.setProperty(SAMPLED_PROPERTY_NAME, Tracer.isTraceObservable());
Tracer.getRequestId().ifPresent(requestId -> requestContext.setProperty(REQUEST_ID_PROPERTY_NAME, requestId));
Tracer.maybeGetTraceMetadata()
.flatMap(TraceMetadata::getRequestId)
.ifPresent(requestId -> requestContext.setProperty(REQUEST_ID_PROPERTY_NAME, requestId));
}

// Handles outgoing response
Expand Down
16 changes: 0 additions & 16 deletions tracing/src/main/java/com/palantir/tracing/DetachedSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,6 @@ static DetachedSpan start(
return Tracer.detachInternal(observability, traceId, parentSpanId, operation, type);
}

/**
* Marks the beginning of a span, which you can {@link #complete} on any other thread.
*
* @see DetachedSpan#start(String)
*/
@CheckReturnValue
static DetachedSpan start(
Observability observability,
String traceId,
Optional<String> requestId,
Optional<String> parentSpanId,
String operation,
SpanType type) {
return Tracer.detachInternal(observability, traceId, requestId, parentSpanId, operation, type);
}

/**
* Equivalent to {@link Tracer#startSpan(String, SpanType)}, but using this {@link DetachedSpan} as the parent
* instead of thread state.
Expand Down
6 changes: 6 additions & 0 deletions tracing/src/main/java/com/palantir/tracing/TraceMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public interface TraceMetadata {
/** Corresponds to {@link com.palantir.tracing.api.TraceHttpHeaders#TRACE_ID}. */
String getTraceId();

/**
* Returns the unique request identifier for this thread's trace.
* Corresponds to {@link com.palantir.tracing.Tracers#REQUEST_ID_KEY}.
*/
Optional<String> getRequestId();

/** Corresponds to {@link com.palantir.tracing.api.TraceHttpHeaders#SPAN_ID}. */
String getSpanId();

Expand Down
5 changes: 0 additions & 5 deletions tracing/src/main/java/com/palantir/tracing/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ static Optional<String> getRequestId(DetachedSpan detachedSpan) {
throw new SafeIllegalStateException("Unknown span type", SafeArg.of("detachedSpan", detachedSpan));
}

/** Returns the unique request identifier for this thread's trace. */
public static Optional<String> getRequestId() {
return checkNotNull(currentTrace.get(), "There is no trace").getRequestId();
}

static boolean isSampled(DetachedSpan detachedSpan) {
return detachedSpan instanceof SampledDetachedSpan;
}
Expand Down