profiler - ActiveState ActiveGo 1.8
...

Package profiler

import "cloud.google.com/go/profiler"
Overview
Index
Examples
Subdirectories

Overview ▾

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

Start

Package files

profiler.go

func Start

func Start(cfg *Config) error

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

Example

Code:

// 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.
}

type Config

Config is the profiler configuration.

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
}

Subdirectories

Name Synopsis
..
mocks