Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartProfilingHTTPServer ¶
StartProfilingHTTPServer starts an HTTP server for profiling using the provided configuration. It sets up endpoints for pprof profiling and listens on the specified host and port. The server includes handlers for various pprof endpoints such as index, profile, cmdline, symbol, and trace. The server's read and header timeouts are set to two minutes.
Parameters:
- ctx (context.Context): The context for managing server lifecycle.
- c (Config): The configuration object containing the profiling host and port.
Behavior:
- Logs an error and returns if the TCP listener cannot be created.
- Logs the port on which the profiling server is listening.
- Handles server closure gracefully, logging a warning if the server is stopped or an error if the connection is closed unexpectedly.
- Supports graceful shutdown using context cancellation or timeout.
Types ¶
type Config ¶
type Config struct {
// ProfilingHost is the address to bind the profiling server
ProfilingHost string `mapstructure:"ProfilingHost"`
// ProfilingPort is the port to bind the profiling server
ProfilingPort int `mapstructure:"ProfilingPort"`
// ProfilingEnabled is the flag to enable/disable the profiling server
ProfilingEnabled bool `mapstructure:"ProfilingEnabled"`
}
Config represents the configuration settings for the profiling server. It includes options to specify the host, port, and whether profiling is enabled.
Click to show internal directories.
Click to hide internal directories.