To use Push Mode, call pyroscope.Start() with a pyroscope.Config object. This sends profiling data directly to the Pyroscope server.
Key configuration options include:
ApplicationName: A unique identifier for your application.ServerAddress: The URL of your Pyroscope server.Logger: The logger to use (set to nil to disable logging; pyroscope.StandardLogger is the default).BasicAuthUser and BasicAuthPassword: Credentials for HTTP Basic authentication (required for Grafana Cloud).TenantID: The Pyroscope tenant ID (required for multi-tenancy, not needed for Grafana Cloud).ProfileTypes: A slice of pyroscope.ProfileType to specify which profilers to enable (e.g., pyroscope.ProfileCPU, pyroscope.ProfileAllocObjects, etc.). All profilers are enabled by default.
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
}