-
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
Changes from 74 commits
fb10415
8451596
5275f32
7c01d61
dd834a7
7f9c6b8
f43b7db
548e3d0
4942040
dda30bb
59cf5f3
278839b
71f51e5
a3502c1
9be19e2
ae1c052
0a4f08d
a491a5b
a36759c
58c6248
ecdd80d
95f7bd2
656fe58
9e8a3bd
086facb
63c40a6
551a255
bf398e1
5a9a679
0f26bc7
6b962ba
60e22c0
505c2f7
e06c9b0
af9287a
d38b6fc
0e76724
c697fef
a4d588c
fdd79e1
48d98c2
07398c1
051f36f
e307486
073a526
9745124
4649574
c4b3423
0b5c1f1
3b58a29
3fe6238
732f4e9
01e0925
a3e5134
13b1c02
75ae4bc
5f0b166
7393c0c
42adf76
eeb9afc
0794250
190da25
c8bbf39
f28568c
74d1084
dc92999
93a0cf7
e91a898
2db3f2e
4e02075
8bc320e
96c26b9
85cbb5b
f1431c8
965f365
a289dff
27e701a
980af1b
c9c3cf1
31af4d9
a3567d9
cbd3b71
54735b8
349af35
6ce4054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 `Context` in order to get and set the | ||
carlosalberto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| current `Span` state and how `Span`s are passed across process boundaries. | ||
bogdandrutu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # 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) | ||
| - [Set current Context](#set-current-context) | ||
|
|
||
| </details> | ||
|
|
||
| ## Overview | ||
carlosalberto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| `Context` is a propagation mechanism which carries execution-scoped values | ||
carlosalberto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| across API boundaries and between logically associated execution units. | ||
| Cross-cutting concerns access their data in-process using the same shared | ||
| `Context` object. | ||
|
|
||
| `Context` MUST be immutable, and its write operations MUST | ||
carlosalberto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| result in the creation of a new `Context` cointaining the original | ||
carlosalberto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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`. | ||
|
|
||
| `Context` is expected to have the following operations, with their | ||
carlosalberto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| respective language differences: | ||
bogdandrutu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## 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 | ||
|
|
||
| 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. | ||
|
|
||
| ### Set current Context | ||
|
|
||
| Associates a `Context` with the caller's current execution unit. | ||
|
|
||
| The API MUST accept the following parameters: | ||
|
|
||
| - The `Context`. | ||
|
||
|
|
||
| The API SHOULD return a handle that can be used to restore the previous | ||
| `Context`. | ||
Uh oh!
There was an error while loading. Please reload this page.