trace.proto 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // Copyright (c) 2015, Google Inc.
  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/annotations.proto";
  17. import "google/protobuf/empty.proto";
  18. import "google/protobuf/timestamp.proto";
  19. option java_multiple_files = true;
  20. option java_outer_classname = "TraceProto";
  21. option java_package = "com.google.devtools.cloudtrace.v1";
  22. // This file describes an API for collecting and viewing traces and spans
  23. // within a trace. A Trace is a collection of spans corresponding to a single
  24. // operation or set of operations for an application. A span is an individual
  25. // timed event which forms a node of the trace tree. Spans for a single trace
  26. // may span multiple services.
  27. service TraceService {
  28. // Returns of a list of traces that match the specified filter conditions.
  29. rpc ListTraces(ListTracesRequest) returns (ListTracesResponse) {
  30. option (google.api.http) = { get: "/v1/projects/{project_id}/traces" };
  31. }
  32. // Gets a single trace by its ID.
  33. rpc GetTrace(GetTraceRequest) returns (Trace) {
  34. option (google.api.http) = { get: "/v1/projects/{project_id}/traces/{trace_id}" };
  35. }
  36. // Sends new traces to Cloud Trace or updates existing traces. If the ID of
  37. // a trace that you send matches that of an existing trace, any fields
  38. // in the existing trace and its spans are overwritten by the provided values,
  39. // and any new fields provided are merged with the existing trace data. If the
  40. // ID does not match, a new trace is created.
  41. rpc PatchTraces(PatchTracesRequest) returns (google.protobuf.Empty) {
  42. option (google.api.http) = { patch: "/v1/projects/{project_id}/traces" body: "traces" };
  43. }
  44. }
  45. // A trace describes how long it takes for an application to perform an
  46. // operation. It consists of a set of spans, each of which represent a single
  47. // timed event within the operation.
  48. message Trace {
  49. // Project ID of the Cloud project where the trace data is stored.
  50. string project_id = 1;
  51. // Globally unique identifier for the trace. This identifier is a 128-bit
  52. // numeric value formatted as a 32-byte hex string.
  53. string trace_id = 2;
  54. // Collection of spans in the trace.
  55. repeated TraceSpan spans = 3;
  56. }
  57. // List of new or updated traces.
  58. message Traces {
  59. // List of traces.
  60. repeated Trace traces = 1;
  61. }
  62. // A span represents a single timed event within a trace. Spans can be nested
  63. // and form a trace tree. Often, a trace contains a root span that describes the
  64. // end-to-end latency of an operation and, optionally, one or more subspans for
  65. // its suboperations. Spans do not need to be contiguous. There may be gaps
  66. // between spans in a trace.
  67. message TraceSpan {
  68. // Type of span. Can be used to specify additional relationships between spans
  69. // in addition to a parent/child relationship.
  70. enum SpanKind {
  71. // Unspecified.
  72. SPAN_KIND_UNSPECIFIED = 0;
  73. // Indicates that the span covers server-side handling of an RPC or other
  74. // remote network request.
  75. RPC_SERVER = 1;
  76. // Indicates that the span covers the client-side wrapper around an RPC or
  77. // other remote request.
  78. RPC_CLIENT = 2;
  79. }
  80. // Identifier for the span. This identifier must be unique within a trace.
  81. fixed64 span_id = 1;
  82. // Distinguishes between spans generated in a particular context. For example,
  83. // two spans with the same name may be distinguished using `RPC_CLIENT`
  84. // and `RPC_SERVER` to identify queueing latency associated with the span.
  85. SpanKind kind = 2;
  86. // Name of the trace. The trace name is sanitized and displayed in the
  87. // Cloud Trace tool in the Google Developers Console. The name may be a method
  88. // name or some other per-call site name. For the same executable and the same
  89. // call point, a best practice is to use a consistent name, which makes it
  90. // easier to correlate cross-trace spans.
  91. string name = 3;
  92. // Start time of the span in nanoseconds from the UNIX epoch.
  93. google.protobuf.Timestamp start_time = 4;
  94. // End time of the span in nanoseconds from the UNIX epoch.
  95. google.protobuf.Timestamp end_time = 5;
  96. // ID of the parent span, if any. Optional.
  97. fixed64 parent_span_id = 6;
  98. // Collection of labels associated with the span.
  99. map<string, string> labels = 7;
  100. }
  101. // The request message for the `ListTraces` method. All fields are required
  102. // unless specified.
  103. message ListTracesRequest {
  104. // Type of data returned for traces in the list.
  105. enum ViewType {
  106. // Default is `MINIMAL` if unspecified.
  107. VIEW_TYPE_UNSPECIFIED = 0;
  108. // Minimal view of the trace record that contains only the project
  109. // and trace IDs.
  110. MINIMAL = 1;
  111. // Root span view of the trace record that returns the root spans along
  112. // with the minimal trace data.
  113. ROOTSPAN = 2;
  114. // Complete view of the trace record that contains the actual trace data.
  115. // This is equivalent to calling the REST `get` or RPC `GetTrace` method
  116. // using the ID of each listed trace.
  117. COMPLETE = 3;
  118. }
  119. // ID of the Cloud project where the trace data is stored.
  120. string project_id = 1;
  121. // Type of data returned for traces in the list. Optional. Default is
  122. // `MINIMAL`.
  123. ViewType view = 2;
  124. // Maximum number of traces to return. If not specified or <= 0, the
  125. // implementation selects a reasonable value. The implementation may
  126. // return fewer traces than the requested page size. Optional.
  127. int32 page_size = 3;
  128. // Token identifying the page of results to return. If provided, use the
  129. // value of the `next_page_token` field from a previous request. Optional.
  130. string page_token = 4;
  131. // End of the time interval (inclusive) during which the trace data was
  132. // collected from the application.
  133. google.protobuf.Timestamp start_time = 5;
  134. // Start of the time interval (inclusive) during which the trace data was
  135. // collected from the application.
  136. google.protobuf.Timestamp end_time = 6;
  137. // An optional filter for the request.
  138. string filter = 7;
  139. // Field used to sort the returned traces. Optional.
  140. // Can be one of the following:
  141. //
  142. // * `trace_id`
  143. // * `name` (`name` field of root span in the trace)
  144. // * `duration` (difference between `end_time` and `start_time` fields of
  145. // the root span)
  146. // * `start` (`start_time` field of the root span)
  147. //
  148. // Descending order can be specified by appending `desc` to the sort field
  149. // (for example, `name desc`).
  150. //
  151. // Only one sort field is permitted.
  152. string order_by = 8;
  153. }
  154. // The response message for the `ListTraces` method.
  155. message ListTracesResponse {
  156. // List of trace records returned.
  157. repeated Trace traces = 1;
  158. // If defined, indicates that there are more traces that match the request
  159. // and that this value should be passed to the next request to continue
  160. // retrieving additional traces.
  161. string next_page_token = 2;
  162. }
  163. // The request message for the `GetTrace` method.
  164. message GetTraceRequest {
  165. // ID of the Cloud project where the trace data is stored.
  166. string project_id = 1;
  167. // ID of the trace to return.
  168. string trace_id = 2;
  169. }
  170. // The request message for the `PatchTraces` method.
  171. message PatchTracesRequest {
  172. // ID of the Cloud project where the trace data is stored.
  173. string project_id = 1;
  174. // The body of the message.
  175. Traces traces = 2;
  176. }