-
Notifications
You must be signed in to change notification settings - Fork 95
No more ThreadLocals, delegate everything to 'palantir/tracing-java' #799
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
36e5dac
[WIP] delegate all tracing calls to `tracing-java`
qinfchen f321e2c
cleanup
qinfchen c78a24b
Use published versions of libraries
iamdanfox edfa0d6
Everything compiles
iamdanfox 6a8471a
Convert#span actually works now
iamdanfox 68d893a
Implement Convert#toRemotingTrace
iamdanfox 420c0e8
All converters propagate nulls
iamdanfox 6ec78ae
Tracer#subscribe returns a remoting span observer
iamdanfox d4dc7d6
Delete redundant fully-qualified names in TracersTest
iamdanfox 332bbe1
Move longToPaddedHex function out of Tracers
iamdanfox 9e6effd
Delete an asConjure method
iamdanfox 1beda24
@Ignore one TracerTest
iamdanfox 6a02d6f
Thanks checkstyle
iamdanfox f3724a3
Reduce visibility of Convert class
iamdanfox 9c45298
Fix one Convert method
iamdanfox 13fb17c
Remove mavenLocal()
iamdanfox 0a5b297
Move Utilities to test source set
iamdanfox 8a06a46
Better javadoc and warnings
iamdanfox bb252e2
Restore CloseableTracerTest
iamdanfox badb51c
Delete some unused fields and point to their new locations
iamdanfox b20a71e
rearrange method orders and remove broken javadoc links
qinfchen 1bd0d56
remove Tracers.TRACE_ID_KEY and use java-tracing TRACE_ID_KEY
qinfchen 0ac9f54
thanks checkstyle
qinfchen e9c0d1e
Revert "remove Tracers.TRACE_ID_KEY and use java-tracing TRACE_ID_KEY"
iamdanfox adf0f74
Don't make Trace public
iamdanfox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Everything compiles
- Loading branch information
commit edfa0d63364318defedbc5747c1dc2c2e44bbf9e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
tracing/src/main/java/com/palantir/remoting3/tracing/Convert.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * (c) Copyright 2018 Palantir Technologies Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.palantir.remoting3.tracing; | ||
|
|
||
| import com.palantir.remoting.api.tracing.OpenSpan; | ||
| import com.palantir.tracing.api.Span; | ||
| import com.palantir.tracing.api.SpanObserver; | ||
| import com.palantir.tracing.api.SpanType; | ||
|
|
||
| /** Utility functions to convert old remoting-api classes to the new tracing-java ones and vice-versa. */ | ||
| public final class Convert { | ||
|
|
||
| private Convert() {} | ||
|
|
||
| static SpanType spanType(com.palantir.remoting.api.tracing.SpanType old) { | ||
| switch (old) { | ||
| case SERVER_INCOMING: | ||
| return SpanType.SERVER_INCOMING; | ||
| case CLIENT_OUTGOING: | ||
| return SpanType.CLIENT_OUTGOING; | ||
| case LOCAL: | ||
| return SpanType.LOCAL; | ||
| } | ||
| throw new IllegalStateException("Unable to convert: " + old); | ||
| } | ||
|
|
||
| static SpanObserver spanObserver(com.palantir.remoting.api.tracing.SpanObserver old) { | ||
| return new SpanObserver() { | ||
| @Override | ||
| public void consume(Span span) { | ||
| old.consume(toRemotingSpan(span)); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| static com.palantir.remoting.api.tracing.Span toRemotingSpan(Span span) { | ||
| return com.palantir.remoting.api.tracing.Span.builder() | ||
| .traceId(span.getTraceId()) | ||
| .parentSpanId(span.getParentSpanId()) | ||
| .spanId(span.getSpanId()) | ||
| .type(toRemotingSpanType(span.type())) | ||
| .operation(span.getOperation()) | ||
| .startTimeMicroSeconds(span.getStartTimeMicroSeconds()) | ||
| .durationNanoSeconds(span.getDurationNanoSeconds()) | ||
| .build(); | ||
| } | ||
|
|
||
| static OpenSpan toRemotingOpenSpan(com.palantir.tracing.api.OpenSpan openSpan) { | ||
| return OpenSpan.builder() | ||
| .parentSpanId(openSpan.getParentSpanId()) | ||
| .spanId(openSpan.getSpanId()) | ||
| .type(toRemotingSpanType(openSpan.type())) | ||
| .operation(openSpan.getOperation()) | ||
| .startTimeMicroSeconds(openSpan.getStartTimeMicroSeconds()) | ||
| .startClockNanoSeconds(openSpan.getStartClockNanoSeconds()) | ||
| .build(); | ||
| } | ||
|
|
||
| static com.palantir.remoting.api.tracing.SpanType toRemotingSpanType(SpanType type) { | ||
| switch (type) { | ||
| case CLIENT_OUTGOING: | ||
| return com.palantir.remoting.api.tracing.SpanType.CLIENT_OUTGOING; | ||
| case SERVER_INCOMING: | ||
| return com.palantir.remoting.api.tracing.SpanType.SERVER_INCOMING; | ||
| case LOCAL: | ||
| return com.palantir.remoting.api.tracing.SpanType.LOCAL; | ||
| } | ||
|
|
||
| throw new UnsupportedOperationException("Unable to convert to Remoting SpanType"); | ||
| } | ||
|
|
||
| public static com.palantir.remoting.api.tracing.SpanObserver toRemotingSpanObserver(SpanObserver unsubscribe) { | ||
| return new com.palantir.remoting.api.tracing.SpanObserver() { | ||
| @Override | ||
| public void consume(com.palantir.remoting.api.tracing.Span span) { | ||
| unsubscribe.consume(Convert.span(span)); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public static Trace toRemotingTrace(com.palantir.tracing.Trace andClearTrace) { | ||
| // TODO | ||
| return null; | ||
| } | ||
|
|
||
| public static Span span(com.palantir.remoting.api.tracing.Span span) { | ||
| // TODO | ||
| return null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
does this need to become public?
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.
Without this being
public, one of the test utils fails to compile.I find an alternative that involved some objects and casting too!
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.
it is also kind of odd that we have a public static method that returns
TraceandTraceis private.https://github.com/palantir/http-remoting/pull/799/files#diff-7ee517b85058e51de91b9bf446ff7585L246
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.
@qinfchen I don't have the original context, but one possible justification could be that this Trace class is useful for testing but shouldn't be used by consumers??