Documentation ¶
Overview ¶
Package cloudprofiler is an auto-generated package for the Cloud Profiler API.
Manages continuous profiling information.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation ¶
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage ¶
To get started with this package, create a client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client ¶
The following is an example of making an API call with the newly created client.
ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudprofilerpb.CreateOfflineProfileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb#CreateOfflineProfileRequest. } resp, err := c.CreateOfflineProfile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context ¶
The ctx passed to NewProfilerClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Index ¶
- func DefaultAuthScopes() []string
- type ExportCallOptions
- type ExportClient
- type ProfileIterator
- type ProfilerCallOptions
- type ProfilerClient
- func (c *ProfilerClient) Close() error
- func (c *ProfilerClient) Connection() *grpc.ClientConndeprecated
- func (c *ProfilerClient) CreateOfflineProfile(ctx context.Context, req *cloudprofilerpb.CreateOfflineProfileRequest, ...) (*cloudprofilerpb.Profile, error)
- func (c *ProfilerClient) CreateProfile(ctx context.Context, req *cloudprofilerpb.CreateProfileRequest, ...) (*cloudprofilerpb.Profile, error)
- func (c *ProfilerClient) UpdateProfile(ctx context.Context, req *cloudprofilerpb.UpdateProfileRequest, ...) (*cloudprofilerpb.Profile, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type ExportCallOptions ¶ added in v0.2.0
type ExportCallOptions struct {
ListProfiles []gax.CallOption
}
ExportCallOptions contains the retry settings for each method of ExportClient.
type ExportClient ¶ added in v0.2.0
type ExportClient struct { // The call options for this service. CallOptions *ExportCallOptions // contains filtered or unexported fields }
ExportClient is a client for interacting with Cloud Profiler API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service allows existing Cloud Profiler customers to export their profile data out of Google Cloud.
func NewExportClient ¶ added in v0.2.0
func NewExportClient(ctx context.Context, opts ...option.ClientOption) (*ExportClient, error)
NewExportClient creates a new export service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service allows existing Cloud Profiler customers to export their profile data out of Google Cloud.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewExportClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewExportRESTClient ¶ added in v0.2.0
func NewExportRESTClient(ctx context.Context, opts ...option.ClientOption) (*ExportClient, error)
NewExportRESTClient creates a new export service rest client.
Service allows existing Cloud Profiler customers to export their profile data out of Google Cloud.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewExportRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*ExportClient) Close ¶ added in v0.2.0
func (c *ExportClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ExportClient) Connection
deprecated
added in
v0.2.0
func (c *ExportClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ExportClient) ListProfiles ¶ added in v0.2.0
func (c *ExportClient) ListProfiles(ctx context.Context, req *cloudprofilerpb.ListProfilesRequest, opts ...gax.CallOption) *ProfileIterator
ListProfiles lists profiles which have been collected so far and for which the caller has permission to view.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" cloudprofilerpb "cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb" "google.golang.org/api/iterator" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewExportClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudprofilerpb.ListProfilesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb#ListProfilesRequest. } it := c.ListProfiles(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*cloudprofilerpb.ListProfilesResponse) } }
Output:
Example (All) ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" cloudprofilerpb "cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewExportClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudprofilerpb.ListProfilesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb#ListProfilesRequest. } for resp, err := range c.ListProfiles(ctx, req).All() { if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
type ProfileIterator ¶ added in v0.2.0
type ProfileIterator struct { // Response is the raw response for the current page. // It must be cast to the RPC response type. // Calling Next() or InternalFetch() updates this value. Response interface{} // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*cloudprofilerpb.Profile, nextPageToken string, err error) // contains filtered or unexported fields }
ProfileIterator manages a stream of *cloudprofilerpb.Profile.
func (*ProfileIterator) All ¶ added in v0.4.1
func (it *ProfileIterator) All() iter.Seq2[*cloudprofilerpb.Profile, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ProfileIterator) Next ¶ added in v0.2.0
func (it *ProfileIterator) Next() (*cloudprofilerpb.Profile, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ProfileIterator) PageInfo ¶ added in v0.2.0
func (it *ProfileIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type ProfilerCallOptions ¶
type ProfilerCallOptions struct { CreateProfile []gax.CallOption CreateOfflineProfile []gax.CallOption UpdateProfile []gax.CallOption }
ProfilerCallOptions contains the retry settings for each method of ProfilerClient.
type ProfilerClient ¶
type ProfilerClient struct { // The call options for this service. CallOptions *ProfilerCallOptions // contains filtered or unexported fields }
ProfilerClient is a client for interacting with Cloud Profiler API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Manage the collection of continuous profiling data provided by profiling agents running in the cloud or by an offline provider of profiling data.
The APIs listed in this service are intended for use within our profiler agents only.
func NewProfilerClient ¶
func NewProfilerClient(ctx context.Context, opts ...option.ClientOption) (*ProfilerClient, error)
NewProfilerClient creates a new profiler service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Manage the collection of continuous profiling data provided by profiling agents running in the cloud or by an offline provider of profiling data.
The APIs listed in this service are intended for use within our profiler agents only.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewProfilerRESTClient ¶
func NewProfilerRESTClient(ctx context.Context, opts ...option.ClientOption) (*ProfilerClient, error)
NewProfilerRESTClient creates a new profiler service rest client.
Manage the collection of continuous profiling data provided by profiling agents running in the cloud or by an offline provider of profiling data.
The APIs listed in this service are intended for use within our profiler agents only.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*ProfilerClient) Close ¶
func (c *ProfilerClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ProfilerClient) Connection
deprecated
func (c *ProfilerClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ProfilerClient) CreateOfflineProfile ¶
func (c *ProfilerClient) CreateOfflineProfile(ctx context.Context, req *cloudprofilerpb.CreateOfflineProfileRequest, opts ...gax.CallOption) (*cloudprofilerpb.Profile, error)
CreateOfflineProfile createOfflineProfile creates a new profile resource in the offline mode. The client provides the profile to create along with the profile bytes, the server records it.
Direct use of this API is discouraged, please use a supported profiler agent (at https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" cloudprofilerpb "cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudprofilerpb.CreateOfflineProfileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb#CreateOfflineProfileRequest. } resp, err := c.CreateOfflineProfile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProfilerClient) CreateProfile ¶
func (c *ProfilerClient) CreateProfile(ctx context.Context, req *cloudprofilerpb.CreateProfileRequest, opts ...gax.CallOption) (*cloudprofilerpb.Profile, error)
CreateProfile createProfile creates a new profile resource in the online mode.
Direct use of this API is discouraged, please use a supported profiler agent (at https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection.
The server ensures that the new profiles are created at a constant rate per deployment, so the creation request may hang for some time until the next profile session is available.
The request may fail with ABORTED error if the creation is not available within ~1m, the response will indicate the duration of the backoff the client should take before attempting creating a profile again. The backoff duration is returned in google.rpc.RetryInfo extension on the response status. To a gRPC client, the extension will be return as a binary-serialized proto in the trailing metadata item named “google.rpc.retryinfo-bin”.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" cloudprofilerpb "cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudprofilerpb.CreateProfileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb#CreateProfileRequest. } resp, err := c.CreateProfile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*ProfilerClient) UpdateProfile ¶
func (c *ProfilerClient) UpdateProfile(ctx context.Context, req *cloudprofilerpb.UpdateProfileRequest, opts ...gax.CallOption) (*cloudprofilerpb.Profile, error)
UpdateProfile updateProfile updates the profile bytes and labels on the profile resource created in the online mode. Updating the bytes for profiles created in the offline mode is currently not supported: the profile content must be provided at the time of the profile creation.
Direct use of this API is discouraged, please use a supported profiler agent (at https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection.
Example ¶
package main import ( "context" cloudprofiler "cloud.google.com/go/cloudprofiler/apiv2" cloudprofilerpb "cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb" ) func main() { ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := cloudprofiler.NewProfilerClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudprofilerpb.UpdateProfileRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudprofiler/apiv2/cloudprofilerpb#UpdateProfileRequest. } resp, err := c.UpdateProfile(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output: