profiles

package
v0.19.770 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

README

Profiling Package

This package provides profiling capabilities for Go applications using the standard net/http/pprof package.

Usage

Environment Variables

The profiler can be configured using the following environment variables:

  • ENABLE_PROFILING: Set to "true", "1", or "yes" to enable profiling (case insensitive)
  • PROFILING_PORT: Set to a valid port number to override the default port (6060)

Example:

# Enable profiling
ENABLE_PROFILING=true ./your-application

# Enable profiling with custom port
ENABLE_PROFILING=true PROFILING_PORT=7070 ./your-application
Programmatic Usage
import "github.com/nuonco/nuon/pkg/profiles"

// Using environment variables only
app := fx.New(
    profiles.EnvModule(),
    // other providers...
)

// Or with explicit configuration
app := fx.New(
    profiles.Module(profiles.ProfilerOptions{
        Enabled: true,
        Port: 8080,
    }),
    // other providers...
)

Accessing Profiles

Once the profiler is running, profiles can be accessed at:

http://localhost:<port>/debug/pprof/

Common endpoints:

  • /debug/pprof/heap - Heap profile
  • /debug/pprof/profile - CPU profile
  • /debug/pprof/goroutine - Goroutines stack traces
  • /debug/pprof/block - Blocking profile

For detailed usage instructions, see the Go pprof documentation.

Documentation

Index

Constants

View Source
const (
	// EnvEnableProfiling is the environment variable to control profiling
	EnvEnableProfiling = "ENABLE_PROFILING"
	// EnvProfilingPort is the environment variable to set profiling port
	EnvProfilingPort = "PROFILING_PORT"
)

Variables

This section is empty.

Functions

func EnvModule

func EnvModule() fx.Option

EnvModule provides the profiler as an fx module using only environment config

func Module

func Module(options ...ProfilerOptions) fx.Option

Module provides the profiler as an fx module

func NewProfilerServer

func NewProfilerServer(options ProfilerOptions) *http.Server

NewProfilerServer creates an HTTP server for profiling

func RegisterProfiler

func RegisterProfiler(lc fx.Lifecycle, options ProfilerOptions)

RegisterProfiler registers the profiler with fx lifecycle

func SetupPprofMux

func SetupPprofMux() *http.ServeMux

Types

type ProfilerOptions

type ProfilerOptions struct {
	Enabled bool
	Port    int
}

func DefaultProfilerOptions

func DefaultProfilerOptions() ProfilerOptions

DefaultProfilerOptions provides default settings for the profiler

func LoadOptionsFromEnv

func LoadOptionsFromEnv() ProfilerOptions

LoadOptionsFromEnv loads profiler options from environment variables

Jump to

Keyboard shortcuts

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