Skip to content

Commit

Permalink
Updated pprof naming and method signature
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Byrgazov <vladislav.byrgazov@xored.com>
  • Loading branch information
Vladislav Byrgazov committed Aug 12, 2024
1 parent 660c766 commit 2b57be8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/tools/pprof/pprof.go → pkg/tools/pprofutils/pprofutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package pprof provides ability to enable pprof if required
package pprof
// Package pprofutils provides ability to enable pprof if required
package pprofutils

import (
"context"
"fmt"
"net/http"
"net/http/pprof"
"net/url"
"time"

"github.com/networkservicemesh/sdk/pkg/tools/log"
)

// Init - configures pprof http handlers
func Init(ctx context.Context, port uint16) {
log.FromContext(ctx).Infof("Profiler is enabled. Listening on %d", port)
// ListenAndServe - configures pprof http handlers
func ListenAndServe(ctx context.Context, listenOn *url.URL) {
log.FromContext(ctx).Infof("Profiler is enabled. Listening on %s", listenOn.Host)
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
Expand All @@ -43,7 +43,7 @@ func Init(ctx context.Context, port uint16) {
mux.Handle("/debug/pprof/mutex", pprof.Handler("mutex"))
mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
server := &http.Server{
Addr: fmt.Sprintf("localhost:%d", port),
Addr: listenOn.Host,
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
Expand Down

0 comments on commit 2b57be8

Please sign in to comment.