This repository has been archived by the owner on May 23, 2023. It is now read-only.
Add clarification for Span under multithreading scenarios. #120
Closed
carlosalberto
wants to merge
1
commit into
opentracing:master
from
carlosalberto:carlos/span_multithreading
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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,33 @@ | ||
# Multithreading Span usage. | ||
|
||
**Current State:** Draft | ||
**Author:** [carlosalberto](https://github.com/carlosalberto) | ||
|
||
In the OpenTracing specification, there is no mention of **Span** behavior under multithreaded applications, nor clarification of any thread-safety requirement. This proposal is thus intended to be explicit about this specific scenario. | ||
|
||
# Background | ||
|
||
Different tracing systems have historically taken different decisions regarding this, with many of them making **Spans** (and their operations) thread-safe. Yet, it has been shown lately that a few frameworks have decided to not make **Spans** thread-safe, and instead provide their own ways to handle this scenario. This could in the near future create confusion among both users and tracing authors, as well as incompatibilities among implementations. | ||
|
||
# Specification Changes | ||
|
||
The `Span` interface adds one or more paragraph detailing the expected behavior of the objects under multithreading scenarios, specially when a single operation may take place through different threads (maybe using a thread pool). `Span` objects should then either: | ||
|
||
* Being thread-safe in all its operations (logs, tags, baggage). | ||
* Guaranteed to work fine and correctly under the described scenarios. | ||
|
||
# Use Cases | ||
|
||
## Application using a thread pool | ||
|
||
Multithreaded applications using a thread pool, with the user creating a `Span` for a given operation, which would be executed as a series of callbacks, each one running on a different, unknown thread. | ||
|
||
For many frameworks, this could be approached with the `Span` being passed between the threads/callbacks during its execution, to add logs, set tags or modify its baggage. | ||
|
||
# Risk Assessment | ||
|
||
The following risks have been identified: | ||
|
||
* This change may affect tracing systems that have taken for granted that there is no need to provide **any** form of thread-safety, as they would need to update or change its own API or code. | ||
|
||
* The clarification may stay too vague or be insufficient in the long term, regarding the frameworks that decide to not provide thread-safety. Thus a proper, clear addition needs to happen for this case. |
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.
That will be a performance concern for span's OPs. Many existed APM/tracers expected span don't face multiple threads, that is also based on this.