Files
threshold/internal/cmd/base/pprof_on.go
T
dillanb-hashi 828148934b chore(e2e): Added build tag for enabling pprof tracing (#5839)
* added pprof tag and make command
* updated tracing readme
2025-06-16 08:19:20 -07:00

29 lines
623 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
//go:build pprof
// +build pprof
package base
import (
"context"
"errors"
"net/http"
"github.com/hashicorp/boundary/internal/event"
_ "net/http/pprof"
)
func StartPprof(ctx context.Context) {
const op = "base.StartPprof"
go func() {
const addr = "localhost:6060"
event.WriteSysEvent(ctx, op, "starting pprof HTTP server", "addr", addr)
if err := http.ListenAndServe(addr, nil); err != nil && !errors.Is(err, http.ErrServerClosed) {
event.WriteSysEvent(ctx, op, "failed to serve pprof HTTP server", "error", err.Error())
}
}()
}