Skip to content

Commit 212d3fd

Browse files
kaidaguerrepdecat
andauthored
feat: allow using pprof on FDW when STEAMPIPE_FDW_PPROF environment variable is set (#368) (#560)
(cherry picked from commit bf341d2) Co-authored-by: Patrick Decat <pdecat@gmail.com>
1 parent 0aa3084 commit 212d3fd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fdw.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import (
1818
"fmt"
1919
"io"
2020
"log"
21+
"net"
22+
"net/http"
23+
"os"
2124
"time"
2225
"unsafe"
2326

@@ -71,6 +74,18 @@ func init() {
7174
log.Printf("[INFO] Version: v%s\n", version.FdwVersion.String())
7275
log.Printf("[INFO] Log level: %s\n", level)
7376

77+
if _, found := os.LookupEnv("STEAMPIPE_FDW_PPROF"); found {
78+
log.Printf("[INFO] PROFILING!!!!")
79+
go func() {
80+
listener, err := net.Listen("tcp", "localhost:0")
81+
if err != nil {
82+
log.Println(err)
83+
return
84+
}
85+
log.Printf("[INFO] Check http://localhost:%d/debug/pprof/", listener.Addr().(*net.TCPAddr).Port)
86+
log.Println(http.Serve(listener, nil))
87+
}()
88+
}
7489
}
7590

7691
// Given a list of FdwDeparsedSortGroup and a FdwPlanState,

0 commit comments

Comments
 (0)