Cloud Profiler API v2 - Package cloud.google.com/go/cloudprofiler/apiv2 (v0.1.0)

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:

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.

Functions

func DefaultAuthScopes

  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

ProfilerCallOptions

  type 
  
 ProfilerCallOptions 
  
 struct 
  
 { 
  
 CreateProfile 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateOfflineProfile 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateProfile 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

ProfilerCallOptions contains the retry settings for each method of ProfilerClient.

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.

General guidelines:

 Profiles for a single deployment must be created in ascending time order.

Profiles can be created in either online or offline mode, see below. 

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.

General guidelines:

 Profiles for a single deployment must be created in ascending time order.

Profiles can be created in either online or offline mode, see below. 

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 
 } 
 

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.

General guidelines:

 Profiles for a single deployment must be created in ascending time order.

Profiles can be created in either online or offline mode, see below. 

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 
 } 
 

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

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.

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 
 } 
 

func (*ProfilerClient) CreateProfile

CreateProfile createProfile creates a new profile resource in the online mode.

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 
 } 
 

func (*ProfilerClient) UpdateProfile

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.

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 
 } 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: