pprof

package
v0.2.0-beta7-bridge-tmp Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartProfilingHTTPServer

func StartProfilingHTTPServer(ctx context.Context, c Config)

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.

Jump to

Keyboard shortcuts

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