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

Commit db7e6a3

Browse files
authored
Merge pull request #8 from sebright/tag-context-encoding
Start documenting the binary encoding for Tag Context.
2 parents 08c43ef + 229182e commit db7e6a3

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

encodings/BinaryEncoding.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,38 @@ This corresponds to:
100100
* `spanId` = {52, 240, 103, 170, 11, 169, 2, 183}
101101
* `traceOptions` = 1
102102

103+
### Tag Context
104+
The Tag Context format uses Varint encoding, which is described in
105+
https://developers.google.com/protocol-buffers/docs/encoding#varints. Note that
106+
each type of tag can appear multiple times.
107+
108+
#### String tag
109+
110+
* `field_id` = 0
111+
* `field_format` = `<tag_key_len><tag_key><tag_val_len><tag_val>` where
112+
113+
* `tag_key_len` is a varint encoded integer.
114+
* `tag_key` is `tag_key_len` bytes comprising the tag key name.
115+
* `tag_val_len` is a varint encoded integer.
116+
* `tag_val` is `tag_val_len` bytes comprising the tag value.
117+
118+
#### Integer tag
119+
120+
* `field_id` = 1
121+
* `field_format` = `<tag_key_len><tag_key><tag_val>` where
122+
123+
* `tag_key_len` is a varint encoded integer.
124+
* `tag_key` is `tag_key_len` bytes comprising the tag key name.
125+
* `tag_val` is 8 bytes, a little-endian int64, representing the tag value.
126+
127+
#### Boolean tag
128+
129+
* `field_id` = 2 or 3, where 2 represents a true value and 3 represents a false value.
130+
* `field_format` = `<tag_key_len><tag_key>` where
131+
132+
* `tag_key_len` is a varint encoded integer.
133+
* `tag_key` is `tag_key_len` bytes comprising the tag key name.
134+
103135
## Related Work
104136
* [TraceContext Project](https://github.com/TraceContext/tracecontext-spec)
105137
* [Stackdriver TraceContext Header](https://cloud.google.com/trace/docs/support)

0 commit comments

Comments
 (0)