-
Notifications
You must be signed in to change notification settings - Fork 20
Common trace state for tracing #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks great, thanks for putting it together! I've noted a few nits, once those are cleaned up, this should be good to merge :-)
tracing/src/main/java/com/palantir/tracing/CommonTraceState.java
Outdated
Show resolved
Hide resolved
tracing/src/main/java/com/palantir/tracing/CommonTraceState.java
Outdated
Show resolved
Hide resolved
tracing/src/main/java/com/palantir/tracing/CommonTraceState.java
Outdated
Show resolved
Hide resolved
tracing/src/main/java/com/palantir/tracing/CommonTraceState.java
Outdated
Show resolved
Hide resolved
| .traceId(trace.getCommonTraceState().getTraceId()) | ||
| .requestId(trace.getCommonTraceState().getRequestId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably keep around the getTraceId() and getRequetId() methods on Trace for conveience/readability. Not sure it buys us anything to deprecate the method. JIT gives us a budget for bytecode that can be inlined and optimized, so smaller methods (reusing common accessors) are more likely to be optimized in hot paths.
| ? new SampledDetachedSpan(operation, type, traceId, requestId, parentSpanId) | ||
| : new UnsampledDetachedSpan(traceId, requestId, parentSpanId); | ||
| ? new SampledDetachedSpan(operation, type, CommonTraceState.of(traceId, requestId), parentSpanId) | ||
| : new UnsampledDetachedSpan(CommonTraceState.of(traceId, requestId), parentSpanId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Might as well extract state creation above, and pass the reference to either the sampled or unsampled implementation.
Co-authored-by: Carter Kozak <[email protected]>
Co-authored-by: Carter Kozak <[email protected]>
Co-authored-by: Carter Kozak <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
Before this PR
Based on comments from #782 I extracted a
CommonTraceStatewhich contains the requestId and traceId. I'm not sure about the following changes:getTraceIdandgetRequestIdbe removed completely?CommonTraceStateserializable introduced the nullable field for reqeustId and I'm not sure if the getter which wraps this nullable can be changed with something smarter.