Skip to content

Add an example for multiple callbacks for an active span.#1

Merged
malafeev merged 3 commits intoopentracing-contrib:masterfrom
carlosalberto:multiple_callbacks
Aug 15, 2017
Merged

Add an example for multiple callbacks for an active span.#1
malafeev merged 3 commits intoopentracing-contrib:masterfrom
carlosalberto:multiple_callbacks

Conversation

@carlosalberto
Copy link
Copy Markdown
Collaborator

Added an example to show how a master task can have a few subtasks, and needs to have its Span closed upon the last one completes.

Haven't been working on OT directly in Java, so let me know in case of any feedback ;)

executor.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
logger.info("Child thread with message '" + message + "' started");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logger.info("Child thread with message '{}' started", message);

}
}

logger.info("Child thread with message '" + message + "' finished");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logger.info("Child thread with message '{}' finished", message);

client.send("task1", span, 100);
client.send("task2", span, 200);
client.send("task3", span, 300);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if we change order 100, 200, 300 to 100, 300, 200 will it be OK?

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.

Yes, that's ok (just tested it). I was even going to make them sleep randomly, but I wanted the example to be clear about that (reversing their sleep time would still be fine as the user can still see such value).

@malafeev malafeev merged commit 697321c into opentracing-contrib:master Aug 15, 2017
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.

2 participants