First Commit of Voltha-Go-Controller from Radisys
Change-Id: I8e2e908e7ab09a4fe3d86849da18b6d69dcf4ab0
diff --git a/infra/pprofcontroller/profile.go b/infra/pprofcontroller/profile.go
new file mode 100644
index 0000000..514971e
--- /dev/null
+++ b/infra/pprofcontroller/profile.go
@@ -0,0 +1,44 @@
+// +build profile
+
+/*
+* Copyright 2022-present Open Networking Foundation
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*
+*
+ */
+
+package pprofcontroller
+
+import (
+ "net/http"
+
+ // using for init
+ _ "net/http/pprof"
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "context"
+)
+
+var logger log.CLogger
+var ctx = context.TODO()
+
+func Init() {
+ // Setup this package so that it's log level can be modified at run time
+ var err error
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{})
+ if err != nil {
+ panic(err)
+ }
+ logger.Error(ctx, "Profiling is ENABLED")
+ go func() {
+ err := http.ListenAndServe("0.0.0.0:6060", nil)
+ logger.Error(ctx, "Profiling enable FAILURE", log.Opts{"Error": err})
+ }()
+}