forked from Layr-Labs/eigenda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ubuntu
committed
Nov 21, 2024
1 parent
aef3436
commit c5e916b
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |