blob: 514971e7ee3531d19beb468d5f4ab41ad6ca8fe0 [file] [log] [blame]
Naveen Sampath04696f72022-06-13 15:19:14 +05301// +build profile
2
3/*
4* Copyright 2022-present Open Networking Foundation
5* Licensed under the Apache License, Version 2.0 (the "License");
6* you may not use this file except in compliance with the License.
7* You may obtain a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*
15*
16 */
17
18package pprofcontroller
19
20import (
21 "net/http"
22
23 // using for init
24 _ "net/http/pprof"
25 "github.com/opencord/voltha-lib-go/v7/pkg/log"
26 "context"
27)
28
29var logger log.CLogger
30var ctx = context.TODO()
31
32func Init() {
33 // Setup this package so that it's log level can be modified at run time
34 var err error
35 logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{})
36 if err != nil {
37 panic(err)
38 }
39 logger.Error(ctx, "Profiling is ENABLED")
40 go func() {
41 err := http.ListenAndServe("0.0.0.0:6060", nil)
42 logger.Error(ctx, "Profiling enable FAILURE", log.Opts{"Error": err})
43 }()
44}