pprof

package
v1.67.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 3 Imported by: 1

README

Package pprof

Пакет pprof для интеграции Go-профилировщика pprof с HTTP-сервером.

Functions

RegisterHandlers(prefix string, muxer Muxer)

Зарегистрировать обработчики pprof с указанным префиксом URL для переданного мультиплексора, реализующего интерфейс Muxer.

Endpoints(prefix string) []string

Получить список всех зарегистрированных эндпоинтов.

Usage

Default usage flow
package main

import (
	"log"

	"github.com/txix-open/isp-kit/infra"
	"github.com/txix-open/isp-kit/infra/pprof"
	"github.com/txix-open/isp-kit/shutdown"
)

func main() {
	srv := infra.NewServer()
	pprof.RegisterHandlers("/debug", srv)

	shutdown.On(func() { /* waiting for SIGINT & SIGTERM signals */
		log.Println("shutting down...")
		srv.Shutdown()
		log.Println("shutdown completed")
	})

	err := srv.ListenAndServe(":8080")
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Overview

Package pprof provides utilities for integrating Go's pprof profiling tools with an HTTP server. It registers the standard pprof endpoints under a configurable URL prefix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Endpoints

func Endpoints(prefix string) []string

Endpoints returns a list of all pprof endpoint paths for the given prefix. This is useful for documentation or verification purposes.

func RegisterHandlers

func RegisterHandlers(prefix string, muxer Muxer)

RegisterHandlers registers pprof handlers with the provided muxer under the specified URL prefix. This enables access to profiling endpoints such as /debug/pprof/, /debug/pprof/profile, and others.

Example:

pprof.RegisterHandlers("/api", srv)

Types

type Muxer

type Muxer interface {
	Handle(pattern string, handler http.Handler)
}

Muxer defines an interface for HTTP multiplexers that can register handlers. This allows the package to work with various HTTP routing implementations.

Jump to

Keyboard shortcuts

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