trace.proto 12 KB

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