Skip to content

Commit

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

import (
"fmt"
"net/http"

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

type PprofConfig struct {
HTTPPort string
EnablePprof bool
}

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(port string, logger logging.Logger) {
pprofAddr := fmt.Sprintf("%s:%s", disperser.Localhost, port)
mux := http.NewServeMux()

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

0 comments on commit 1380625

Please sign in to comment.