1// Copyright 2023 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 15syntax = "proto3"; 16 17package google.devtools.cloudprofiler.v2; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/protobuf/duration.proto"; 24import "google/protobuf/field_mask.proto"; 25import "google/protobuf/timestamp.proto"; 26 27option csharp_namespace = "Google.Cloud.Profiler.V2"; 28option go_package = "cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb;cloudprofilerpb"; 29option java_multiple_files = true; 30option java_outer_classname = "ProfilerProto"; 31option java_package = "com.google.devtools.cloudprofiler.v2"; 32option php_namespace = "Google\\Cloud\\Profiler\\V2"; 33option ruby_package = "Google::Cloud::Profiler::V2"; 34 35// Manage the collection of continuous profiling data provided by profiling 36// agents running in the cloud or by an offline provider of profiling data. 37// 38// __The APIs listed in this service are intended for use within our profiler 39// agents only.__ 40service ProfilerService { 41 option (google.api.default_host) = "cloudprofiler.googleapis.com"; 42 option (google.api.oauth_scopes) = 43 "https://www.googleapis.com/auth/cloud-platform," 44 "https://www.googleapis.com/auth/monitoring," 45 "https://www.googleapis.com/auth/monitoring.write"; 46 47 // CreateProfile creates a new profile resource in the online mode. 48 // 49 // _Direct use of this API is discouraged, please use a [supported 50 // profiler 51 // agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) 52 // instead for profile collection._ 53 // 54 // The server ensures that the new profiles are created at a constant rate per 55 // deployment, so the creation request may hang for some time until the next 56 // profile session is available. 57 // 58 // The request may fail with ABORTED error if the creation is not available 59 // within ~1m, the response will indicate the duration of the backoff the 60 // client should take before attempting creating a profile again. The backoff 61 // duration is returned in google.rpc.RetryInfo extension on the response 62 // status. To a gRPC client, the extension will be return as a 63 // binary-serialized proto in the trailing metadata item named 64 // "google.rpc.retryinfo-bin". 65 // 66 rpc CreateProfile(CreateProfileRequest) returns (Profile) { 67 option (google.api.http) = { 68 post: "/v2/{parent=projects/*}/profiles" 69 body: "*" 70 }; 71 } 72 73 // CreateOfflineProfile creates a new profile resource in the offline 74 // mode. The client provides the profile to create along with the profile 75 // bytes, the server records it. 76 // 77 // _Direct use of this API is discouraged, please use a [supported 78 // profiler 79 // agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) 80 // instead for profile collection._ 81 rpc CreateOfflineProfile(CreateOfflineProfileRequest) returns (Profile) { 82 option (google.api.http) = { 83 post: "/v2/{parent=projects/*}/profiles:createOffline" 84 body: "profile" 85 }; 86 option (google.api.method_signature) = "parent,profile"; 87 } 88 89 // UpdateProfile updates the profile bytes and labels on the profile resource 90 // created in the online mode. Updating the bytes for profiles created in the 91 // offline mode is currently not supported: the profile content must be 92 // provided at the time of the profile creation. 93 // 94 // _Direct use of this API is discouraged, please use a [supported 95 // profiler 96 // agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) 97 // instead for profile collection._ 98 rpc UpdateProfile(UpdateProfileRequest) returns (Profile) { 99 option (google.api.http) = { 100 patch: "/v2/{profile.name=projects/*/profiles/*}" 101 body: "profile" 102 }; 103 option (google.api.method_signature) = "profile,update_mask"; 104 } 105} 106 107// Service allows existing Cloud Profiler customers to export their profile data 108// out of Google Cloud. 109service ExportService { 110 option (google.api.default_host) = "cloudprofiler.googleapis.com"; 111 option (google.api.oauth_scopes) = 112 "https://www.googleapis.com/auth/cloud-platform," 113 "https://www.googleapis.com/auth/monitoring," 114 "https://www.googleapis.com/auth/monitoring.write"; 115 116 // Lists profiles which have been collected so far and for which the caller 117 // has permission to view. 118 rpc ListProfiles(ListProfilesRequest) returns (ListProfilesResponse) { 119 option (google.api.http) = { 120 get: "/v2/{parent=projects/*}/profiles" 121 }; 122 option (google.api.method_signature) = "parent"; 123 } 124} 125 126// CreateProfileRequest describes a profile resource online creation request. 127// The deployment field must be populated. The profile_type specifies the list 128// of profile types supported by the agent. The creation call will hang until a 129// profile of one of these types needs to be collected. 130// 131message CreateProfileRequest { 132 // Parent project to create the profile in. 133 string parent = 4 [(google.api.resource_reference) = { 134 type: "cloudresourcemanager.googleapis.com/Project" 135 }]; 136 137 // Deployment details. 138 Deployment deployment = 1; 139 140 // One or more profile types that the agent is capable of providing. 141 repeated ProfileType profile_type = 2; 142} 143 144// CreateOfflineProfileRequest describes a profile resource offline creation 145// request. 146message CreateOfflineProfileRequest { 147 // Parent project to create the profile in. 148 string parent = 1 [(google.api.resource_reference) = { 149 type: "cloudresourcemanager.googleapis.com/Project" 150 }]; 151 152 // Contents of the profile to create. 153 Profile profile = 2; 154} 155 156// UpdateProfileRequest contains the profile to update. 157message UpdateProfileRequest { 158 // Profile to update. 159 Profile profile = 1; 160 161 // Field mask used to specify the fields to be overwritten. Currently only 162 // profile_bytes and labels fields are supported by UpdateProfile, so only 163 // those fields can be specified in the mask. When no mask is provided, all 164 // fields are overwritten. 165 google.protobuf.FieldMask update_mask = 2; 166} 167 168// Profile resource. 169message Profile { 170 option (google.api.resource) = { 171 type: "cloudprofiler.googleapis.com/Profile" 172 pattern: "projects/{project}/profiles/{profile}" 173 }; 174 175 // Output only. Opaque, server-assigned, unique ID for this profile. 176 string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 177 178 // Type of profile. 179 // For offline mode, this must be specified when creating the profile. For 180 // online mode it is assigned and returned by the server. 181 ProfileType profile_type = 2; 182 183 // Deployment this profile corresponds to. 184 Deployment deployment = 3; 185 186 // Duration of the profiling session. 187 // Input (for the offline mode) or output (for the online mode). 188 // The field represents requested profiling duration. It may slightly differ 189 // from the effective profiling duration, which is recorded in the profile 190 // data, in case the profiling can't be stopped immediately (e.g. in case 191 // stopping the profiling is handled asynchronously). 192 google.protobuf.Duration duration = 4; 193 194 // Input only. Profile bytes, as a gzip compressed serialized proto, the 195 // format is https://github.com/google/pprof/blob/master/proto/profile.proto. 196 bytes profile_bytes = 5 [(google.api.field_behavior) = INPUT_ONLY]; 197 198 // Input only. Labels associated to this specific profile. These labels will 199 // get merged with the deployment labels for the final data set. See 200 // documentation on deployment labels for validation rules and limits. 201 map<string, string> labels = 6 [(google.api.field_behavior) = INPUT_ONLY]; 202 203 // Output only. Start time for the profile. 204 // This output is only present in response from the ListProfiles method. 205 google.protobuf.Timestamp start_time = 7 206 [(google.api.field_behavior) = OUTPUT_ONLY]; 207} 208 209// Deployment contains the deployment identification information. 210message Deployment { 211 // Project ID is the ID of a cloud project. 212 // Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. 213 string project_id = 1; 214 215 // Target is the service name used to group related deployments: 216 // * Service name for App Engine Flex / Standard. 217 // * Cluster and container name for GKE. 218 // * User-specified string for direct Compute Engine profiling (e.g. Java). 219 // * Job name for Dataflow. 220 // Validation regex: `^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$`. 221 string target = 2; 222 223 // Labels identify the deployment within the user universe and same target. 224 // Validation regex for label names: `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`. 225 // Value for an individual label must be <= 512 bytes, the total 226 // size of all label names and values must be <= 1024 bytes. 227 // 228 // Label named "language" can be used to record the programming language of 229 // the profiled deployment. The standard choices for the value include "java", 230 // "go", "python", "ruby", "nodejs", "php", "dotnet". 231 // 232 // For deployments running on Google Cloud Platform, "zone" or "region" label 233 // should be present describing the deployment location. An example of a zone 234 // is "us-central1-a", an example of a region is "us-central1" or 235 // "us-central". 236 map<string, string> labels = 3; 237} 238 239// ProfileType is type of profiling data. 240// NOTE: the enumeration member names are used (in lowercase) as unique string 241// identifiers of profile types, so they must not be renamed. 242enum ProfileType { 243 // Unspecified profile type. 244 PROFILE_TYPE_UNSPECIFIED = 0; 245 246 // Thread CPU time sampling. 247 CPU = 1; 248 249 // Wallclock time sampling. More expensive as stops all threads. 250 WALL = 2; 251 252 // In-use heap profile. Represents a snapshot of the allocations that are 253 // live at the time of the profiling. 254 HEAP = 3; 255 256 // Single-shot collection of all thread stacks. 257 THREADS = 4; 258 259 // Synchronization contention profile. 260 CONTENTION = 5; 261 262 // Peak heap profile. 263 PEAK_HEAP = 6; 264 265 // Heap allocation profile. It represents the aggregation of all allocations 266 // made over the duration of the profile. All allocations are included, 267 // including those that might have been freed by the end of the profiling 268 // interval. The profile is in particular useful for garbage collecting 269 // languages to understand which parts of the code create most of the garbage 270 // collection pressure to see if those can be optimized. 271 HEAP_ALLOC = 7; 272} 273 274// ListProfilesRequest contains request parameters for listing profiles for 275// deployments in projects which the user has permissions to view. 276message ListProfilesRequest { 277 // Required. The parent, which owns this collection of profiles. 278 // Format: projects/{user_project_id} 279 string parent = 1 [ 280 (google.api.field_behavior) = REQUIRED, 281 (google.api.resource_reference) = { 282 type: "cloudresourcemanager.googleapis.com/Project" 283 } 284 ]; 285 286 // The maximum number of items to return. 287 // Default page_size is 1000. 288 // Max limit is 1000. 289 int32 page_size = 2; 290 291 // The token to continue pagination and get profiles from a particular page. 292 // When paginating, all other parameters provided to `ListProfiles` must match 293 // the call that provided the page token. 294 string page_token = 3; 295} 296 297// ListProfileResponse contains the list of collected profiles for deployments 298// in projects which the user has permissions to view. 299message ListProfilesResponse { 300 // List of profiles fetched. 301 repeated Profile profiles = 1; 302 303 // Token to receive the next page of results. 304 // This field maybe empty if there are no more profiles to fetch. 305 string next_page_token = 2; 306 307 // Number of profiles that were skipped in the current page since they were 308 // not able to be fetched successfully. This should typically be zero. A 309 // non-zero value may indicate a transient failure, in which case if the 310 // number is too high for your use case, the call may be retried. 311 int32 skipped_profiles = 3; 312} 313