profiler

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 23 Imported by: 0

README

Synopsis

  1. Call NewProfiler to create a profiler instance. At this time, specify the directory to store the result of pprof.

  2. Start webui with the port to see the profile results: go profiler.ListenAndServe(8080)

  3. Start profiling by profiler.Start()

  4. Stop profiling by profiler.Stop()

You can see the profiling results by accessing http://localhost:8080 in your browser. If you profile again, the latest results will be automatically reflected. If you want to see the previous result, you can also refer to the past result by specifying the number in the profiling order like http://localhost:8080/1/ .

package main

import (
  middlewaretools "github.com/goccy/echo-tools/middleware"
  profilertools "github.com/goccy/echo-tools/profiler"
  "github.com/labstack/echo/v4"
)

var (
  notifier = middlewaretools.NewBenchmarkFinishEventNotifier(onBenchmarkFinished)
  profiler = profilertools.NewProfiler("profile")
)

func startBenchmark(c echo.Context) error {
  notifier.Start()
  profiler.Start()
  return c.JSON(http.StatusOK, struct{}{})
}

func onBenchmarkFinished() {
  profiler.Stop()
}

func main() {
  go profiler.ListenAndServe(8080)
  e := echo.New()
  e.Use(notifier.Middleware())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLogHandler added in v0.2.0

type AccessLogHandler struct{}

func (*AccessLogHandler) ServeHTTP added in v0.2.0

func (h *AccessLogHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AccessLogProfiler added in v0.2.0

type AccessLogProfiler struct {
	// contains filtered or unexported fields
}

func NewAccessLogProfiler added in v0.2.0

func NewAccessLogProfiler(e *echo.Echo, hostAddr string, opts ...AccessLogProfilerOption) *AccessLogProfiler

func (*AccessLogProfiler) Start added in v0.2.0

func (p *AccessLogProfiler) Start() error

func (*AccessLogProfiler) Stop added in v0.2.0

func (p *AccessLogProfiler) Stop() error

type AccessLogProfilerOption added in v0.2.0

type AccessLogProfilerOption func(*AccessLogProfiler)

func AccessLogOption added in v0.2.1

func AccessLogOption(kataribeFile, alpOption, botName, webhookURL, githubToken string) AccessLogProfilerOption

type AccessLogRequest added in v0.2.0

type AccessLogRequest struct {
	FileName          string   `json:"filename"`
	KataribeConfPath  string   `json:"kataribeConfPath"`
	ALPOption         string   `json:"alpOption"`
	Routes            []string `json:"routes"`
	BotName           string   `json:"botName"`
	GitHubToken       string   `json:"githubToken"`
	DiscordWebhookURL string   `json:"discordWebhookURL"`
}

type MySQLSlowQueryLogHandler

type MySQLSlowQueryLogHandler struct{}

func (*MySQLSlowQueryLogHandler) ServeHTTP

type MySQLSlowQueryLogProfiler

type MySQLSlowQueryLogProfiler struct {
	// contains filtered or unexported fields
}

func NewMySQLSlowQueryLogProfiler

func NewMySQLSlowQueryLogProfiler(e *echo.Echo, hostAddr string, db *sql.DB, opts ...MySQLSlowQueryLogProfilerOption) *MySQLSlowQueryLogProfiler

func (*MySQLSlowQueryLogProfiler) Start

func (p *MySQLSlowQueryLogProfiler) Start() error

func (*MySQLSlowQueryLogProfiler) Stop

func (p *MySQLSlowQueryLogProfiler) Stop() error

type MySQLSlowQueryLogProfilerOption

type MySQLSlowQueryLogProfilerOption func(*MySQLSlowQueryLogProfiler)

func MySQLSlowQueryLogDiscordNotifierOption

func MySQLSlowQueryLogDiscordNotifierOption(botName, webhookURL, githubToken string) MySQLSlowQueryLogProfilerOption

type MySQLSlowQueryLogRequest

type MySQLSlowQueryLogRequest struct {
	FileName          string `json:"filename"`
	BotName           string `json:"botName"`
	GitHubToken       string `json:"githubToken"`
	DiscordWebhookURL string `json:"discordWebhookURL"`
}

type Profiler

type Profiler struct {
	// contains filtered or unexported fields
}

func NewProfiler

func NewProfiler(baseDir string) *Profiler

func (*Profiler) AddProfiler

func (p *Profiler) AddProfiler(profiler SubProfiler)

func (*Profiler) ListenAndServe

func (p *Profiler) ListenAndServe(port uint16) error

func (*Profiler) Start

func (p *Profiler) Start() error

func (*Profiler) Stop

func (p *Profiler) Stop() error

type SubProfiler

type SubProfiler interface {
	Start() error
	Stop() error
}

Jump to

Keyboard shortcuts

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