blob: d8e3a979c7b5096a007becd47505bd472c5cc32e [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"
Tinoj Joseph1d108322022-07-13 10:07:39 +053025 "voltha-go-controller/log"
26 "context"
Naveen Sampath04696f72022-06-13 15:19:14 +053027)
28
29var logger log.CLogger
30var ctx = context.TODO()
31
32func Init() {
Tinoj Joseph1d108322022-07-13 10:07:39 +053033 // 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 }
Naveen Sampath04696f72022-06-13 15:19:14 +053039 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}