Skip to content

Commit

Permalink
add file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 21, 2024
1 parent aef3436 commit c5e916b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions disperser/apiserver/pprof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package apiserver

import (
"fmt"
"net/http"

_ "net/http/pprof"

"github.com/Layr-Labs/eigensdk-go/logging"
)

type PprofProfiler struct {
logger logging.Logger
httpPort string
}

func NewPprofProfiler(httpPort string, logger logging.Logger) *PprofProfiler {
return &PprofProfiler{
logger: logger.With("component", "PprofProfiler"),
httpPort: httpPort,
}
}

// Start the pprof server
func (p *PprofProfiler) Start(logger logging.Logger) {
pprofAddr := fmt.Sprintf("%s:%s", "0.0.0.0", p.httpPort)

if err := http.ListenAndServe(pprofAddr, nil); err != nil {
p.logger.Error("pprof server failed", "error", err, "pprofAddr", pprofAddr)
}
}

0 comments on commit c5e916b

Please sign in to comment.