cloudprofiler
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package cloudprofiler provides access to the Cloud Profiler API.
For product documentation, see:https://cloud.google.com/profiler/
Library status¶
These client libraries are officially supported by Google. However, thislibrary is considered complete and is in maintenance mode. This meansthat we will address critical bugs and security issues but will not addany new features.
When possible, we recommend using our newer[Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)that are still actively being worked and iterated on.
Creating a client¶
Usage example:
import "google.golang.org/api/cloudprofiler/v2"...ctx := context.Background()cloudprofilerService, err := cloudprofiler.NewService(ctx)
In this example, Google Application Default Credentials are used forauthentication. For information on how to create and obtain ApplicationDefault Credentials, seehttps://developers.google.com/identity/protocols/application-default-credentials.
Other authentication options¶
By default, all available scopes (see "Constants") are used to authenticate.To restrict scopes, usegoogle.golang.org/api/option.WithScopes:
cloudprofilerService, err := cloudprofiler.NewService(ctx, option.WithScopes(cloudprofiler.MonitoringWriteScope))
To use an API key for authentication (note: some APIs do not support APIkeys), usegoogle.golang.org/api/option.WithAPIKey:
cloudprofilerService, err := cloudprofiler.NewService(ctx, option.WithAPIKey("AIza..."))To use an OAuth token (e.g., a user token obtained via a three-legged OAuthflow, usegoogle.golang.org/api/option.WithTokenSource:
config := &oauth2.Config{...}// ...token, err := config.Exchange(ctx, ...)cloudprofilerService, err := cloudprofiler.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))Seegoogle.golang.org/api/option.ClientOption for details on options.
Index¶
- Constants
- type CreateProfileRequest
- type Deployment
- type ListProfilesResponse
- type Profile
- type ProjectsProfilesCreateCall
- func (c *ProjectsProfilesCreateCall) Context(ctx context.Context) *ProjectsProfilesCreateCall
- func (c *ProjectsProfilesCreateCall) Do(opts ...googleapi.CallOption) (*Profile, error)
- func (c *ProjectsProfilesCreateCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateCall
- func (c *ProjectsProfilesCreateCall) Header() http.Header
- type ProjectsProfilesCreateOfflineCall
- func (c *ProjectsProfilesCreateOfflineCall) Context(ctx context.Context) *ProjectsProfilesCreateOfflineCall
- func (c *ProjectsProfilesCreateOfflineCall) Do(opts ...googleapi.CallOption) (*Profile, error)
- func (c *ProjectsProfilesCreateOfflineCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateOfflineCall
- func (c *ProjectsProfilesCreateOfflineCall) Header() http.Header
- type ProjectsProfilesListCall
- func (c *ProjectsProfilesListCall) Context(ctx context.Context) *ProjectsProfilesListCall
- func (c *ProjectsProfilesListCall) Do(opts ...googleapi.CallOption) (*ListProfilesResponse, error)
- func (c *ProjectsProfilesListCall) Fields(s ...googleapi.Field) *ProjectsProfilesListCall
- func (c *ProjectsProfilesListCall) Header() http.Header
- func (c *ProjectsProfilesListCall) IfNoneMatch(entityTag string) *ProjectsProfilesListCall
- func (c *ProjectsProfilesListCall) PageSize(pageSize int64) *ProjectsProfilesListCall
- func (c *ProjectsProfilesListCall) PageToken(pageToken string) *ProjectsProfilesListCall
- func (c *ProjectsProfilesListCall) Pages(ctx context.Context, f func(*ListProfilesResponse) error) error
- type ProjectsProfilesPatchCall
- func (c *ProjectsProfilesPatchCall) Context(ctx context.Context) *ProjectsProfilesPatchCall
- func (c *ProjectsProfilesPatchCall) Do(opts ...googleapi.CallOption) (*Profile, error)
- func (c *ProjectsProfilesPatchCall) Fields(s ...googleapi.Field) *ProjectsProfilesPatchCall
- func (c *ProjectsProfilesPatchCall) Header() http.Header
- func (c *ProjectsProfilesPatchCall) UpdateMask(updateMask string) *ProjectsProfilesPatchCall
- type ProjectsProfilesService
- func (r *ProjectsProfilesService) Create(parent string, createprofilerequest *CreateProfileRequest) *ProjectsProfilesCreateCall
- func (r *ProjectsProfilesService) CreateOffline(parent string, profile *Profile) *ProjectsProfilesCreateOfflineCall
- func (r *ProjectsProfilesService) List(parent string) *ProjectsProfilesListCall
- func (r *ProjectsProfilesService) Patch(name string, profile *Profile) *ProjectsProfilesPatchCall
- type ProjectsService
- type Service
Constants¶
const (// See, edit, configure, and delete your Google Cloud data and see the email// address for your Google Account.CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"// View and write monitoring data for all of your Google and third-party Cloud// and API projectsMonitoringScope = "https://www.googleapis.com/auth/monitoring"// Publish metric data to your Google Cloud projectsMonitoringWriteScope = "https://www.googleapis.com/auth/monitoring.write")
OAuth2 scopes used by this API.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeCreateProfileRequest¶
type CreateProfileRequest struct {// Deployment: Deployment details.Deployment *Deployment `json:"deployment,omitempty"`// ProfileType: One or more profile types that the agent is capable of// providing.//// Possible values:// "PROFILE_TYPE_UNSPECIFIED" - Unspecified profile type.// "CPU" - Thread CPU time sampling.// "WALL" - Wallclock time sampling. More expensive as stops all threads.// "HEAP" - In-use heap profile. Represents a snapshot of the allocations// that are live at the time of the profiling.// "THREADS" - Single-shot collection of all thread stacks.// "CONTENTION" - Synchronization contention profile.// "PEAK_HEAP" - Peak heap profile.// "HEAP_ALLOC" - Heap allocation profile. It represents the aggregation of// all allocations made over the duration of the profile. All allocations are// included, including those that might have been freed by the end of the// profiling interval. The profile is in particular useful for garbage// collecting languages to understand which parts of the code create most of// the garbage collection pressure to see if those can be optimized.ProfileType []string `json:"profileType,omitempty"`// ForceSendFields is a list of field names (e.g. "Deployment") to// unconditionally include in API requests. By default, fields with empty or// default values are omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more// details.ForceSendFields []string `json:"-"`// NullFields is a list of field names (e.g. "Deployment") to include in API// requests with the JSON null value. By default, fields with empty values are// omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.NullFields []string `json:"-"`}CreateProfileRequest: CreateProfileRequest describes a profile resourceonline creation request. The deployment field must be populated. Theprofile_type specifies the list of profile types supported by the agent. Thecreation call will hang until a profile of one of these types needs to becollected.
func (CreateProfileRequest)MarshalJSON¶
func (sCreateProfileRequest) MarshalJSON() ([]byte,error)
typeDeployment¶
type Deployment struct {// Labels: Labels identify the deployment within the user universe and same// target. Validation regex for label names: `^a-z0-9// ([a-z0-9-]{0,61}[a-z0-9])?$`. Value for an individual label must be <= 512// bytes, the total size of all label names and values must be <= 1024 bytes.// Label named "language" can be used to record the programming language of the// profiled deployment. The standard choices for the value include "java",// "go", "python", "ruby", "nodejs", "php", "dotnet". For deployments running// on Google Cloud Platform, "zone" or "region" label should be present// describing the deployment location. An example of a zone is "us-central1-a",// an example of a region is "us-central1" or "us-central".Labels map[string]string `json:"labels,omitempty"`// ProjectId: Project ID is the ID of a cloud project. Validation regex:// `^a-z{4,61}[a-z0-9]$`.ProjectIdstring `json:"projectId,omitempty"`// Target: Target is the service name used to group related deployments: *// Service name for App Engine Flex / Standard. * Cluster and container name// for GKE. * User-specified string for direct Compute Engine profiling (e.g.// Java). * Job name for Dataflow. Validation regex: `^a-z0-9// ([-a-z0-9_.]{0,253}[a-z0-9])?$`.Targetstring `json:"target,omitempty"`// ForceSendFields is a list of field names (e.g. "Labels") to unconditionally// include in API requests. By default, fields with empty or default values are// omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more// details.ForceSendFields []string `json:"-"`// NullFields is a list of field names (e.g. "Labels") to include in API// requests with the JSON null value. By default, fields with empty values are// omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.NullFields []string `json:"-"`}Deployment: Deployment contains the deployment identification information.
func (Deployment)MarshalJSON¶
func (sDeployment) MarshalJSON() ([]byte,error)
typeListProfilesResponse¶added inv0.155.0
type ListProfilesResponse struct {// NextPageToken: Token to receive the next page of results. This field maybe// empty if there are no more profiles to fetch.NextPageTokenstring `json:"nextPageToken,omitempty"`// Profiles: List of profiles fetched.Profiles []*Profile `json:"profiles,omitempty"`// SkippedProfiles: Number of profiles that were skipped in the current page// since they were not able to be fetched successfully. This should typically// be zero. A non-zero value may indicate a transient failure, in which case if// the number is too high for your use case, the call may be retried.SkippedProfilesint64 `json:"skippedProfiles,omitempty"`// ServerResponse contains the HTTP response code and headers from the server.googleapi.ServerResponse `json:"-"`// ForceSendFields is a list of field names (e.g. "NextPageToken") to// unconditionally include in API requests. By default, fields with empty or// default values are omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more// details.ForceSendFields []string `json:"-"`// NullFields is a list of field names (e.g. "NextPageToken") to include in API// requests with the JSON null value. By default, fields with empty values are// omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.NullFields []string `json:"-"`}ListProfilesResponse: ListProfileResponse contains the list of collectedprofiles for deployments in projects which the user has permissions to view.
func (ListProfilesResponse)MarshalJSON¶added inv0.155.0
func (sListProfilesResponse) MarshalJSON() ([]byte,error)
typeProfile¶
type Profile struct {// Deployment: Deployment this profile corresponds to.Deployment *Deployment `json:"deployment,omitempty"`// Duration: Duration of the profiling session. Input (for the offline mode) or// output (for the online mode). The field represents requested profiling// duration. It may slightly differ from the effective profiling duration,// which is recorded in the profile data, in case the profiling can't be// stopped immediately (e.g. in case stopping the profiling is handled// asynchronously).Durationstring `json:"duration,omitempty"`// Labels: Input only. Labels associated to this specific profile. These labels// will get merged with the deployment labels for the final data set. See// documentation on deployment labels for validation rules and limits.Labels map[string]string `json:"labels,omitempty"`// Name: Output only. Opaque, server-assigned, unique ID for this profile.Namestring `json:"name,omitempty"`// ProfileBytes: Input only. Profile bytes, as a gzip compressed serialized// proto, the format is//https://github.com/google/pprof/blob/master/proto/profile.proto.ProfileBytesstring `json:"profileBytes,omitempty"`// ProfileType: Type of profile. For offline mode, this must be specified when// creating the profile. For online mode it is assigned and returned by the// server.//// Possible values:// "PROFILE_TYPE_UNSPECIFIED" - Unspecified profile type.// "CPU" - Thread CPU time sampling.// "WALL" - Wallclock time sampling. More expensive as stops all threads.// "HEAP" - In-use heap profile. Represents a snapshot of the allocations// that are live at the time of the profiling.// "THREADS" - Single-shot collection of all thread stacks.// "CONTENTION" - Synchronization contention profile.// "PEAK_HEAP" - Peak heap profile.// "HEAP_ALLOC" - Heap allocation profile. It represents the aggregation of// all allocations made over the duration of the profile. All allocations are// included, including those that might have been freed by the end of the// profiling interval. The profile is in particular useful for garbage// collecting languages to understand which parts of the code create most of// the garbage collection pressure to see if those can be optimized.ProfileTypestring `json:"profileType,omitempty"`// StartTime: Output only. Start time for the profile. This output is only// present in response from the ListProfiles method.StartTimestring `json:"startTime,omitempty"`// ServerResponse contains the HTTP response code and headers from the server.googleapi.ServerResponse `json:"-"`// ForceSendFields is a list of field names (e.g. "Deployment") to// unconditionally include in API requests. By default, fields with empty or// default values are omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more// details.ForceSendFields []string `json:"-"`// NullFields is a list of field names (e.g. "Deployment") to include in API// requests with the JSON null value. By default, fields with empty values are// omitted from API requests. See//https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.NullFields []string `json:"-"`}Profile: Profile resource.
func (Profile)MarshalJSON¶
typeProjectsProfilesCreateCall¶
type ProjectsProfilesCreateCall struct {// contains filtered or unexported fields}func (*ProjectsProfilesCreateCall)Context¶
func (c *ProjectsProfilesCreateCall) Context(ctxcontext.Context) *ProjectsProfilesCreateCall
Context sets the context to be used in this call's Do method.
func (*ProjectsProfilesCreateCall)Do¶
func (c *ProjectsProfilesCreateCall) Do(opts ...googleapi.CallOption) (*Profile,error)
Do executes the "cloudprofiler.projects.profiles.create" call.Any non-2xx status code is an error. Response headers are in either*Profile.ServerResponse.Header or (if a response was returned at all) inerror.(*googleapi.Error).Header. Use googleapi.IsNotModified to checkwhether the returned error was because http.StatusNotModified was returned.
func (*ProjectsProfilesCreateCall)Fields¶
func (c *ProjectsProfilesCreateCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateCall
Fields allows partial responses to be retrieved. Seehttps://developers.google.com/gdata/docs/2.0/basics#PartialResponse for moredetails.
func (*ProjectsProfilesCreateCall)Header¶
func (c *ProjectsProfilesCreateCall) Header()http.Header
Header returns a http.Header that can be modified by the caller to addheaders to the request.
typeProjectsProfilesCreateOfflineCall¶
type ProjectsProfilesCreateOfflineCall struct {// contains filtered or unexported fields}func (*ProjectsProfilesCreateOfflineCall)Context¶
func (c *ProjectsProfilesCreateOfflineCall) Context(ctxcontext.Context) *ProjectsProfilesCreateOfflineCall
Context sets the context to be used in this call's Do method.
func (*ProjectsProfilesCreateOfflineCall)Do¶
func (c *ProjectsProfilesCreateOfflineCall) Do(opts ...googleapi.CallOption) (*Profile,error)
Do executes the "cloudprofiler.projects.profiles.createOffline" call.Any non-2xx status code is an error. Response headers are in either*Profile.ServerResponse.Header or (if a response was returned at all) inerror.(*googleapi.Error).Header. Use googleapi.IsNotModified to checkwhether the returned error was because http.StatusNotModified was returned.
func (*ProjectsProfilesCreateOfflineCall)Fields¶
func (c *ProjectsProfilesCreateOfflineCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateOfflineCall
Fields allows partial responses to be retrieved. Seehttps://developers.google.com/gdata/docs/2.0/basics#PartialResponse for moredetails.
func (*ProjectsProfilesCreateOfflineCall)Header¶
func (c *ProjectsProfilesCreateOfflineCall) Header()http.Header
Header returns a http.Header that can be modified by the caller to addheaders to the request.
typeProjectsProfilesListCall¶added inv0.155.0
type ProjectsProfilesListCall struct {// contains filtered or unexported fields}func (*ProjectsProfilesListCall)Context¶added inv0.155.0
func (c *ProjectsProfilesListCall) Context(ctxcontext.Context) *ProjectsProfilesListCall
Context sets the context to be used in this call's Do method.
func (*ProjectsProfilesListCall)Do¶added inv0.155.0
func (c *ProjectsProfilesListCall) Do(opts ...googleapi.CallOption) (*ListProfilesResponse,error)
Do executes the "cloudprofiler.projects.profiles.list" call.Any non-2xx status code is an error. Response headers are in either*ListProfilesResponse.ServerResponse.Header or (if a response was returnedat all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified tocheck whether the returned error was because http.StatusNotModified wasreturned.
func (*ProjectsProfilesListCall)Fields¶added inv0.155.0
func (c *ProjectsProfilesListCall) Fields(s ...googleapi.Field) *ProjectsProfilesListCall
Fields allows partial responses to be retrieved. Seehttps://developers.google.com/gdata/docs/2.0/basics#PartialResponse for moredetails.
func (*ProjectsProfilesListCall)Header¶added inv0.155.0
func (c *ProjectsProfilesListCall) Header()http.Header
Header returns a http.Header that can be modified by the caller to addheaders to the request.
func (*ProjectsProfilesListCall)IfNoneMatch¶added inv0.155.0
func (c *ProjectsProfilesListCall) IfNoneMatch(entityTagstring) *ProjectsProfilesListCall
IfNoneMatch sets an optional parameter which makes the operation fail if theobject's ETag matches the given value. This is useful for getting updatesonly after the object has changed since the last request.
func (*ProjectsProfilesListCall)PageSize¶added inv0.155.0
func (c *ProjectsProfilesListCall) PageSize(pageSizeint64) *ProjectsProfilesListCall
PageSize sets the optional parameter "pageSize": The maximum number of itemsto return. Default page_size is 1000. Max limit is 1000.
func (*ProjectsProfilesListCall)PageToken¶added inv0.155.0
func (c *ProjectsProfilesListCall) PageToken(pageTokenstring) *ProjectsProfilesListCall
PageToken sets the optional parameter "pageToken": The token to continuepagination and get profiles from a particular page. When paginating, allother parameters provided to `ListProfiles` must match the call thatprovided the page token.
func (*ProjectsProfilesListCall)Pages¶added inv0.155.0
func (c *ProjectsProfilesListCall) Pages(ctxcontext.Context, f func(*ListProfilesResponse)error)error
Pages invokes f for each page of results.A non-nil error returned from f will halt the iteration.The provided context supersedes any context provided to the Context method.
typeProjectsProfilesPatchCall¶
type ProjectsProfilesPatchCall struct {// contains filtered or unexported fields}func (*ProjectsProfilesPatchCall)Context¶
func (c *ProjectsProfilesPatchCall) Context(ctxcontext.Context) *ProjectsProfilesPatchCall
Context sets the context to be used in this call's Do method.
func (*ProjectsProfilesPatchCall)Do¶
func (c *ProjectsProfilesPatchCall) Do(opts ...googleapi.CallOption) (*Profile,error)
Do executes the "cloudprofiler.projects.profiles.patch" call.Any non-2xx status code is an error. Response headers are in either*Profile.ServerResponse.Header or (if a response was returned at all) inerror.(*googleapi.Error).Header. Use googleapi.IsNotModified to checkwhether the returned error was because http.StatusNotModified was returned.
func (*ProjectsProfilesPatchCall)Fields¶
func (c *ProjectsProfilesPatchCall) Fields(s ...googleapi.Field) *ProjectsProfilesPatchCall
Fields allows partial responses to be retrieved. Seehttps://developers.google.com/gdata/docs/2.0/basics#PartialResponse for moredetails.
func (*ProjectsProfilesPatchCall)Header¶
func (c *ProjectsProfilesPatchCall) Header()http.Header
Header returns a http.Header that can be modified by the caller to addheaders to the request.
func (*ProjectsProfilesPatchCall)UpdateMask¶
func (c *ProjectsProfilesPatchCall) UpdateMask(updateMaskstring) *ProjectsProfilesPatchCall
UpdateMask sets the optional parameter "updateMask": Field mask used tospecify the fields to be overwritten. Currently only profile_bytes andlabels fields are supported by UpdateProfile, so only those fields can bespecified in the mask. When no mask is provided, all fields are overwritten.
typeProjectsProfilesService¶
type ProjectsProfilesService struct {// contains filtered or unexported fields}funcNewProjectsProfilesService¶
func NewProjectsProfilesService(s *Service) *ProjectsProfilesService
func (*ProjectsProfilesService)Create¶
func (r *ProjectsProfilesService) Create(parentstring, createprofilerequest *CreateProfileRequest) *ProjectsProfilesCreateCall
Create: CreateProfile creates a new profile resource in the online mode._Direct use of this API is discouraged, please use a supported profileragent(https://cloud.google.com/profiler/docs/about-profiler#profiling_agent)instead for profile collection._ The server ensures that the new profilesare created at a constant rate per deployment, so the creation request mayhang for some time until the next profile session is available. The requestmay fail with ABORTED error if the creation is not available within ~1m, theresponse will indicate the duration of the backoff the client should takebefore attempting creating a profile again. The backoff duration is returnedin google.rpc.RetryInfo extension on the response status. To a gRPC client,the extension will be return as a binary-serialized proto in the trailingmetadata item named "google.rpc.retryinfo-bin".
- parent: Parent project to create the profile in.
func (*ProjectsProfilesService)CreateOffline¶
func (r *ProjectsProfilesService) CreateOffline(parentstring, profile *Profile) *ProjectsProfilesCreateOfflineCall
CreateOffline: CreateOfflineProfile creates a new profile resource in theoffline mode. The client provides the profile to create along with theprofile bytes, the server records it. _Direct use of this API isdiscouraged, please use a supported profiler agent(https://cloud.google.com/profiler/docs/about-profiler#profiling_agent)instead for profile collection._
- parent: Parent project to create the profile in.
func (*ProjectsProfilesService)List¶added inv0.155.0
func (r *ProjectsProfilesService) List(parentstring) *ProjectsProfilesListCall
List: Lists profiles which have been collected so far and for which thecaller has permission to view.
- parent: The parent, which owns this collection of profiles. Format:projects/{user_project_id}.
func (*ProjectsProfilesService)Patch¶
func (r *ProjectsProfilesService) Patch(namestring, profile *Profile) *ProjectsProfilesPatchCall
Patch: UpdateProfile updates the profile bytes and labels on the profileresource created in the online mode. Updating the bytes for profiles createdin the offline mode is currently not supported: the profile content must beprovided at the time of the profile creation. _Direct use of this API isdiscouraged, please use a supported profiler agent(https://cloud.google.com/profiler/docs/about-profiler#profiling_agent)instead for profile collection._
- name: Output only. Opaque, server-assigned, unique ID for this profile.
typeProjectsService¶
type ProjectsService struct {Profiles *ProjectsProfilesService// contains filtered or unexported fields}funcNewProjectsService¶
func NewProjectsService(s *Service) *ProjectsService
typeService¶
type Service struct {BasePathstring// API endpoint base URLUserAgentstring// optional additional User-Agent fragmentProjects *ProjectsService// contains filtered or unexported fields} funcNewdeprecated
New creates a new Service. It uses the provided http.Client for requests.
Deprecated: please use NewService instead.To provide a custom HTTP client, use option.WithHTTPClient.If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
funcNewService¶added inv0.3.0
NewService creates a new Service.