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 13, 2024
1 parent
55fc8ef
commit 1380625
Showing
1 changed file
with
36 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,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) | ||
} | ||
} |