Skip to content

Pull in existing code from talsma-ict.#1

Merged
sjoerdtalsma merged 52 commits intoopentracing-contrib:masterfrom
talsma-ict:master
Jan 19, 2017
Merged

Pull in existing code from talsma-ict.#1
sjoerdtalsma merged 52 commits intoopentracing-contrib:masterfrom
talsma-ict:master

Conversation

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator

The java-globaltracer library has been split up in separate packages for active span management and global tracer access.

This pull request is for the active span management package into an independent separate library.

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator Author

@adriancole @wu-sheng I can't select you as reviewers, but I know you have a strong opinion about this as well 😄

@codefromthecrypt
Copy link
Copy Markdown

first peek is deja-vu from java-globaltracer.. either that's good or not :) I will take a look at this tomorrow after feedback from the former is digested

Copy link
Copy Markdown

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

Similar to the other codebase I think this overshoots in complexity, which is particularly troubling as tests are absent. Please try to pare down to minimum features needed and don't add forward thinking extension points or expose anything public that isn't proven necessary by people besides yourself.

*
* @author Sjoerd Talsma
*/
public class CallableWithActiveSpan<T> implements Callable<T> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does this need to be a public type? similar for the Runnable variant

if (span == null) span = NoopSpan.INSTANCE;
return getInstance().setActiveSpan(span);
} catch (Exception activationException) {
LOGGER.log(Level.WARNING, "Could not activate {0}.", new Object[]{span, activationException});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

seems string cat is simpler here. there's questionable value in adding a period vs the cruft. ps did you mean to add the exception as a parameter?

/**
* Managed object to deactivate an activated {@link Span} with.
*/
public interface SpanDeactivator {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why the marker interface. what does one expect to do with it?

@codefromthecrypt
Copy link
Copy Markdown

the main thing I think you lose track of is that you are thinking somewhere possibly farther than others. It is possible that the end design will eventually become as complex, but since this is intended to be a shared project, I think it is better to focus code on only what's required and no more. Then, use things like the rule-of-three before making things public etc.

Especially when doing fancy code like the lock-free loops, you really must have these things tested as this is the sort of code that breaks and is hard to tell why. Tests are a great way to tell if code should be present or not. For example, if you feel strongly that some hook is necessary, a feature test can explain that better than anyone's conjecture of importance.

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator Author

sjoerdtalsma commented Jan 4, 2017

@bensigelman Should we rename the repo to java-spanmanager in line with the new concepts?

@codefromthecrypt
Copy link
Copy Markdown

just to set expectations, I'm not planning to do further reviews on this, as between the global tracer and here, I've spent dozens of hours which delayed very important work I'm behind on. I hope my help so far has been.. helpful.

Copy link
Copy Markdown

@bhs bhs left a comment

Choose a reason for hiding this comment

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

@sjoerdtalsma I want to make progress on this PR in the coming days if you have cycles for it.

FWIW, I would like OpenTracing APIs to change in 2017 in order to make things like this repo easier/better/cleaner. It's possible that something like this would actually get folded into OpenTracing proper, actually. I figured that getting into the weeds on this PR would be a good way to bring all of these issues to the fore.

I also wanted to mention an alternative: make a version number like 0.0.1, add a giant caveat to the top of the README, and just clean things up a little bit and merge something that's a working prototype more than a fully-debated PR. We would then look at how this works when integrated into real/mature repos and make changes as needed.

Thanks!

* <li>Consecutive <code>release()</code> calls for already-released spans will be ignored.</li>
* </ol>
*/
final class ThreadLocalSpanManager implements SpanManager {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you have any practical examples of possible non-TLS SpanManagers that would actually play nice with the static-ness of this API? (I.e., that could retrieve the active span without parameters and without using TLS) Or is the idea just that they'd use some other TLS, like MDC or similar?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good question. The idea is that people can keep using their own context propagation mechanism they may already have, as that has impact on the code.
For instance, I created a security context propagation for a client that transfers to new background threads. I can easily create a SpanManager adaptor using that same propagation tool to also propagate/piggyback the spans besides other contextual information.

The impact is on the code scheduling the new threads which needs to be decoupled from whatever context must be propagated.
Whatever works for somebody should be extendable to also propagate spans with, hence the SpanManager interface.

I agree there needs to be cleanup and clarification. What is now the ActiveSpanManager is merely a 'global' placeholder similar to the 'global' tracer.
Should it be named GlobalSpanManager again? similar to GlobalTracer??

The concurrent package is meant to provide an example for propagating spans accross threads, but by no means is anyone obliged to use it.
I personally prefer an existing context propagation solution to which the SpanManager is registered as callback.
I have this concept working in a library, but it is currently not documented.

The tracer package is meant to automatically activate / deactivate spans to be propagated when started / finished.
Again, this is not obligatory, but in my opinion a very useful tool to separate the tracing from the propagation.

Comment thread README.md Outdated

## Examples

_TODO create examples_
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is arguably the most important / first thing we should do (even if there's no impl to back things up). It'd be great to talk about how the calling code is going to look and just collectively imagine impls, at least as long as we are able to imagine the same things.

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator Author

@bensigelman Could you add me as a Collaborator to this repo?
Then I can enable Travis builds for it.

@sjoerdtalsma sjoerdtalsma mentioned this pull request Jan 13, 2017
@bhs
Copy link
Copy Markdown

bhs commented Jan 19, 2017

@sjoerdtalsma can you summarize where we are at with this PR? I see that you changed the README to reflect its early stage... are we just waiting for the release artifact machinery to stabilize?

Thanks!

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator Author

@bensigelman

  • travis needs to be enabled on this repository. I would have done it, but I don't think I'm a Collaborator on the repo (I could enable it on the globaltracer, not on this one).

    @bensigelman Could you add me as a Collaborator to this repo?
    Then I can enable Travis builds for it.

  • the repo needs to be renamed to java-spanmanager before we can finalize on the release packaging in bintray (Don't know if I can rename the repo with Collaborator rights, but otherwise, you could do it).

@bhs
Copy link
Copy Markdown

bhs commented Jan 19, 2017

@sjoerdtalsma I saw your previous note and gave you write access to the repo...

@bhs
Copy link
Copy Markdown

bhs commented Jan 19, 2017

... I bumped you up to Admin, that should hopefully be sufficient!

image

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator Author

sjoerdtalsma commented Jan 19, 2017

... I bumped you up to Admin, that should hopefully be sufficient!

That did it! I enabled travis for this repo, thanks!

@sjoerdtalsma
Copy link
Copy Markdown
Collaborator Author

The repository rename needs to happen before release, since all credentials are encrypted to a specific org/repo for travis.
I think then we're good to go. As I'm admin now, I guess I can do the rename too...
Okay with you @bensigelman ?

@sjoerdtalsma sjoerdtalsma merged commit 1ea488c into opentracing-contrib:master Jan 19, 2017
@bhs
Copy link
Copy Markdown

bhs commented Jan 20, 2017

thanks @sjoerdtalsma!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants