Skip to content
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

[improvement] Add methods to set span operation when wrapping with a new trace #59

Merged
merged 4 commits into from
Feb 6, 2019

Conversation

pkoenig10
Copy link
Member

Before this PR

When calling any of the wrapWithNewTrace methods, the operation of the initial span would be set to "root". This makes it difficult to determine the origin of traces if wrapWithNewTrace is used in more than one place.

After this PR

Tracers now provides variants of the wrapWithNewTrace methods that allow callers to explicitly set the initial span operation.

Follow up to #49.

@pkoenig10 pkoenig10 requested a review from a team as a code owner January 29, 2019 19:29
@@ -237,7 +240,7 @@ public void testWrapCallableWithNewTrace_traceStateInsideCallableHasSpan() throw

OpenSpan span = spans.get(0);

assertThat(span.getOperation()).isEqualTo("root");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should retain test cases for the default as well

@carterkozak
Copy link
Contributor

It would be helpful to configure our executors to wrap operations based on the executor name.

This looks sane to me, thoughts @uschi2000?

* wrap a ScheduledExecutorService that has already been {@link #wrap(ExecutorService) wrapped}. If this is
* done, a new trace will be generated for each execution, effectively bypassing the intent of the previous
* wrapping.
*/
public static ExecutorService wrapWithNewTrace(ExecutorService executorService) {
public static ExecutorService wrapWithNewTrace(String operation, ExecutorService executorService) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will appear unredacted in Telemetry, so what do you think about another beloved @CompileTimeConstant to enforce that people don't accidentally exfil usernames or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it impossible to use thread pool name patterns as the operation when created a wrapped executor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the operation we'd use for thread pools, we'd need to use the DeferredTracer + overload Tracers.wrap(ExecutorService) which can be implemented in a separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this method when building scheduled executor services with new traces.

ExecutorService wrappedService =
Tracers.wrapWithNewTrace(Executors.newSingleThreadExecutor());
Tracers.wrapWithNewTrace(someOperartion, Executors.newSingleThreadExecutor());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someOperation?

@ellisjoe
Copy link
Contributor

ellisjoe commented Feb 6, 2019

Does this mean that all of these traces will no longer have any root span? Is that valid given the zipkin spec?

@carterkozak
Copy link
Contributor

They won't have a span named root, but they will still have a root span. Normally our root span is something along the lines of Jersey: GET /foo.

Related to this PR, do we think we should add a span for every runnable executed on an executor? We copy the trace and allow spans to be created, but we don't provide any data to track when the task began/completed, or on which executor.

@carterkozak
Copy link
Contributor

This looks reasonable to me 👍

@pkoenig10
Copy link
Member Author

I've opened #63

@bulldozer-bot bulldozer-bot bot merged commit 74f46d4 into palantir:develop Feb 6, 2019
@pkoenig10 pkoenig10 deleted the name branch February 8, 2019 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants