Documentation ¶
Overview ¶
Package profiler is a client for the Google Cloud Profiler service.
This package is still experimental and subject to change.
Usage example:
import "cloud.google.com/go/profiler" ... err := profiler.Start(profiler.Config{Service: "my-service"}) if err != nil { // TODO: Handle error. }
Calling Start will start a goroutine to collect profiles and upload to Cloud Profiler server, at the rhythm specified by the server.
The caller must provide the service string in the config, and may provide other information as well. See Config for details.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(cfg Config, options ...option.ClientOption) error
Start starts a goroutine to collect and upload profiles. The caller must provide the service string in the config. See Config for details. Start should only be called once. Any additional calls will be ignored.
Example ¶
package main import ( "cloud.google.com/go/profiler" ) func main() { err := profiler.Start(profiler.Config{Service: "my-service", ServiceVersion: "v1"}) if err != nil { //TODO: Handle error. } }
Output:
Types ¶
type Config ¶
type Config struct { // Service (or deprecated Target) must be provided to start the profiler. // It specifies the name of the service under which the profiled data // will be recorded and exposed at the Cloud Profiler UI for the project. // You can specify an arbitrary string, but see Deployment.target at // https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudprofiler/v2/profiler.proto // for restrictions. // NOTE: The string should be the same across different replicas of // your service so that the globally constant profiling rate is // maintained. Do not put things like PID or unique pod ID in the name. Service string // ServiceVersion is an optional field specifying the version of the // service. It can be an arbitrary string. Cloud Profiler profiles // once per minute for each version of each service in each zone. // ServiceVersion defaults to an empty string. ServiceVersion string // DebugLogging enables detailed debug logging from profiler. It // defaults to false. DebugLogging bool // ProjectID is the Cloud Console project ID to use instead of // the one read from the VM metadata server. // // Set this if you are running the agent in your local environment // or anywhere else outside of Google Cloud Platform. ProjectID string // APIAddr is the HTTP endpoint to use to connect to the profiler // agent API. Defaults to the production environment, overridable // for testing. APIAddr string // Target is deprecated, use Service instead. Target string // contains filtered or unexported fields }
Config is the profiler configuration.
Click to show internal directories.
Click to hide internal directories.