pprof

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Enabled     bool     `mapstructure:"enabled" yaml:"enabled" json:"enabled"`               // 是否启用认证
	AuthToken   string   `mapstructure:"auth-token" yaml:"auth-token" json:"authToken"`       // 认证令牌
	AllowedIPs  []string `mapstructure:"allowed-ips" yaml:"allowed-ips" json:"allowedIps"`    // 允许的IP列表
	RequireAuth bool     `mapstructure:"require-auth" yaml:"require-auth" json:"requireAuth"` // 是否需要认证
}

AuthConfig 认证配置

type PProf

type PProf struct {
	ModuleName     string          `mapstructure:"module-name" yaml:"module-name" json:"moduleName"`             // 模块名称
	Enabled        bool            `mapstructure:"enabled" yaml:"enabled" json:"enabled"`                        // 是否启用PProf
	PathPrefix     string          `mapstructure:"path-prefix" yaml:"path-prefix" json:"pathPrefix"`             // PProf路径前缀
	Port           int             `mapstructure:"port" yaml:"port" json:"port"`                                 // PProf服务端口
	EnableProfiles *ProfilesConfig `mapstructure:"enable-profiles" yaml:"enable-profiles" json:"enableProfiles"` // 启用的性能分析
	Sampling       *SamplingConfig `mapstructure:"sampling" yaml:"sampling" json:"sampling"`                     // 采样配置
	Authentication *AuthConfig     `mapstructure:"authentication" yaml:"authentication" json:"authentication"`   // 认证配置
}

PProf 性能分析配置

func Default

func Default() *PProf

Default 创建默认PProf配置

func (*PProf) Clone

func (c *PProf) Clone() internal.Configurable

Clone 返回配置的副本

func (*PProf) Disable

func (c *PProf) Disable() *PProf

Disable 禁用PProf

func (*PProf) Enable

func (c *PProf) Enable() *PProf

Enable 启用PProf

func (*PProf) EnableBlockProfile

func (c *PProf) EnableBlockProfile() *PProf

EnableBlockProfile 启用阻塞性能分析

func (*PProf) EnableCPUProfile

func (c *PProf) EnableCPUProfile() *PProf

EnableCPUProfile 启用CPU性能分析

func (*PProf) EnableForDevelopment

func (c *PProf) EnableForDevelopment() *PProf

EnableForDevelopment 启用开发环境配置

func (*PProf) EnableGoroutineProfile

func (c *PProf) EnableGoroutineProfile() *PProf

EnableGoroutineProfile 启用协程性能分析

func (*PProf) EnableMutexProfile

func (c *PProf) EnableMutexProfile() *PProf

EnableMutexProfile 启用互斥锁性能分析

func (*PProf) Get

func (c *PProf) Get() interface{}

Get 返回配置接口

func (*PProf) IsEnabled

func (c *PProf) IsEnabled() bool

IsEnabled 检查是否启用

func (*PProf) Set

func (c *PProf) Set(data interface{})

Set 设置配置数据

func (*PProf) Validate

func (c *PProf) Validate() error

Validate 验证配置

func (*PProf) WithAllowedIPs

func (c *PProf) WithAllowedIPs(ips []string) *PProf

WithAllowedIPs 设置允许的IP列表

func (*PProf) WithAuthToken

func (c *PProf) WithAuthToken(token string) *PProf

WithAuthToken 设置认证令牌

func (*PProf) WithEnabled

func (c *PProf) WithEnabled(enabled bool) *PProf

WithEnabled 设置是否启用PProf

func (*PProf) WithModuleName

func (c *PProf) WithModuleName(moduleName string) *PProf

WithModuleName 设置模块名称

func (*PProf) WithPathPrefix

func (c *PProf) WithPathPrefix(pathPrefix string) *PProf

WithPathPrefix 设置PProf路径前缀

func (*PProf) WithPort

func (c *PProf) WithPort(port int) *PProf

WithPort 设置PProf服务端口

func (*PProf) WithProfiles

func (c *PProf) WithProfiles(cpu, goroutine, block, mutex, heap, allocs, threadCreate, trace bool) *PProf

WithProfiles 设置启用的性能分析

func (*PProf) WithSampling

func (c *PProf) WithSampling(memoryRate, blockRate, mutexFraction int) *PProf

WithSampling 设置采样配置

type ProfilesConfig

type ProfilesConfig struct {
	CPU          bool `mapstructure:"cpu" yaml:"cpu" json:"cpu"`                            // CPU性能分析
	Goroutine    bool `mapstructure:"goroutine" yaml:"goroutine" json:"goroutine"`          // 协程性能分析
	Block        bool `mapstructure:"block" yaml:"block" json:"block"`                      // 阻塞性能分析
	Mutex        bool `mapstructure:"mutex" yaml:"mutex" json:"mutex"`                      // 互斥锁性能分析
	Heap         bool `mapstructure:"heap" yaml:"heap" json:"heap"`                         // 堆内存分析
	Allocs       bool `mapstructure:"allocs" yaml:"allocs" json:"allocs"`                   // 内存分配分析
	ThreadCreate bool `mapstructure:"threadcreate" yaml:"threadcreate" json:"threadcreate"` // 线程创建分析
	Trace        bool `mapstructure:"trace" yaml:"trace" json:"trace"`                      // 追踪分析
}

ProfilesConfig 性能分析配置

type SamplingConfig

type SamplingConfig struct {
	MemoryRate    int `mapstructure:"memory-rate" yaml:"memory-rate" json:"memoryRate"`          // 内存采样率
	BlockRate     int `mapstructure:"block-rate" yaml:"block-rate" json:"blockRate"`             // 阻塞采样率
	MutexFraction int `mapstructure:"mutex-fraction" yaml:"mutex-fraction" json:"mutexFraction"` // 互斥锁采样比例
}

SamplingConfig 采样配置

Jump to

Keyboard shortcuts

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