Debian Codegraph @

proto/zipkin_proto3/zipkin.proto

raw
1 // Copyright 2022 The OpenZipkin Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 syntax = "proto3";
16
17 // This is the package for using protobuf with Zipkin API V2, but for historical
18 // reasons uses the protoc syntax version instead.
19 package zipkin.proto3;
20
21 // In Java, the closest model type to this proto is in the "zipkin2" package
22 option java_package = "zipkin2.proto3";
23 option java_multiple_files = true;
24
25 option go_package = "github.com/openzipkin/zipkin-go/proto/zipkin_proto3";
26
27 // A span is a single-host view of an operation. A trace is a series of spans
28 // (often RPC calls) which nest to form a latency tree. Spans are in the same
29 // trace when they share the same trace ID. The parent_id field establishes the
30 // position of one span in the tree.
31 //
32 // The root span is where parent_id is Absent and usually has the longest
33 // duration in the trace. However, nested asynchronous work can materialize as
34 // child spans whose duration exceed the root span.
35 //
36 // Spans usually represent remote activity such as RPC calls, or messaging
37 // producers and consumers. However, they can also represent in-process
38 // activity in any position of the trace. For example, a root span could
39 // represent a server receiving an initial client request. A root span could
40 // also represent a scheduled job that has no remote context.
41 //
42 // Encoding notes:
43 //
44 // Epoch timestamp are encoded fixed64 as varint would also be 8 bytes, and more
45 // expensive to encode and size. Duration is stored uint64, as often the numbers
46 // are quite small.
47 //
48 // Default values are ok, as only natural numbers are used. For example, zero is
49 // an invalid timestamp and an invalid duration, false values for debug or shared
50 // are ignorable, and zero-length strings also coerce to null.
51 //
52 // The next id is 14.
53 //
54 // Note fields up to 15 take 1 byte to encode. Take care when adding new fields
55 // https://developers.google.com/protocol-buffers/docs/proto3#assigning-tags
56 message Span {
57 // Randomly generated, unique identifier for a trace, set on all spans within
58 // it.
59 //
60 // This field is required and encoded as 8 or 16 opaque bytes.
61 bytes trace_id = 1;
62 // The parent span ID or absent if this the root span in a trace.
63 bytes parent_id = 2;
64 // Unique identifier for this operation within the trace.
65 //
66 // This field is required and encoded as 8 opaque bytes.
67 bytes id = 3;
68 // When present, kind clarifies timestamp, duration and remote_endpoint. When
69 // absent, the span is local or incomplete. Unlike client and server, there
70 // is no direct critical path latency relationship between producer and
71 // consumer spans.
72 enum Kind {
73 // Default value interpreted as absent.
74 SPAN_KIND_UNSPECIFIED = 0;
75 // The span represents the client side of an RPC operation, implying the
76 // following:
77 //
78 // timestamp is the moment a request was sent to the server.
79 // duration is the delay until a response or an error was received.
80 // remote_endpoint is the server.
81 CLIENT = 1;
82 // The span represents the server side of an RPC operation, implying the
83 // following:
84 //
85 // timestamp is the moment a client request was received.
86 // duration is the delay until a response was sent or an error.
87 // remote_endpoint is the client.
88 SERVER = 2;
89 // The span represents production of a message to a remote broker, implying
90 // the following:
91 //
92 // timestamp is the moment a message was sent to a destination.
93 // duration is the delay sending the message, such as batching.
94 // remote_endpoint is the broker.
95 PRODUCER = 3;
96 // The span represents consumption of a message from a remote broker, not
97 // time spent servicing it. For example, a message processor would be an
98 // in-process child span of a consumer. Consumer spans imply the following:
99 //
100 // timestamp is the moment a message was received from an origin.
101 // duration is the delay consuming the message, such as from backlog.
102 // remote_endpoint is the broker.
103 CONSUMER = 4;
104 }
105 // When present, used to interpret remote_endpoint
106 Kind kind = 4;
107 // The logical operation this span represents in lowercase (e.g. rpc method).
108 // Leave absent if unknown.
109 //
110 // As these are lookup labels, take care to ensure names are low cardinality.
111 // For example, do not embed variables into the name.
112 string name = 5;
113 // Epoch microseconds of the start of this span, possibly absent if
114 // incomplete.
115 //
116 // For example, 1502787600000000 corresponds to 2017-08-15 09:00 UTC
117 //
118 // This value should be set directly by instrumentation, using the most
119 // precise value possible. For example, gettimeofday or multiplying epoch
120 // millis by 1000.
121 //
122 // There are three known edge-cases where this could be reported absent.
123 // - A span was allocated but never started (ex not yet received a timestamp)
124 // - The span's start event was lost
125 // - Data about a completed span (ex tags) were sent after the fact
126 fixed64 timestamp = 6;
127 // Duration in microseconds of the critical path, if known. Durations of less
128 // than one are rounded up. Duration of children can be longer than their
129 // parents due to asynchronous operations.
130 //
131 // For example 150 milliseconds is 150000 microseconds.
132 uint64 duration = 7;
133 // The host that recorded this span, primarily for query by service name.
134 //
135 // Instrumentation should always record this. Usually, absent implies late
136 // data. The IP address corresponding to this is usually the site local or
137 // advertised service address. When present, the port indicates the listen
138 // port.
139 Endpoint local_endpoint = 8;
140 // When an RPC (or messaging) span, indicates the other side of the
141 // connection.
142 //
143 // By recording the remote endpoint, your trace will contain network context
144 // even if the peer is not tracing. For example, you can record the IP from
145 // the "X-Forwarded-For" header or the service name and socket of a remote
146 // peer.
147 Endpoint remote_endpoint = 9;
148 // Associates events that explain latency with the time they happened.
149 repeated Annotation annotations = 10;
150 // Tags give your span context for search, viewing and analysis.
151 //
152 // For example, a key "your_app.version" would let you lookup traces by
153 // version. A tag "sql.query" isn't searchable, but it can help in debugging
154 // when viewing a trace.
155 map<string, string> tags = 11;
156 // True is a request to store this span even if it overrides sampling policy.
157 //
158 // This is true when the "X-B3-Flags" header has a value of 1.
159 bool debug = 12;
160 // True if we are contributing to a span started by another tracer (ex on a
161 // different host).
162 bool shared = 13;
163 }
164
165 // The network context of a node in the service graph.
166 //
167 // The next id is 5.
168 message Endpoint {
169 // Lower-case label of this node in the service graph, such as "favstar".
170 // Leave absent if unknown.
171 //
172 // This is a primary label for trace lookup and aggregation, so it should be
173 // intuitive and consistent. Many use a name from service discovery.
174 string service_name = 1;
175 // 4 byte representation of the primary IPv4 address associated with this
176 // connection. Absent if unknown.
177 bytes ipv4 = 2;
178 // 16 byte representation of the primary IPv6 address associated with this
179 // connection. Absent if unknown.
180 //
181 // Prefer using the ipv4 field for mapped addresses.
182 bytes ipv6 = 3;
183 // Depending on context, this could be a listen port or the client-side of a
184 // socket. Absent if unknown.
185 int32 port = 4;
186 }
187
188 // Associates an event that explains latency with a timestamp.
189 // Unlike log statements, annotations are often codes. Ex. "ws" for WireSend
190 //
191 // The next id is 3.
192 message Annotation {
193 // Epoch microseconds of this event.
194 //
195 // For example, 1502787600000000 corresponds to 2017-08-15 09:00 UTC
196 //
197 // This value should be set directly by instrumentation, using the most
198 // precise value possible. For example, gettimeofday or multiplying epoch
199 // millis by 1000.
200 fixed64 timestamp = 1;
201 // Usually a short tag indicating an event, like "error"
202 //
203 // While possible to add larger data, such as garbage collection details, low
204 // cardinality event names both keep the size of spans down and also are easy
205 // to search against.
206 string value = 2;
207 }
208
209 // A list of spans with possibly different trace ids, in no particular order.
210 //
211 // This is used for all transports: POST, Kafka messages etc. No other fields
212 // are expected, This message facilitates the mechanics of encoding a list, as
213 // a field number is required. The name of this type is the same in the OpenApi
214 // aka Swagger specification. https://zipkin.io/zipkin-api/#/default/post_spans
215 message ListOfSpans {
216 repeated Span spans = 1;
217 }