profserver

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 9 Imported by: 0

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
	Address string
	// contains filtered or unexported fields
}

Config represents a set of configuration parameters for profiling server.

func NewConfig

func NewConfig() *Config

NewConfig creates a new instance of the Config.

func NewConfigWithKeyPrefix

func NewConfigWithKeyPrefix(keyPrefix string) *Config

NewConfigWithKeyPrefix creates a new instance of the Config. Allows specifying key prefix which will be used for parsing configuration parameters.

func (*Config) KeyPrefix

func (c *Config) KeyPrefix() string

KeyPrefix returns a key prefix with which all configuration parameters should be presented.

func (*Config) Set

func (c *Config) Set(dp config.DataProvider) error

Set sets profiling server configuration values from config.DataProvider.

func (*Config) SetProviderDefaults

func (c *Config) SetProviderDefaults(dp config.DataProvider)

SetProviderDefaults sets default configuration values for profiling server in config.DataProvider.

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).

Jump to

Keyboard shortcuts

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