trace.proto 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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.v1;
  16. import "google/api/client.proto";
  17. import "google/api/field_behavior.proto";
  18. import "google/api/resource.proto";
  19. import "google/protobuf/empty.proto";
  20. import "google/protobuf/timestamp.proto";
  21. import "google/api/annotations.proto";
  22. option csharp_namespace = "Google.Cloud.Trace.V1";
  23. option go_package = "google.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace";
  24. option java_multiple_files = true;
  25. option java_outer_classname = "TraceProto";
  26. option java_package = "com.google.devtools.cloudtrace.v1";
  27. option php_namespace = "Google\\Cloud\\Trace\\V1";
  28. option ruby_package = "Google::Cloud::Trace::V1";
  29. // This file describes an API for collecting and viewing traces and spans
  30. // within a trace. A Trace is a collection of spans corresponding to a single
  31. // operation or set of operations for an application. A span is an individual
  32. // timed event which forms a node of the trace tree. Spans for a single trace
  33. // may span multiple services.
  34. service TraceService {
  35. option (google.api.default_host) = "cloudtrace.googleapis.com";
  36. option (google.api.oauth_scopes) =
  37. "https://www.googleapis.com/auth/cloud-platform,"
  38. "https://www.googleapis.com/auth/trace.append,"
  39. "https://www.googleapis.com/auth/trace.readonly";
  40. // Returns of a list of traces that match the specified filter conditions.
  41. rpc ListTraces(ListTracesRequest) returns (ListTracesResponse) {
  42. option (google.api.http) = {
  43. get: "/v1/projects/{project_id}/traces"
  44. };
  45. option (google.api.method_signature) = "project_id";
  46. }
  47. // Gets a single trace by its ID.
  48. rpc GetTrace(GetTraceRequest) returns (Trace) {
  49. option (google.api.http) = {
  50. get: "/v1/projects/{project_id}/traces/{trace_id}"
  51. };
  52. option (google.api.method_signature) = "project_id,trace_id";
  53. }
  54. // Sends new traces to Stackdriver Trace or updates existing traces. If the ID
  55. // of a trace that you send matches that of an existing trace, any fields
  56. // in the existing trace and its spans are overwritten by the provided values,
  57. // and any new fields provided are merged with the existing trace data. If the
  58. // ID does not match, a new trace is created.
  59. rpc PatchTraces(PatchTracesRequest) returns (google.protobuf.Empty) {
  60. option (google.api.http) = {
  61. patch: "/v1/projects/{project_id}/traces"
  62. body: "traces"
  63. };
  64. option (google.api.method_signature) = "project_id,traces";
  65. }
  66. }
  67. // A trace describes how long it takes for an application to perform an
  68. // operation. It consists of a set of spans, each of which represent a single
  69. // timed event within the operation.
  70. message Trace {
  71. // Project ID of the Cloud project where the trace data is stored.
  72. string project_id = 1;
  73. // Globally unique identifier for the trace. This identifier is a 128-bit
  74. // numeric value formatted as a 32-byte hex string. For example,
  75. // `382d4f4c6b7bb2f4a972559d9085001d`.
  76. string trace_id = 2;
  77. // Collection of spans in the trace.
  78. repeated TraceSpan spans = 3;
  79. }
  80. // List of new or updated traces.
  81. message Traces {
  82. // List of traces.
  83. repeated Trace traces = 1;
  84. }
  85. // A span represents a single timed event within a trace. Spans can be nested
  86. // and form a trace tree. Often, a trace contains a root span that describes the
  87. // end-to-end latency of an operation and, optionally, one or more subspans for
  88. // its suboperations. Spans do not need to be contiguous. There may be gaps
  89. // between spans in a trace.
  90. message TraceSpan {
  91. // Type of span. Can be used to specify additional relationships between spans
  92. // in addition to a parent/child relationship.
  93. enum SpanKind {
  94. // Unspecified.
  95. SPAN_KIND_UNSPECIFIED = 0;
  96. // Indicates that the span covers server-side handling of an RPC or other
  97. // remote network request.
  98. RPC_SERVER = 1;
  99. // Indicates that the span covers the client-side wrapper around an RPC or
  100. // other remote request.
  101. RPC_CLIENT = 2;
  102. }
  103. // Identifier for the span. Must be a 64-bit integer other than 0 and
  104. // unique within a trace. For example, `2205310701640571284`.
  105. fixed64 span_id = 1;
  106. // Distinguishes between spans generated in a particular context. For example,
  107. // two spans with the same name may be distinguished using `RPC_CLIENT`
  108. // and `RPC_SERVER` to identify queueing latency associated with the span.
  109. SpanKind kind = 2;
  110. // Name of the span. Must be less than 128 bytes. The span name is sanitized
  111. // and displayed in the Stackdriver Trace tool in the
  112. // Google Cloud Platform Console.
  113. // The name may be a method name or some other per-call site name.
  114. // For the same executable and the same call point, a best practice is
  115. // to use a consistent name, which makes it easier to correlate
  116. // cross-trace spans.
  117. string name = 3;
  118. // Start time of the span in nanoseconds from the UNIX epoch.
  119. google.protobuf.Timestamp start_time = 4;
  120. // End time of the span in nanoseconds from the UNIX epoch.
  121. google.protobuf.Timestamp end_time = 5;
  122. // Optional. ID of the parent span, if any.
  123. fixed64 parent_span_id = 6 [(google.api.field_behavior) = OPTIONAL];
  124. // Collection of labels associated with the span. Label keys must be less than
  125. // 128 bytes. Label values must be less than 16 kilobytes (10MB for
  126. // `/stacktrace` values).
  127. //
  128. // Some predefined label keys exist, or you may create your own. When creating
  129. // your own, we recommend the following formats:
  130. //
  131. // * `/category/product/key` for agents of well-known products (e.g.
  132. // `/db/mongodb/read_size`).
  133. // * `short_host/path/key` for domain-specific keys (e.g.
  134. // `foo.com/myproduct/bar`)
  135. //
  136. // Predefined labels include:
  137. //
  138. // * `/agent`
  139. // * `/component`
  140. // * `/error/message`
  141. // * `/error/name`
  142. // * `/http/client_city`
  143. // * `/http/client_country`
  144. // * `/http/client_protocol`
  145. // * `/http/client_region`
  146. // * `/http/host`
  147. // * `/http/method`
  148. // * `/http/path`
  149. // * `/http/redirected_url`
  150. // * `/http/request/size`
  151. // * `/http/response/size`
  152. // * `/http/route`
  153. // * `/http/status_code`
  154. // * `/http/url`
  155. // * `/http/user_agent`
  156. // * `/pid`
  157. // * `/stacktrace`
  158. // * `/tid`
  159. map<string, string> labels = 7;
  160. }
  161. // The request message for the `ListTraces` method. All fields are required
  162. // unless specified.
  163. message ListTracesRequest {
  164. // Type of data returned for traces in the list.
  165. enum ViewType {
  166. // Default is `MINIMAL` if unspecified.
  167. VIEW_TYPE_UNSPECIFIED = 0;
  168. // Minimal view of the trace record that contains only the project
  169. // and trace IDs.
  170. MINIMAL = 1;
  171. // Root span view of the trace record that returns the root spans along
  172. // with the minimal trace data.
  173. ROOTSPAN = 2;
  174. // Complete view of the trace record that contains the actual trace data.
  175. // This is equivalent to calling the REST `get` or RPC `GetTrace` method
  176. // using the ID of each listed trace.
  177. COMPLETE = 3;
  178. }
  179. // Required. ID of the Cloud project where the trace data is stored.
  180. string project_id = 1 [(google.api.field_behavior) = REQUIRED];
  181. // Optional. Type of data returned for traces in the list. Default is
  182. // `MINIMAL`.
  183. ViewType view = 2 [(google.api.field_behavior) = OPTIONAL];
  184. // Optional. Maximum number of traces to return. If not specified or <= 0, the
  185. // implementation selects a reasonable value. The implementation may
  186. // return fewer traces than the requested page size.
  187. int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL];
  188. // Token identifying the page of results to return. If provided, use the
  189. // value of the `next_page_token` field from a previous request.
  190. string page_token = 4;
  191. // Start of the time interval (inclusive) during which the trace data was
  192. // collected from the application.
  193. google.protobuf.Timestamp start_time = 5;
  194. // End of the time interval (inclusive) during which the trace data was
  195. // collected from the application.
  196. google.protobuf.Timestamp end_time = 6;
  197. // Optional. A filter against labels for the request.
  198. //
  199. // By default, searches use prefix matching. To specify exact match, prepend
  200. // a plus symbol (`+`) to the search term.
  201. // Multiple terms are ANDed. Syntax:
  202. //
  203. // * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root
  204. // span starts with `NAME_PREFIX`.
  205. // * `+root:NAME` or `+NAME`: Return traces where any root span's name is
  206. // exactly `NAME`.
  207. // * `span:NAME_PREFIX`: Return traces where any span starts with
  208. // `NAME_PREFIX`.
  209. // * `+span:NAME`: Return traces where any span's name is exactly
  210. // `NAME`.
  211. // * `latency:DURATION`: Return traces whose overall latency is
  212. // greater or equal to than `DURATION`. Accepted units are nanoseconds
  213. // (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For
  214. // example, `latency:24ms` returns traces whose overall latency
  215. // is greater than or equal to 24 milliseconds.
  216. // * `label:LABEL_KEY`: Return all traces containing the specified
  217. // label key (exact match, case-sensitive) regardless of the key:value
  218. // pair's value (including empty values).
  219. // * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified
  220. // label key (exact match, case-sensitive) whose value starts with
  221. // `VALUE_PREFIX`. Both a key and a value must be specified.
  222. // * `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair
  223. // exactly matching the specified text. Both a key and a value must be
  224. // specified.
  225. // * `method:VALUE`: Equivalent to `/http/method:VALUE`.
  226. // * `url:VALUE`: Equivalent to `/http/url:VALUE`.
  227. string filter = 7 [(google.api.field_behavior) = OPTIONAL];
  228. // Optional. Field used to sort the returned traces.
  229. // Can be one of the following:
  230. //
  231. // * `trace_id`
  232. // * `name` (`name` field of root span in the trace)
  233. // * `duration` (difference between `end_time` and `start_time` fields of
  234. // the root span)
  235. // * `start` (`start_time` field of the root span)
  236. //
  237. // Descending order can be specified by appending `desc` to the sort field
  238. // (for example, `name desc`).
  239. //
  240. // Only one sort field is permitted.
  241. string order_by = 8 [(google.api.field_behavior) = OPTIONAL];
  242. }
  243. // The response message for the `ListTraces` method.
  244. message ListTracesResponse {
  245. // List of trace records as specified by the view parameter.
  246. repeated Trace traces = 1;
  247. // If defined, indicates that there are more traces that match the request
  248. // and that this value should be passed to the next request to continue
  249. // retrieving additional traces.
  250. string next_page_token = 2;
  251. }
  252. // The request message for the `GetTrace` method.
  253. message GetTraceRequest {
  254. // Required. ID of the Cloud project where the trace data is stored.
  255. string project_id = 1 [(google.api.field_behavior) = REQUIRED];
  256. // Required. ID of the trace to return.
  257. string trace_id = 2 [(google.api.field_behavior) = REQUIRED];
  258. }
  259. // The request message for the `PatchTraces` method.
  260. message PatchTracesRequest {
  261. // Required. ID of the Cloud project where the trace data is stored.
  262. string project_id = 1 [(google.api.field_behavior) = REQUIRED];
  263. // Required. The body of the message.
  264. Traces traces = 2 [(google.api.field_behavior) = REQUIRED];
  265. }