Categorygithub.com/grafana/pyroscope-go
modulepackage
1.2.0
Repository: https://github.com/grafana/pyroscope-go.git
Documentation: pkg.go.dev

# README

Pyroscope Golang Client

This is a golang integration for Pyroscope — open source continuous profiling platform.

For more information, please visit our golang integration documentation.

Profiling Go applications

To start profiling a Go application, you need to include our go module in your app:

go get github.com/grafana/pyroscope-go

Then add the following code to your application:

package main

import "github.com/grafana/pyroscope-go"

func main() {
  pyroscope.Start(pyroscope.Config{
    ApplicationName: "simple.golang.app",

    // replace this with the address of pyroscope server
    ServerAddress:   "http://pyroscope-server:4040",

    // you can disable logging by setting this to nil
    Logger:          pyroscope.StandardLogger,

    // Optional HTTP Basic authentication (Grafana Cloud)
    BasicAuthUser:     "<User>",
    BasicAuthPassword: "<Password>",
    // Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana Cloud.
    // TenantID:          "<TenantID>",

    // by default all profilers are enabled,
    // but you can select the ones you want to use:
    ProfileTypes: []pyroscope.ProfileType{
      pyroscope.ProfileCPU,
      pyroscope.ProfileAllocObjects,
      pyroscope.ProfileAllocSpace,
      pyroscope.ProfileInuseObjects,
      pyroscope.ProfileInuseSpace,
    },
  })

  // your code goes here
}

Tags

It is possible to add tags (labels) to the profiling data. These tags can be used to filter the data in the UI.

// these two ways of adding tags are equivalent:
pyroscope.TagWrapper(context.Background(), pyroscope.Labels("controller", "slow_controller"), func(c context.Context) {
  slowCode()
})

pprof.Do(context.Background(), pprof.Labels("controller", "slow_controller"), func(c context.Context) {
  slowCode()
})

Pull Mode

Go integration supports pull mode, which means that you can profile applications without adding any extra code. For that to work you will need to make sure you have profiling routes (/debug/pprof) enabled in your http server. Generally, that means that you need to add net/http/pprof package:

import _ "net/http/pprof"

Examples

Check out the examples directory in our repository to learn more 🔥

Maintainers

This package is maintained by @grafana/pyroscope-go. Mention this team on issues or PRs for feedback.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
Start starts continuously profiling go code.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

Logger is an interface that library users can use It is based on logrus, but much smaller — That's because we don't want library users to have to implement all of the logrus's methods.

# Type aliases

No description provided by the author
No description provided by the author