trace.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. // Copyright 2020 Google LLC
  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. syntax = "proto3";
  15. package google.devtools.cloudtrace.v2;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/protobuf/timestamp.proto";
  19. import "google/protobuf/wrappers.proto";
  20. import "google/rpc/status.proto";
  21. option csharp_namespace = "Google.Cloud.Trace.V2";
  22. option go_package = "google.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "TraceProto";
  25. option java_package = "com.google.devtools.cloudtrace.v2";
  26. option php_namespace = "Google\\Cloud\\Trace\\V2";
  27. option ruby_package = "Google::Cloud::Trace::V2";
  28. // A span represents a single operation within a trace. Spans can be
  29. // nested to form a trace tree. Often, a trace contains a root span
  30. // that describes the end-to-end latency, and one or more subspans for
  31. // its sub-operations. A trace can also contain multiple root spans,
  32. // or none at all. Spans do not need to be contiguous—there may be
  33. // gaps or overlaps between spans in a trace.
  34. message Span {
  35. option (google.api.resource) = {
  36. type: "cloudtrace.googleapis.com/Span"
  37. pattern: "projects/{project}/traces/{trace}/spans/{span}"
  38. };
  39. // A set of attributes, each in the format `[KEY]:[VALUE]`.
  40. message Attributes {
  41. // The set of attributes. Each attribute's key can be up to 128 bytes
  42. // long. The value can be a string up to 256 bytes, a signed 64-bit integer,
  43. // or the Boolean values `true` and `false`. For example:
  44. //
  45. // "/instance_id": { "string_value": { "value": "my-instance" } }
  46. // "/http/request_bytes": { "int_value": 300 }
  47. // "abc.com/myattribute": { "bool_value": false }
  48. map<string, AttributeValue> attribute_map = 1;
  49. // The number of attributes that were discarded. Attributes can be discarded
  50. // because their keys are too long or because there are too many attributes.
  51. // If this value is 0 then all attributes are valid.
  52. int32 dropped_attributes_count = 2;
  53. }
  54. // A time-stamped annotation or message event in the Span.
  55. message TimeEvent {
  56. // Text annotation with a set of attributes.
  57. message Annotation {
  58. // A user-supplied message describing the event. The maximum length for
  59. // the description is 256 bytes.
  60. TruncatableString description = 1;
  61. // A set of attributes on the annotation. You can have up to 4 attributes
  62. // per Annotation.
  63. Attributes attributes = 2;
  64. }
  65. // An event describing a message sent/received between Spans.
  66. message MessageEvent {
  67. // Indicates whether the message was sent or received.
  68. enum Type {
  69. // Unknown event type.
  70. TYPE_UNSPECIFIED = 0;
  71. // Indicates a sent message.
  72. SENT = 1;
  73. // Indicates a received message.
  74. RECEIVED = 2;
  75. }
  76. // Type of MessageEvent. Indicates whether the message was sent or
  77. // received.
  78. Type type = 1;
  79. // An identifier for the MessageEvent's message that can be used to match
  80. // SENT and RECEIVED MessageEvents. It is recommended to be unique within
  81. // a Span.
  82. int64 id = 2;
  83. // The number of uncompressed bytes sent or received.
  84. int64 uncompressed_size_bytes = 3;
  85. // The number of compressed bytes sent or received. If missing assumed to
  86. // be the same size as uncompressed.
  87. int64 compressed_size_bytes = 4;
  88. }
  89. // The timestamp indicating the time the event occurred.
  90. google.protobuf.Timestamp time = 1;
  91. // A `TimeEvent` can contain either an `Annotation` object or a
  92. // `MessageEvent` object, but not both.
  93. oneof value {
  94. // Text annotation with a set of attributes.
  95. Annotation annotation = 2;
  96. // An event describing a message sent/received between Spans.
  97. MessageEvent message_event = 3;
  98. }
  99. }
  100. // A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation
  101. // on the span, consisting of either user-supplied key:value pairs, or
  102. // details of a message sent/received between Spans.
  103. message TimeEvents {
  104. // A collection of `TimeEvent`s.
  105. repeated TimeEvent time_event = 1;
  106. // The number of dropped annotations in all the included time events.
  107. // If the value is 0, then no annotations were dropped.
  108. int32 dropped_annotations_count = 2;
  109. // The number of dropped message events in all the included time events.
  110. // If the value is 0, then no message events were dropped.
  111. int32 dropped_message_events_count = 3;
  112. }
  113. // A pointer from the current span to another span in the same trace or in a
  114. // different trace. For example, this can be used in batching operations,
  115. // where a single batch handler processes multiple requests from different
  116. // traces or when the handler receives a request from a different project.
  117. message Link {
  118. // The relationship of the current span relative to the linked span: child,
  119. // parent, or unspecified.
  120. enum Type {
  121. // The relationship of the two spans is unknown.
  122. TYPE_UNSPECIFIED = 0;
  123. // The linked span is a child of the current span.
  124. CHILD_LINKED_SPAN = 1;
  125. // The linked span is a parent of the current span.
  126. PARENT_LINKED_SPAN = 2;
  127. }
  128. // The [TRACE_ID] for a trace within a project.
  129. string trace_id = 1;
  130. // The [SPAN_ID] for a span within a trace.
  131. string span_id = 2;
  132. // The relationship of the current span relative to the linked span.
  133. Type type = 3;
  134. // A set of attributes on the link. You have have up to 32 attributes per
  135. // link.
  136. Attributes attributes = 4;
  137. }
  138. // A collection of links, which are references from this span to a span
  139. // in the same or different trace.
  140. message Links {
  141. // A collection of links.
  142. repeated Link link = 1;
  143. // The number of dropped links after the maximum size was enforced. If
  144. // this value is 0, then no links were dropped.
  145. int32 dropped_links_count = 2;
  146. }
  147. // Type of span. Can be used to specify additional relationships between spans
  148. // in addition to a parent/child relationship.
  149. enum SpanKind {
  150. // Unspecified. Do NOT use as default.
  151. // Implementations MAY assume SpanKind.INTERNAL to be default.
  152. SPAN_KIND_UNSPECIFIED = 0;
  153. // Indicates that the span is used internally. Default value.
  154. INTERNAL = 1;
  155. // Indicates that the span covers server-side handling of an RPC or other
  156. // remote network request.
  157. SERVER = 2;
  158. // Indicates that the span covers the client-side wrapper around an RPC or
  159. // other remote request.
  160. CLIENT = 3;
  161. // Indicates that the span describes producer sending a message to a broker.
  162. // Unlike client and server, there is no direct critical path latency
  163. // relationship between producer and consumer spans (e.g. publishing a
  164. // message to a pubsub service).
  165. PRODUCER = 4;
  166. // Indicates that the span describes consumer receiving a message from a
  167. // broker. Unlike client and server, there is no direct critical path
  168. // latency relationship between producer and consumer spans (e.g. receiving
  169. // a message from a pubsub service subscription).
  170. CONSUMER = 5;
  171. }
  172. // Required. The resource name of the span in the following format:
  173. //
  174. // projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]
  175. //
  176. // [TRACE_ID] is a unique identifier for a trace within a project;
  177. // it is a 32-character hexadecimal encoding of a 16-byte array.
  178. //
  179. // [SPAN_ID] is a unique identifier for a span within a trace; it
  180. // is a 16-character hexadecimal encoding of an 8-byte array.
  181. string name = 1 [(google.api.field_behavior) = REQUIRED];
  182. // Required. The [SPAN_ID] portion of the span's resource name.
  183. string span_id = 2 [(google.api.field_behavior) = REQUIRED];
  184. // The [SPAN_ID] of this span's parent span. If this is a root span,
  185. // then this field must be empty.
  186. string parent_span_id = 3;
  187. // Required. A description of the span's operation (up to 128 bytes).
  188. // Stackdriver Trace displays the description in the
  189. // Google Cloud Platform Console.
  190. // For example, the display name can be a qualified method name or a file name
  191. // and a line number where the operation is called. A best practice is to use
  192. // the same display name within an application and at the same call point.
  193. // This makes it easier to correlate spans in different traces.
  194. TruncatableString display_name = 4 [(google.api.field_behavior) = REQUIRED];
  195. // Required. The start time of the span. On the client side, this is the time kept by
  196. // the local machine where the span execution starts. On the server side, this
  197. // is the time when the server's application handler starts running.
  198. google.protobuf.Timestamp start_time = 5 [(google.api.field_behavior) = REQUIRED];
  199. // Required. The end time of the span. On the client side, this is the time kept by
  200. // the local machine where the span execution ends. On the server side, this
  201. // is the time when the server application handler stops running.
  202. google.protobuf.Timestamp end_time = 6 [(google.api.field_behavior) = REQUIRED];
  203. // A set of attributes on the span. You can have up to 32 attributes per
  204. // span.
  205. Attributes attributes = 7;
  206. // Stack trace captured at the start of the span.
  207. StackTrace stack_trace = 8;
  208. // A set of time events. You can have up to 32 annotations and 128 message
  209. // events per span.
  210. TimeEvents time_events = 9;
  211. // Links associated with the span. You can have up to 128 links per Span.
  212. Links links = 10;
  213. // Optional. The final status for this span.
  214. google.rpc.Status status = 11 [(google.api.field_behavior) = OPTIONAL];
  215. // Optional. Set this parameter to indicate whether this span is in
  216. // the same process as its parent. If you do not set this parameter,
  217. // Stackdriver Trace is unable to take advantage of this helpful
  218. // information.
  219. google.protobuf.BoolValue same_process_as_parent_span = 12 [(google.api.field_behavior) = OPTIONAL];
  220. // Optional. The number of child spans that were generated while this span
  221. // was active. If set, allows implementation to detect missing child spans.
  222. google.protobuf.Int32Value child_span_count = 13 [(google.api.field_behavior) = OPTIONAL];
  223. // Optional. Distinguishes between spans generated in a particular context. For example,
  224. // two spans with the same name may be distinguished using `CLIENT` (caller)
  225. // and `SERVER` (callee) to identify an RPC call.
  226. SpanKind span_kind = 14 [(google.api.field_behavior) = OPTIONAL];
  227. }
  228. // The allowed types for [VALUE] in a `[KEY]:[VALUE]` attribute.
  229. message AttributeValue {
  230. // The type of the value.
  231. oneof value {
  232. // A string up to 256 bytes long.
  233. TruncatableString string_value = 1;
  234. // A 64-bit signed integer.
  235. int64 int_value = 2;
  236. // A Boolean value represented by `true` or `false`.
  237. bool bool_value = 3;
  238. }
  239. }
  240. // A call stack appearing in a trace.
  241. message StackTrace {
  242. // Represents a single stack frame in a stack trace.
  243. message StackFrame {
  244. // The fully-qualified name that uniquely identifies the function or
  245. // method that is active in this frame (up to 1024 bytes).
  246. TruncatableString function_name = 1;
  247. // An un-mangled function name, if `function_name` is
  248. // [mangled](http://www.avabodh.com/cxxin/namemangling.html). The name can
  249. // be fully-qualified (up to 1024 bytes).
  250. TruncatableString original_function_name = 2;
  251. // The name of the source file where the function call appears (up to 256
  252. // bytes).
  253. TruncatableString file_name = 3;
  254. // The line number in `file_name` where the function call appears.
  255. int64 line_number = 4;
  256. // The column number where the function call appears, if available.
  257. // This is important in JavaScript because of its anonymous functions.
  258. int64 column_number = 5;
  259. // The binary module from where the code was loaded.
  260. Module load_module = 6;
  261. // The version of the deployed source code (up to 128 bytes).
  262. TruncatableString source_version = 7;
  263. }
  264. // A collection of stack frames, which can be truncated.
  265. message StackFrames {
  266. // Stack frames in this call stack.
  267. repeated StackFrame frame = 1;
  268. // The number of stack frames that were dropped because there
  269. // were too many stack frames.
  270. // If this value is 0, then no stack frames were dropped.
  271. int32 dropped_frames_count = 2;
  272. }
  273. // Stack frames in this stack trace. A maximum of 128 frames are allowed.
  274. StackFrames stack_frames = 1;
  275. // The hash ID is used to conserve network bandwidth for duplicate
  276. // stack traces within a single trace.
  277. //
  278. // Often multiple spans will have identical stack traces.
  279. // The first occurrence of a stack trace should contain both the
  280. // `stackFrame` content and a value in `stackTraceHashId`.
  281. //
  282. // Subsequent spans within the same request can refer
  283. // to that stack trace by only setting `stackTraceHashId`.
  284. int64 stack_trace_hash_id = 2;
  285. }
  286. // Binary module.
  287. message Module {
  288. // For example: main binary, kernel modules, and dynamic libraries
  289. // such as libc.so, sharedlib.so (up to 256 bytes).
  290. TruncatableString module = 1;
  291. // A unique identifier for the module, usually a hash of its
  292. // contents (up to 128 bytes).
  293. TruncatableString build_id = 2;
  294. }
  295. // Represents a string that might be shortened to a specified length.
  296. message TruncatableString {
  297. // The shortened string. For example, if the original string is 500
  298. // bytes long and the limit of the string is 128 bytes, then
  299. // `value` contains the first 128 bytes of the 500-byte string.
  300. //
  301. // Truncation always happens on a UTF8 character boundary. If there
  302. // are multi-byte characters in the string, then the length of the
  303. // shortened string might be less than the size limit.
  304. string value = 1;
  305. // The number of bytes removed from the original string. If this
  306. // value is 0, then the string was not shortened.
  307. int32 truncated_byte_count = 2;
  308. }