Documentation
¶
Overview ¶
Package profserver provides HTTP server for profiling (pprof is used under the hood).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled" json:"enabled"`
Address string `mapstructure:"address" yaml:"address" json:"address"`
// contains filtered or unexported fields
}
Config represents a set of configuration parameters for profiling server. Configuration can be loaded in different formats (YAML, JSON) using config.Loader, viper, or with json.Unmarshal/yaml.Unmarshal functions directly.
func NewConfig ¶
func NewConfig(options ...ConfigOption) *Config
NewConfig creates a new instance of the Config.
func NewConfigWithKeyPrefix ¶
NewConfigWithKeyPrefix creates a new instance of the Config with a key prefix. This prefix will be used by config.Loader. Deprecated: use NewConfig with WithKeyPrefix instead.
func NewDefaultConfig ¶ added in v1.11.0
func NewDefaultConfig(options ...ConfigOption) *Config
NewDefaultConfig creates a new instance of the Config with default values.
func (*Config) KeyPrefix ¶
KeyPrefix returns a key prefix with which all configuration parameters should be presented. Implements config.KeyPrefixProvider interface.
func (*Config) Set ¶
func (c *Config) Set(dp config.DataProvider) error
Set sets profiling server configuration values from config.DataProvider. Implements config.Config interface.
func (*Config) SetProviderDefaults ¶
func (c *Config) SetProviderDefaults(dp config.DataProvider)
SetProviderDefaults sets default configuration values for profiling server in config.DataProvider. Implements config.Config interface.
type ConfigOption ¶ added in v1.11.0
type ConfigOption func(*configOptions)
ConfigOption is a type for functional options for the Config.
func WithKeyPrefix ¶ added in v1.11.0
func WithKeyPrefix(keyPrefix string) ConfigOption
WithKeyPrefix returns a ConfigOption that sets a key prefix for parsing configuration parameters. This prefix will be used by config.Loader.
type ProfServer ¶
type ProfServer struct {
URL string
HTTPServer *http.Server
Logger log.FieldLogger
// contains filtered or unexported fields
}
ProfServer represents HTTP server for profiling. pprof is used under the hood. It implements service.Unit interface.
func New ¶
func New(cfg *Config, logger log.FieldLogger) *ProfServer
New creates a new HTTP server (pprof) for profiling.
func (*ProfServer) Start ¶
func (s *ProfServer) Start(fatalError chan<- error)
Start starts profiling HTTP server in a blocking way. Supposed this methods will be called in a separate goroutine. If a fatal error occurs, it's sent into passed fatalError channel and should be processed outside.
func (*ProfServer) Stop ¶
func (s *ProfServer) Stop(gracefully bool) error
Stop stops profiling HTTP server (always in no gracefully way).