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

Commit 138d5e8

Browse files
authored
update Tag definition with TagMetadata. (#233)
* update Tag definition with TagMetadata. * fix review comments. * fixed more review comments. * fix comments. * rephrased condition for sending/receiving based on tag ttl. * rearranged paragraphs and replaced scoped span with scope. * replace used with supported. * added example for TTL > 0 and decrementTTL option for tag propagators. * differentiate future and current tag processing requirement.
1 parent c762112 commit 138d5e8

File tree

1 file changed

+80
-18
lines changed

1 file changed

+80
-18
lines changed

tags/TagMap.md

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ according to unique value of the `Tag`s. The `Tag`s can also be used to filter (
66
measurements in a `View`. `Tag`s can further be used for logging and tracing.
77

88
# Tag
9-
A `Tag` consists of TagScope, TagKey, and TagValue.
9+
A `Tag` consists of TagMetadata, TagKey, and TagValue.
1010

1111
## TagKey
1212

@@ -23,23 +23,85 @@ and group stats, annotate traces and logs.
2323
`TagValue` is a string. It MUST contain only printable ASCII (codes between
2424
32 and 126)
2525

26-
## TagScope
26+
## TagMetadata
27+
28+
`TagMetadata` contains properties associated with a `Tag`. For now only the property `TagTTL`
29+
is defined. In future, additional properties may be added to address specific situations.
30+
31+
A tag creator determines metadata of a tag it creates.
32+
33+
### TagTTL
34+
35+
`TagTTL` is an integer that represents number of hops a tag can propagate. Anytime a sender serializes a tag,
36+
sends it over the wire and receiver unserializes the tag then the tag is considered to have travelled one hop.
37+
There could be one or more proxy(ies) between sender and receiver. Proxies are treated as transparent
38+
entities and they may not create additional hops. Every propagation implementation should support an option
39+
`decrementTTL` (default set to true) that allows proxies to set it to false.
40+
41+
**For now, ONLY special values (0 and -1) are supported.**
42+
43+
#### Special Values
44+
- **NO_PROPAGATION (0)**: Tag with `TagTTL` value of zero is considered to have local scope and
45+
is used within the process it created.
46+
47+
- **UNLIMITED_PROPAGATION (-1)**: A Tag with `TagTTL` value of -1 can propagate unlimited hops.
48+
However, it is still subject to outgoing and incoming (on remote side) filter criteria.
49+
See `TagPropagationFilter` in [Tag Propagation](#Tag Propagation). `TagTTL` value of -1
50+
is typical used to represent a request, processing of which may span multiple entities.
51+
52+
#### Example for TagTTL > 0
53+
On a server side typically there is no information about the caller besides ip/port,
54+
but in every process there is a notion of "service_name" tag that is added as a "caller" tag before
55+
serialization when a RPC/HTTP call is made. For the "caller" tag, desirable `TagTTL` value is 1.
56+
57+
Note that TagTTL value of 1 is not supported at this time. The example is listed here simply to
58+
show a possible use case for TagTTL > 0.
59+
60+
### Processing at Receiver and Sender
61+
For now, limited processing is required on Sender and Receiver. However, for the sake of
62+
completeness, future processing requirement is also listed here. These requirements are marked with
63+
"**(future)**".
64+
65+
This processing is done as part of tag propagator.
66+
67+
#### At Receiver
68+
Upon receiving a tag from remote entity a tag extractor
69+
70+
- MUST decrement the value of `TagTTL` by one if it is greater than zero. **(future)**
71+
- MUST treat the value of `TagTTL` as -1 if it is not present.
72+
- MUST discard the `Tag` for any other value of `TagTTL`. **(future)**
73+
74+
#### At Sender
75+
Upon preparing to send a tag to a remote entity a tag injector
76+
- MUST send the tag AND include `TagTTL` if its value is greater than 0. **(future)**
77+
- MUST send the tag without 'TagTTL' if its value is -1. Absence of TagTTL on the wire is treated as having TagTTL of -1.
78+
This is to optimize on-the-wire representation of common case.
79+
- MUST not send the tag if the value of `TagTTL` is 0.
80+
81+
A tag accepted for sending/receiving based on `TagTTL` value could still be excluded from sending/receiving based on
82+
`TagPropagationFilter`.
83+
84+
## Tag Conflict Resolution
85+
If a new tag conflicts with an existing tag then the new tag takes precedence. Entire `Tag` along
86+
with `TagValue` and `TagMetadata` is replaced by the most recent tag (regardless of it is locally
87+
generated or received from a remote peer). Replacement is limited to a scope in which the
88+
conflict arises. When the scope is closed the orignal value and metadata prior to the conflict is restored.
89+
For example,
90+
```
91+
T# - Tag keys
92+
V# - Tag Values
93+
M# - Tag Metadata
94+
95+
Enter Scope 1
96+
Current Tags T1=V1/M1, T2=V2/M2
97+
Enter Scope 2
98+
Add Tags T3=V3/M3, T2=v4/M4
99+
Current Tags T1=V1/M1, T2=V4/M4, T3=V3/M3 <== Value/Metadata of T2 is replaced by V4/M4.
100+
Close Scope 2
101+
Current Tags T1=V1/M1, T2=V2/M2 <== T2 is restored.
102+
Close Scope 1
103+
```
27104

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.
43105

44106
# TagMap
45107
`TagMap` is an abstract data type that represents collection of tags.
@@ -61,7 +123,7 @@ list of ordered `TagPropagationFilter`s for receiving `Tag`s or for forwarding `
61123
A `TagPropagationFilter` list for receiving MAY be different then that for forwarding.
62124

63125
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`.
126+
If no filter is specified for forwarding then all `Tag`s are forwarded except those that have `TagTTL` of 0.
65127

66128
### TagPropagationFilter
67129
Tag Propagation Filter consists of action (`TagPropagationFilterAction`) and condition

0 commit comments

Comments
 (0)