package profiler

import "cloud.google.com/go/profiler"

Package profiler is a client for the Google Cloud Profiler service.

This package is still experimental and subject to change.

Calling Start will start a goroutine to collect profiles and upload to Cloud Profiler server, at the rhythm specified by the server.

The caller should provide the target string in the config so Cloud Profiler knows how to group the profile data. Otherwise the target string is set to "unknown".

Optionally DebugLogging can be set in the config to enable detailed logging from profiler.

Start should only be called once. The first call will start the profiling goroutine. Any additional calls will be ignored.

Index

Examples

Functions

func Start

func Start(cfg *Config) error

Start starts a goroutine to collect and upload profiles. See package level documentation for details.

Example

Code:play 

package main

import (
	"cloud.google.com/go/profiler"
)

func main() {
	// The caller should provide the target string in the config so Cloud
	// Profiler knows how to group the profile data. Otherwise the target
	// string is set to "unknown".
	//
	// Optionally DebugLogging can be set in the config to enable detailed
	// logging from profiler.
	err := profiler.Start(&profiler.Config{Target: "my-target"})
	if err != nil {
		//TODO: Handle error.
	}
}

Types

type Config

type Config struct {
	// Target groups related deployments together, defaults to "unknown".
	Target string
	// DebugLogging enables detailed debug logging from profiler.
	DebugLogging bool
	// ProjectID is the ID of the cloud project to use instead of
	// the one read from the VM metadata server. Typically for testing.
	ProjectID string
	// InstanceName is the name of the VM instance to use instead of
	// the one read from the VM metadata server. Typically for testing.
	InstanceName string
	// ZoneName is the name of the zone to use instead of
	// the one read from the VM metadata server. Typically for testing.
	ZoneName 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
}

Config is the profiler configuration.

Source Files

profiler.go

Directories

PathSynopsis
profiler/mocks
Version
v0.9.0
Published
Jun 21, 2017
Platform
windows/amd64
Imports
25 packages
Last checked
12 minutes ago

Tools for package owners.