-
Notifications
You must be signed in to change notification settings - Fork 935
Add the Context notion. #424
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
Merged
bogdandrutu
merged 85 commits into
open-telemetry:master
from
carlosalberto:context_aware
Feb 12, 2020
Merged
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
fb10415
Initial context integration.
carlosalberto 8451596
Update api-propagators.md
carlosalberto 5275f32
Remove the mention of binary propagators.
carlosalberto 7c01d61
Mention that the tracing's propagation must happen internally.
carlosalberto dd834a7
Make context -> Context.
carlosalberto 7f9c6b8
Rename api-context.md to context.md
carlosalberto f43b7db
Remove the notion of key.
carlosalberto 548e3d0
Add a note on Context being a SDK API.
carlosalberto 4942040
Note on the optional global operations.
carlosalberto dda30bb
Clean up pass.
carlosalberto 59cf5f3
Remove context-prop from the *tracing* index.
carlosalberto 278839b
Update specification/api-propagators.md
carlosalberto 71f51e5
Update specification/api-propagators.md
carlosalberto a3502c1
Update specification/api-propagators.md
carlosalberto 9be19e2
Update specification/context.md
carlosalberto ae1c052
First clean up pass over Context.
carlosalberto 0a4f08d
Update specification/api-propagators.md
carlosalberto a491a5b
Overview and layout updates.
carlosalberto a36759c
Make the MD linter happy (long lines though).
carlosalberto 58c6248
Update specification/context.md
carlosalberto ecdd80d
Update specification/context.md
carlosalberto 95f7bd2
Update specification/context.md
carlosalberto 656fe58
Update specification/context.md
carlosalberto 9e8a3bd
Use MUST/SHOULD for clarifying propagators expectations.
carlosalberto 086facb
Move the IsRemote deserialization note to the Extraction section.
carlosalberto 63c40a6
Improve wording for Context handling in Extraction.
carlosalberto 551a255
Clarify the protected global methods in context.md
carlosalberto bf398e1
Remove the extra explanation of Context in overview.md
carlosalberto 5a9a679
Improve the wording for set/remove values in context.md
carlosalberto 0f26bc7
Merge branch 'master' into context_aware
carlosalberto 6b962ba
Update specification/api-propagators.md
carlosalberto 60e22c0
Update specification/api-propagators.md
carlosalberto 505c2f7
Update specification/api-propagators.md
carlosalberto e06c9b0
Update specification/api-propagators.md
carlosalberto af9287a
Fix style?
carlosalberto d38b6fc
Clarify the Context usage in Extract.
carlosalberto 0e76724
Update specification/context.md
carlosalberto c697fef
Clarify IsRemote on Extract.
carlosalberto a4d588c
More style changes.
carlosalberto fdd79e1
OTel MUST provide Context impl if none exists.
carlosalberto 48d98c2
Update specification/context.md
carlosalberto 07398c1
Update specification/context.md
carlosalberto 051f36f
Update specification/context.md
carlosalberto e307486
Reword the optionality of Context in propagators.
carlosalberto 073a526
Clarify again the expected usage for implicit `Context`.
carlosalberto 9745124
Update specification/context.md
carlosalberto 4649574
Be more strict on the Context parameters.
carlosalberto c4b3423
Merge branch 'master' into context_aware
carlosalberto 0b5c1f1
Clarify that SDK/OTel instrumentation only SHOULD use global Context.
carlosalberto 3b58a29
Mention that Context will be used through concerns APIs.
carlosalberto 3fe6238
Update specification/api-propagators.md
carlosalberto 732f4e9
Update specification/api-propagators.md
carlosalberto 01e0925
We do not use the Required word anymore.
carlosalberto a3e5134
Do not require extract to set null/empty upon errors.
carlosalberto 13b1c02
Better wording for failed extraction values.
carlosalberto 75ae4bc
Update specification/context.md
carlosalberto 5f0b166
Clarify ONCE that Context is immutable.
carlosalberto 7393c0c
Use "derived" instead of "child" for Context-Context relationships.
carlosalberto 42adf76
Remove a misleading line.
carlosalberto eeb9afc
Mention tracing uses Context specifially.
carlosalberto 0794250
Update specification/api-propagators.md
carlosalberto 190da25
Update specification/api-propagators.md
carlosalberto c8bbf39
Merge branch 'master' into context_aware
carlosalberto f28568c
Clarify that Context keeps the untouched original values.
carlosalberto 74d1084
Merge branch 'master' into context_aware
carlosalberto dc92999
Clarify a new Context is created only for write operations.
carlosalberto 93a0cf7
Misc fixes.
carlosalberto e91a898
Set current Context should return a handle.
carlosalberto 2db3f2e
Note on global Context operations.
carlosalberto 4e02075
Remove the Remove operation on Context.
carlosalberto 8bc320e
Clarify the usage of cross-cutting concern APIs.
carlosalberto 96c26b9
Restore "Create a key" section.
carlosalberto 85cbb5b
Merge branch 'master' into context_aware
carlosalberto f1431c8
Minor fix to a previous commit.
carlosalberto 965f365
Add a detach operation.
carlosalberto a289dff
Update specification/api-propagators.md
carlosalberto 27e701a
Update specification/api-propagators.md
carlosalberto 980af1b
Update specification/context.md
carlosalberto c9c3cf1
Update specification/context.md
carlosalberto 31af4d9
Update specification/context.md
carlosalberto a3567d9
Update specification/context.md
carlosalberto cbd3b71
Update specification/context.md
carlosalberto 54735b8
Update specification/api-tracing.md
carlosalberto 349af35
Use value instead of object for Token.
carlosalberto 6ce4054
Merge branch 'master' into context_aware
bogdandrutu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -122,13 +122,15 @@ mechanism, for instance the `ServiceLoader` class in Java. | |
|
|
||
| The `Tracer` MUST provide functions to: | ||
|
|
||
| - Get the currently active `Span` | ||
| - Create a new `Span` | ||
|
|
||
| The `Tracer` SHOULD provide methods to: | ||
|
|
||
| - Get the currently active `Span` | ||
| - Make a given `Span` as active | ||
|
|
||
| The `Tracer` SHOULD allow end users to configure other tracing components that | ||
| control how `Span`s are passed across process boundaries, including the text | ||
| format `Propagator` used to serialize `Span`s created by the `Tracer`. | ||
| The `Tracer` MUST internally leverage the `Context` in order to get and set the | ||
| current `Span` state and how `Span`s are passed across process boundaries. | ||
|
|
||
| When getting the current span, the `Tracer` MUST return a placeholder `Span` | ||
| with an invalid `SpanContext` if there is no currently active `Span`. | ||
|
|
@@ -139,18 +141,13 @@ SHOULD create each new `Span` as a child of its active `Span` unless an | |
| explicit parent is provided or the option to create a span without a parent is | ||
| selected, or the current active `Span` is invalid. | ||
|
|
||
| The `Tracer` MUST provide a way to update its active `Span`, and MAY provide | ||
| The `Tracer` SHOULD provide a way to update its active `Span` and MAY provide | ||
| convenience functions to manage a `Span`'s lifetime and the scope in which a | ||
| `Span` is active. When an active `Span` is made inactive, the previously-active | ||
| `Span` SHOULD be made active. A `Span` maybe finished (i.e. have a non-null end | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/maybe/may be/ Is "finished" accurate? I wish we kept OT naming here, "span ended" sounds weird.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :) I will update this line in another (tiny) PR. |
||
| time) but stil active. A `Span` may be active on one thread after it has been | ||
| made inactive on another. | ||
|
|
||
| The implementation MUST provide a text `Propagator`, which the | ||
| `Tracer` SHOULD use by default if other propagators are not configured. SDKs | ||
| SHOULD use the W3C HTTP Trace Context as the default text format. For more | ||
| details, see [trace-context](https://github.com/w3c/trace-context). | ||
|
|
||
| ## SpanContext | ||
|
|
||
| A `SpanContext` represents the portion of a `Span` which must be serialized and | ||
|
|
||
This file contains hidden or 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,111 @@ | ||
| # Context | ||
|
|
||
| <details> | ||
| <summary> | ||
| Table of Contents | ||
| </summary> | ||
|
|
||
| - [Overview](#overview) | ||
| - [Create a key](#create-a-key) | ||
| - [Get value](#get-value) | ||
| - [Set value](#set-value) | ||
| - [Optional operations](#optional-operations) | ||
| - [Get current Context](#get-current-context) | ||
| - [Attach Context](#attach-context) | ||
| - [Detach Context](#detach-context) | ||
|
|
||
| </details> | ||
|
|
||
| ## Overview | ||
carlosalberto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| A `Context` is a propagation mechanism which carries execution-scoped values | ||
| across API boundaries and between logically associated execution units. | ||
| Cross-cutting concerns access their data in-process using the same shared | ||
| `Context` object. | ||
|
|
||
| A `Context` MUST be immutable, and its write operations MUST | ||
| result in the creation of a new `Context` containing the original | ||
| values and the specified values updated. | ||
|
|
||
| Languages are expected to use the single, widely used `Context` implementation | ||
| if one exists for them. In the cases where an extremely clear, pre-existing | ||
| option is not available, OpenTelemetry MUST provide its own `Context` | ||
| implementation. Depending on the language, its usage may be either explicit | ||
| or implicit. | ||
|
|
||
| Users writing instrumentation in languages that use `Context` implicitly are | ||
| discouraged from using the `Context` API directly. In those cases, users will | ||
| manipulate `Context` through cross-cutting concerns APIs instead, in order to | ||
| perform operations such as setting trace or correlation context values for | ||
| a specified `Context`. | ||
|
|
||
| A `Context` is expected to have the following operations, with their | ||
| respective language differences: | ||
|
|
||
| ## Create a key | ||
|
|
||
| Keys are used to allow cross-cutting concerns to control access to their local state, | ||
| and they cannot be guessed by third parties. It is recommended that concerns mediate | ||
| data access via an API, rather than provide direct public access to their keys. | ||
|
|
||
| The API MUST accept the following parameter: | ||
|
|
||
| - The key identifier. Different languages may impose different restrictions on the expected types, so this parameter remains an implementation detail. | ||
|
|
||
| The API MUST return an opaque object representing the newly created key. | ||
|
|
||
| ## Get value | ||
carlosalberto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Concerns can access their local state in the current execution state | ||
| represented by a `Context`. | ||
|
|
||
| The API MUST accept the following parameters: | ||
|
|
||
| - The `Context`. | ||
| - The key. | ||
|
|
||
| The API MUST return the value in the `Context` for the specified key. | ||
|
|
||
| ## Set value | ||
|
|
||
| Concerns can record their local state in the current execution state | ||
| represented by a `Context`. | ||
|
|
||
| The API MUST accept the following parameters: | ||
|
|
||
| - The `Context`. | ||
| - The key. | ||
| - The value to be set. | ||
|
|
||
| The API MUST return a new `Context` containing the new value. | ||
carlosalberto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Optional Global operations | ||
|
|
||
| These operations are expected to only be implemented by languages | ||
| using `Context` implicitly, and thus are optional. These operations | ||
| SHOULD only be used to implement automatic scope switching and define | ||
| higher level APIs by SDK components and OpenTelemetry instrumentation libraries. | ||
|
|
||
| ### Get current Context | ||
|
|
||
| The API MUST return the `Context` associated with the caller's current execution unit. | ||
|
|
||
| ### Attach Context | ||
|
|
||
| Associates a `Context` with the caller's current execution unit. | ||
|
|
||
| The API MUST accept the following parameters: | ||
|
|
||
| - The `Context`. | ||
|
|
||
| The API MUST return a value that can be used as a `Token` to restore the previous | ||
| `Context`. | ||
|
|
||
| ### Detach Context | ||
|
|
||
| Resets the `Context` associated with the caller's current execution unit | ||
| to the value it had before attaching a specified `Context`. | ||
|
|
||
| The API MUST accept the following parameters: | ||
|
|
||
| - A `Token` that was returned by a previous call to attach a `Context`. | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.