trace.proto 14 KB

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