profiler.proto 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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.cloudprofiler.v2;
  16. import "google/api/annotations.proto";
  17. import "google/protobuf/duration.proto";
  18. import "google/protobuf/field_mask.proto";
  19. import "google/api/client.proto";
  20. option csharp_namespace = "Google.Cloud.Profiler.V2";
  21. option go_package = "google.golang.org/genproto/googleapis/devtools/cloudprofiler/v2;cloudprofiler";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "ProfilerProto";
  24. option java_package = "com.google.devtools.cloudprofiler.v2";
  25. option php_namespace = "Google\\Cloud\\Profiler\\V2";
  26. option ruby_package = "Google::Cloud::Profiler::V2";
  27. // Manage the collection of continuous profiling data provided by profiling
  28. // agents running in the cloud or by an offline provider of profiling data.
  29. //
  30. // General guidelines:
  31. // * Profiles for a single deployment must be created in ascending time order.
  32. // * Profiles can be created in either online or offline mode, see below.
  33. service ProfilerService {
  34. option (google.api.default_host) = "cloudprofiler.googleapis.com";
  35. option (google.api.oauth_scopes) =
  36. "https://www.googleapis.com/auth/cloud-platform,"
  37. "https://www.googleapis.com/auth/monitoring,"
  38. "https://www.googleapis.com/auth/monitoring.write";
  39. // CreateProfile creates a new profile resource in the online mode.
  40. //
  41. // The server ensures that the new profiles are created at a constant rate per
  42. // deployment, so the creation request may hang for some time until the next
  43. // profile session is available.
  44. //
  45. // The request may fail with ABORTED error if the creation is not available
  46. // within ~1m, the response will indicate the duration of the backoff the
  47. // client should take before attempting creating a profile again. The backoff
  48. // duration is returned in google.rpc.RetryInfo extension on the response
  49. // status. To a gRPC client, the extension will be return as a
  50. // binary-serialized proto in the trailing metadata item named
  51. // "google.rpc.retryinfo-bin".
  52. rpc CreateProfile(CreateProfileRequest) returns (Profile) {
  53. option (google.api.http) = {
  54. post: "/v2/{parent=projects/*}/profiles"
  55. body: "*"
  56. };
  57. }
  58. // CreateOfflineProfile creates a new profile resource in the offline mode.
  59. // The client provides the profile to create along with the profile bytes, the
  60. // server records it.
  61. rpc CreateOfflineProfile(CreateOfflineProfileRequest) returns (Profile) {
  62. option (google.api.http) = {
  63. post: "/v2/{parent=projects/*}/profiles:createOffline"
  64. body: "profile"
  65. };
  66. }
  67. // UpdateProfile updates the profile bytes and labels on the profile resource
  68. // created in the online mode. Updating the bytes for profiles created in the
  69. // offline mode is currently not supported: the profile content must be
  70. // provided at the time of the profile creation.
  71. rpc UpdateProfile(UpdateProfileRequest) returns (Profile) {
  72. option (google.api.http) = {
  73. patch: "/v2/{profile.name=projects/*/profiles/*}"
  74. body: "profile"
  75. };
  76. }
  77. }
  78. // CreateProfileRequest describes a profile resource online creation request.
  79. // The deployment field must be populated. The profile_type specifies the list
  80. // of profile types supported by the agent. The creation call will hang until a
  81. // profile of one of these types needs to be collected.
  82. message CreateProfileRequest {
  83. // Parent project to create the profile in.
  84. string parent = 4;
  85. // Deployment details.
  86. Deployment deployment = 1;
  87. // One or more profile types that the agent is capable of providing.
  88. repeated ProfileType profile_type = 2;
  89. }
  90. // CreateOfflineProfileRequest describes a profile resource offline creation
  91. // request. Profile field must be set.
  92. message CreateOfflineProfileRequest {
  93. // Parent project to create the profile in.
  94. string parent = 1;
  95. // Contents of the profile to create.
  96. Profile profile = 2;
  97. }
  98. // UpdateProfileRequest contains the profile to update.
  99. message UpdateProfileRequest {
  100. // Profile to update
  101. Profile profile = 1;
  102. // Field mask used to specify the fields to be overwritten. Currently only
  103. // profile_bytes and labels fields are supported by UpdateProfile, so only
  104. // those fields can be specified in the mask. When no mask is provided, all
  105. // fields are overwritten.
  106. google.protobuf.FieldMask update_mask = 2;
  107. }
  108. // Profile resource.
  109. message Profile {
  110. // Output only. Opaque, server-assigned, unique ID for this profile.
  111. string name = 1;
  112. // Type of profile.
  113. // For offline mode, this must be specified when creating the profile. For
  114. // online mode it is assigned and returned by the server.
  115. ProfileType profile_type = 2;
  116. // Deployment this profile corresponds to.
  117. Deployment deployment = 3;
  118. // Duration of the profiling session.
  119. // Input (for the offline mode) or output (for the online mode).
  120. // The field represents requested profiling duration. It may slightly differ
  121. // from the effective profiling duration, which is recorded in the profile
  122. // data, in case the profiling can't be stopped immediately (e.g. in case
  123. // stopping the profiling is handled asynchronously).
  124. google.protobuf.Duration duration = 4;
  125. // Input only. Profile bytes, as a gzip compressed serialized proto, the
  126. // format is https://github.com/google/pprof/blob/master/proto/profile.proto.
  127. bytes profile_bytes = 5;
  128. // Input only. Labels associated to this specific profile. These labels will
  129. // get merged with the deployment labels for the final data set. See
  130. // documentation on deployment labels for validation rules and limits.
  131. map<string, string> labels = 6;
  132. }
  133. // Deployment contains the deployment identification information.
  134. message Deployment {
  135. // Project ID is the ID of a cloud project.
  136. // Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`.
  137. string project_id = 1;
  138. // Target is the service name used to group related deployments:
  139. // * Service name for GAE Flex / Standard.
  140. // * Cluster and container name for GKE.
  141. // * User-specified string for direct GCE profiling (e.g. Java).
  142. // * Job name for Dataflow.
  143. // Validation regex: `^[a-z]([-a-z0-9_.]{0,253}[a-z0-9])?$`.
  144. string target = 2;
  145. // Labels identify the deployment within the user universe and same target.
  146. // Validation regex for label names: `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`.
  147. // Value for an individual label must be <= 512 bytes, the total
  148. // size of all label names and values must be <= 1024 bytes.
  149. //
  150. // Label named "language" can be used to record the programming language of
  151. // the profiled deployment. The standard choices for the value include "java",
  152. // "go", "python", "ruby", "nodejs", "php", "dotnet".
  153. //
  154. // For deployments running on Google Cloud Platform, "zone" or "region" label
  155. // should be present describing the deployment location. An example of a zone
  156. // is "us-central1-a", an example of a region is "us-central1" or
  157. // "us-central".
  158. map<string, string> labels = 3;
  159. }
  160. // ProfileType is type of profiling data.
  161. // NOTE: the enumeration member names are used (in lowercase) as unique string
  162. // identifiers of profile types, so they must not be renamed.
  163. enum ProfileType {
  164. // Unspecified profile type.
  165. PROFILE_TYPE_UNSPECIFIED = 0;
  166. // Thread CPU time sampling.
  167. CPU = 1;
  168. // Wallclock time sampling. More expensive as stops all threads.
  169. WALL = 2;
  170. // In-use heap profile. Represents a snapshot of the allocations that are
  171. // live at the time of the profiling.
  172. HEAP = 3;
  173. // Single-shot collection of all thread stacks.
  174. THREADS = 4;
  175. // Synchronization contention profile.
  176. CONTENTION = 5;
  177. // Peak heap profile.
  178. PEAK_HEAP = 6;
  179. // Heap allocation profile. It represents the aggregation of all allocations
  180. // made over the duration of the profile. All allocations are included,
  181. // including those that might have been freed by the end of the profiling
  182. // interval. The profile is in particular useful for garbage collecting
  183. // languages to understand which parts of the code create most of the garbage
  184. // collection pressure to see if those can be optimized.
  185. HEAP_ALLOC = 7;
  186. }