Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 91cca5e

Browse files
authored
Initial Draft for TagMap and its propagation. (#200)
* [WIP] Initial Draft for TagMap and its propagation. * Modified the spec with simple approach of remote and local tags. * Revised the spec with Local and non-local scope. Removed metadata. * Fix review comments. * fix few more review comments. - changed Global to Request scope - changed TagFilter to TagPropagationFilter - added HAS_PREFIX option for TagFilterAction * rename all TagFilter* to TagPropagationFilter* * defined FilterAction as an interface.
1 parent efec9d5 commit 91cca5e

File tree

2 files changed

+127
-48
lines changed

2 files changed

+127
-48
lines changed

tags/TagContext.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

tags/TagMap.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Summary
2+
A `Tag` is used to label anything that is associated
3+
with a specific operation, such as an HTTP request. These `Tag`s are used to
4+
aggregate measurements in a [`View`](https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/DataAggregation.md#view)
5+
according to unique value of the `Tag`s. The `Tag`s can also be used to filter (include/exclude)
6+
measurements in a `View`. `Tag`s can further be used for logging and tracing.
7+
8+
# Tag
9+
A `Tag` consists of TagScope, TagKey, and TagValue.
10+
11+
## TagKey
12+
13+
`TagKey` is the name of the Tag. TagKey along with `TagValue` is used to aggregate
14+
and group stats, annotate traces and logs.
15+
16+
**Restrictions**
17+
- Must contain only printable ASCII (codes between 32 and 126 inclusive)
18+
- Must have length greater than zero and less than 256.
19+
- Must not be empty.
20+
21+
## TagValue
22+
23+
`TagValue` is a string. It MUST contain only printable ASCII (codes between
24+
32 and 126)
25+
26+
## TagScope
27+
28+
`TagScope` is used to determine the scope of a `Tag`. The values for the `TagScope` are
29+
Local or Request. In future, additional values can be added to address specific situations.
30+
31+
The tag creator determines the scope of the tag.
32+
33+
**Local Scope**
34+
Tag with `Local` scope are used within the process it created. Such tags are not propagated
35+
across process boundaries. Even if the process is reentrant the tag MUST be excluded from
36+
propagation when the call leaves the process.
37+
38+
**Request Scope**
39+
If a tag is created with the `Request` scope then it is propagated across process boundaries subject
40+
to outgoing and incoming (on remote side) filter criteria. See `TagPropagationFilter` in
41+
[Tag Propagation](#Tag Propagation). Typically 'Request' tags represents a request, processing
42+
of which may span multiple entities.
43+
44+
# TagMap
45+
`TagMap` is an abstract data type that represents collection of tags.
46+
i.e., each key is associated with exactly one value. `TagMap` is serializable, and it represents
47+
all of the information that could be propagated inside the process and across process boundaries.
48+
`TagMap` is a recommended name but languages can have more language specific name.
49+
50+
## Limits
51+
Combined size of all `Tag`s should not exceed 8192 bytes before encoding.
52+
The size restriction applies to the deserialized tags so that the set of decoded
53+
`TagMap`s is independent of the encoding format.
54+
55+
## TagMap Propagation
56+
`TagMap` may be propagated across process boundaries or across any arbitrary boundaries for various
57+
reasons. For example, one may propagate 'project-id' Tag across all micro-services to break down metrics
58+
by 'project-id'. Not all `Tag`s in a `TagMap` should be propagated and not all `Tag`s in a `TagMap`
59+
should be accepted from a remote peer. Hence, `TagMap` propagator must allow specifying an optional
60+
list of ordered `TagPropagationFilter`s for receiving `Tag`s or for forwarding `Tag`s or for both.
61+
A `TagPropagationFilter` list for receiving MAY be different then that for forwarding.
62+
63+
If no filter is specified for receiving then all `Tag`s are received.
64+
If no filter is specified for forwarding then all `Tag`s are forwarded except those that have `Local Scope`.
65+
66+
### TagPropagationFilter
67+
Tag Propagation Filter consists of action (`TagPropagationFilterAction`) and condition
68+
(`TagPropagationFilterMatchOperator` and `TagPropagationFilterMatchString`). A `TagKey`
69+
is evaluated against condition of each `TagPropagationFilter` in order. If the condition is evaluated
70+
to true then action is taken according to `TagPropagationFilterAction` and filter processing is stopped.
71+
If the condition is evaluated to false then the `TagKey` is processed against next `TagPropagationFilter`
72+
in the ordered list. If none of the condition is evaluated to true then the default
73+
action is **Exclude**.
74+
75+
#### TagPropagationFilterAction
76+
This is an interface. Implementation of this interface takes appropriate action on the `Tag` if the
77+
condition (`TagPropagationFitlerMatchOperator` and `TagPropagationFilterMatchString`) is evaluated to true.
78+
At a minimum, `Exclude` and `Include` actions MUST be implemented.
79+
80+
**Exclude**
81+
If the `TagPropagationFilterAction` is Exclude then any `Tag` whose `TagKey` evaluates to true
82+
with the condition (`TagPropagationFitlerMatchOperator` and `TagPropagationFilterMatchString`)
83+
MUST be excluded.
84+
85+
**Include**
86+
If the `TagPropagationFilterAction` is Include then any `Tag` whose `TagKey` evaluates to true
87+
with the condition (`TagPropagationFitlerMatchOperator ` and `TagPropagationFilterMatchString`)
88+
MUST be included.
89+
90+
#### TagPropagationFilterMatchOperator
91+
92+
| Operator | Description |
93+
|----------|-------------|
94+
| EQUAL | The condition is evaluated to true if `TagKey` is exactly same as `TagPropagationFilterMatchString` |
95+
| NOTEQUAL | The condition is evaluated to true if `TagKey` is NOT exactly same as `TagPropagationFilterMatchString` |
96+
| HAS_PREFIX | The condition is evaluated to true if `TagKey` begins with `TagPropagationFilterMatchString` |
97+
98+
#### TagPropagationFilterMatchString
99+
It is a string to compare against TagKey using `TagPropagationFilterMatchOperator` in order to
100+
include or exclude a `Tag`.
101+
102+
## Encoding
103+
104+
### Wire Format
105+
TBD:
106+
107+
#### Over gRPC
108+
TagMap should be encoded using [BinaryEncoding](https://github.com/census-instrumentation/opencensus-specs/tree/master/encodings)
109+
and propagated using gRPC metadata opencensus-tag-bin.
110+
111+
#### Over HTTP
112+
113+
TBD: W3C [correlation context](https://github.com/w3c/correlation-context/blob/master/correlation_context/HTTP_HEADER_FORMAT.md)
114+
may be an appropriate choice.
115+
116+
117+
### Error handling
118+
- Call should continue irrespective of any error related to encoding/decoding.
119+
- There are no partial failures for encoding or decoding. The result of encoding or decoding
120+
should always be a complete `TagMap` or an error. The type of error
121+
reporting depends on the language.
122+
- Serialization should result in an error if the `TagMap` does not meet the
123+
size restriction above.
124+
- Deserialization should result in an error if the serialized `TagMap`
125+
- cannot be parsed.
126+
- contains a `TagKey` or `TagValue` that does not meet the restrictions above.
127+
- does not meet the size restriction above.

0 commit comments

Comments
 (0)