Skip to content

Commit 63bbb0a

Browse files
committed
Enable cpu profiling
1 parent 8f07964 commit 63bbb0a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

assets/terraform/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import (
44
"context"
55
"flag"
66
"log"
7+
"os"
8+
"runtime/pprof"
79

810
"github.com/PaloAltoNetworks/terraform-provider-panos/internal/provider"
911

1012
"github.com/hashicorp/terraform-plugin-framework/providerserver"
1113
)
1214

15+
var _ = pprof.StartCPUProfile
16+
1317
// Run "go generate" to format example terraform files and generate the docs for the registry/website
1418

1519
// If you do not have terraform installed, you can remove the formatting command, but its suggested to
@@ -35,6 +39,16 @@ func main() {
3539
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
3640
flag.Parse()
3741

42+
cpuprofile := os.Getenv("TF_PANOS_PROFILE")
43+
if cpuprofile != "" {
44+
f, err := os.Create(cpuprofile)
45+
if err != nil {
46+
log.Fatal(err)
47+
}
48+
pprof.StartCPUProfile(f)
49+
defer pprof.StopCPUProfile()
50+
}
51+
3852
opts := providerserver.ServeOpts{
3953
Address: "registry.terraform.io/paloaltonetworks/panos",
4054
Debug: debug,

0 commit comments

Comments
 (0)