Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves state conflict between client and local spans
Before, local spans used the same thread local as client ones. This meant a client span in the same trace would overwite a local span. Ex. [server -> local -> client] would truncate to [server -> client] This change adds state to ensure local spans aren't overwritten by client spans. This change does not introduce a state stack, eventhough local spans should be nestable. The reason is that Brave's model isn't currently designed for that and a nested model would significantly impact the api.
- Loading branch information
Adrian Cole
committed
Dec 9, 2015
1 parent
8e8830c
commit e2d6f02
Showing
14 changed files
with
371 additions
and
280 deletions.
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
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
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
35 changes: 35 additions & 0 deletions
35
brave-core/src/main/java/com/github/kristofa/brave/LocalSpanState.java
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
package com.github.kristofa.brave; | |||
|
|||
import com.github.kristofa.brave.internal.Nullable; | |||
import com.twitter.zipkin.gen.Span; | |||
|
|||
/** | |||
* Maintains state for a single local span. This means nesting is not supported. | |||
* | |||
* <p/>Local spans can be at the following locations in the span tree. | |||
* <ul> | |||
* <li>The root-span of a trace originated by Brave</li> | |||
* <li>A child of a server span originated by Brave</li> | |||
* </ul> | |||
*/ | |||
public interface LocalSpanState extends CommonSpanState { | |||
|
|||
/** | |||
* Gets the Span for the local request that was started as part of current request. | |||
* <p/> | |||
* Should be thread-aware to support multiple parallel requests. | |||
* | |||
* @return Local request span for current thread. | |||
*/ | |||
@Nullable | |||
Span getCurrentLocalSpan(); | |||
|
|||
/** | |||
* Sets current local span. | |||
* <p/> | |||
* Should be thread-aware to support multiple parallel requests. | |||
* | |||
* @param span Local span. | |||
*/ | |||
void setCurrentLocalSpan(Span span); | |||
} |
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
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
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
Oops, something went wrong.