pprof

package
v1.0.1-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// UseProfileFieldName использовать ли pprof
	UseProfileFieldName = "trace.pprof"

	// EndpointFieldName путь для pprof
	EndpointFieldName = "server.http.routes.pprof"
)

Variables

View Source
var (
	// UseProfileDefault включить pprof
	UseProfileDefault = false

	// EndpointDefault путь для pprof
	EndpointDefault = "/debug"
)
View Source
var Component = compogo.Component{
	Dependencies: compogo.Components{
		&chi.Component,
	},
	Init: compogo.StepFunc(func(container compogo.Container) error {
		return container.Provide(NewConfig)
	}),
	BindFlags: compogo.BindFlags(func(flagSet flag.FlagSet, container compogo.Container) error {
		return container.Invoke(func(config *Config) {
			flagSet.BoolVar(&config.UseProfile, UseProfileFieldName, UseProfileDefault, "if true, add debug path to routing")
			flagSet.StringVar(&config.Endpoint, EndpointFieldName, EndpointDefault, "path for debug endpoint")
		})
	}),
	Configuration: compogo.StepFunc(func(container compogo.Container) error {
		return container.Invoke(Configuration)
	}),
	PreExecute: compogo.StepFunc(func(container compogo.Container) error {
		return container.Invoke(func(config *Config, r httpServer.Router, logger compogo.Logger) {
			if config.UseProfile {
				logger.GetLogger("http").
					GetLogger("server").
					GetLogger("router").
					GetLogger("chi").
					Infof("add pprof endpoint - '%s'", config.Endpoint)

				r.Mount(config.Endpoint, middleware.Profiler())
			}
		})
	}),
}

Component — компонент pprof эндпоинтов для chi-роутера. Добавляет эндпоинты для профилирования (CPU, memory, goroutine и т.д.). Включается только если UseProfile = true.

Functions

This section is empty.

Types

type Config

type Config struct {
	UseProfile bool
	Endpoint   string
}

Config содержит конфигурацию pprof эндпоинтов.

func Configuration

func Configuration(config *Config, configurator compogo.Configurator) *Config

Configuration загружает конфигурацию из Configurator.

func NewConfig

func NewConfig() *Config

NewConfig создаёт новую конфигурацию.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL