Skip to content
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

Adding Correlations API and removing DistributedContext #420

Merged
merged 22 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The OpenTelemetry specification describes the cross-language requirements and ex
- [Package/Library Layout](specification/library-layout.md)
- [Concurrency and Thread-Safety](specification/concurrency.md)
- API Specification
- [DistributedContext](specification/api-distributedcontext.md)
- [CorrelationContext](specification/api-correlationcontext.md)
- [Propagators](specification/api-propagators.md)
- [Tracing](specification/api-tracing.md)
- [Metrics](specification/api-metrics.md)
Expand Down
100 changes: 100 additions & 0 deletions specification/api-correlationcontext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Correlations API

`CorrelationContext` is an abstract data type represented by set of name/value pairs describing user
codeboten marked this conversation as resolved.
Show resolved Hide resolved
defined properties. Each name in `CorrelationContext` is associated with exactly one value.
codeboten marked this conversation as resolved.
Show resolved Hide resolved
`CorrelationContext` is serialized using the [W3C Correlation Context](https://w3c.github.io/correlation-context/) specification and is
codeboten marked this conversation as resolved.
Show resolved Hide resolved
used to annotate telemetry. Those values can be used to add dimension to the metric or
codeboten marked this conversation as resolved.
Show resolved Hide resolved
additional context properties to logs and traces.

`CorrelationContext` is a recommended name but languages can have more
codeboten marked this conversation as resolved.
Show resolved Hide resolved
language-specific names like `cctx`.

## Conflict Resolution

If a new name/value pair is added and its name conflicts with an existing pair, then the new pair takes precedence. The value
codeboten marked this conversation as resolved.
Show resolved Hide resolved
is replaced by the most recent value (regardless of it is locally generated or received from a remote peer). Replacement is limited to a
codeboten marked this conversation as resolved.
Show resolved Hide resolved
scope in which the conflict arises. When the scope is closed the original value prior to the conflict is restored. For example,
codeboten marked this conversation as resolved.
Show resolved Hide resolved

```
T# - entry names
codeboten marked this conversation as resolved.
Show resolved Hide resolved
V# - entry values

Enter Scope 1
codeboten marked this conversation as resolved.
Show resolved Hide resolved
Current Entries E1=V1, E2=V2
Enter Scope 2
Add entries E3=V3, E2=V4
Current Entries E1=V1, E2=V4, E3=V3/M3 <== Value of E2 is replaced by V4.
codeboten marked this conversation as resolved.
Show resolved Hide resolved
Close Scope 2
Current Entries E1=V1, E2=V2 <== E2 is restored.
Close Scope 1
```

## CorrelationContext
codeboten marked this conversation as resolved.
Show resolved Hide resolved

### GetCorrelations

codeboten marked this conversation as resolved.
Show resolved Hide resolved
Returns the entries in this `CorrelationContext`. The order of entries is not
codeboten marked this conversation as resolved.
Show resolved Hide resolved
codeboten marked this conversation as resolved.
Show resolved Hide resolved
significant. Based on the language specification, the returned value can be
either an immutable collection or an immutable iterator to the collection of
codeboten marked this conversation as resolved.
Show resolved Hide resolved
entries in this `CorrelationContext`.

### GetCorrelation
codeboten marked this conversation as resolved.
Show resolved Hide resolved

To access the value for an entry by a prior event, the Correlations API
provides a function which takes a context and a name as input, and returns a
codeboten marked this conversation as resolved.
Show resolved Hide resolved
value. Returns the `Value` associated with the given `Name`, or null
codeboten marked this conversation as resolved.
Show resolved Hide resolved
if the given `Name` is not present.

Required parameter:
codeboten marked this conversation as resolved.
Show resolved Hide resolved

`Context` the context from which to get the correlation.
codeboten marked this conversation as resolved.
Show resolved Hide resolved

`Name` entry name to return the value for.

### SetCorrelation
codeboten marked this conversation as resolved.
Show resolved Hide resolved

To record the value for an entry, the Correlations API provides a function which
codeboten marked this conversation as resolved.
Show resolved Hide resolved
takes a context, a name, and a value as input. Returns an updated `Context` which
codeboten marked this conversation as resolved.
Show resolved Hide resolved
contains the new value.

Required parameter:
codeboten marked this conversation as resolved.
Show resolved Hide resolved

`Context` the context to which the value will be set.

`Name` entry name for which to set the value.
codeboten marked this conversation as resolved.
Show resolved Hide resolved

`Value` entry value to set.

### RemoveCorrelation

To delete an entry, the Correlations API provides a function which takes a context
codeboten marked this conversation as resolved.
Show resolved Hide resolved
and a name as input. Returns an updated `Context` which no longer contains the selected `Name`.

Required parameter:
codeboten marked this conversation as resolved.
Show resolved Hide resolved

`Context` the context from which to remove the correlation.

`Name` entry name to remove.

### ClearCorrelations

To avoid sending any entries to an untrusted process, the Correlation API provides
codeboten marked this conversation as resolved.
Show resolved Hide resolved
a function to remove all Correlations from a context. Returns an updated `Context`
with no correlations.

Required parameter:
codeboten marked this conversation as resolved.
Show resolved Hide resolved

`Context` the context from which to remove all correlations.

### Limits

Combined size of all entries should not exceed 8192 bytes before encoding.
codeboten marked this conversation as resolved.
Show resolved Hide resolved
The size restriction applies to the deserialized entries so that the set of decoded
`CorrelationContext`s is independent of the encoding format.

### CorrelationContext Propagation

`CorrelationContext` may be propagated across process boundaries or across any arbitrary boundaries
codeboten marked this conversation as resolved.
Show resolved Hide resolved
(process, $OTHER_BOUNDARY1, $OTHER_BOUNDARY2, etc) for various reasons.
For example, one may propagate 'project-id' entry across all micro-services to break down metrics
codeboten marked this conversation as resolved.
Show resolved Hide resolved
by 'project-id'.
226 changes: 0 additions & 226 deletions specification/api-distributedcontext.md

This file was deleted.

4 changes: 2 additions & 2 deletions specification/api-propagators.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Serializes the given value into the on-the-wire representation.

Required arguments:

- the value to serialize, can be `SpanContext` or `DistributedContext`.
- the value to serialize, can be `SpanContext` or `CorrelationContext`.

Returns the on-the-wire byte representation of the value.

Expand Down Expand Up @@ -94,7 +94,7 @@ Injects the value downstream. For example, as http headers.

Required arguments:

- the value to be injected, can be `SpanContext` or `DistributedContext`.
- the value to be injected, can be `SpanContext` or `CorrelationContext`.
- the carrier that holds propagation fields. For example, an outgoing message or http request.
- the `Setter` invoked for each propagation key to add or remove.

Expand Down
Loading