Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 1 | // +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 | |
| 18 | package pprofcontroller |
| 19 | |
| 20 | import ( |
| 21 | "net/http" |
| 22 | |
| 23 | // using for init |
| 24 | _ "net/http/pprof" |
Tinoj Joseph | 1d10832 | 2022-07-13 10:07:39 +0530 | [diff] [blame] | 25 | "voltha-go-controller/log" |
| 26 | "context" |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 27 | ) |
| 28 | |
| 29 | var logger log.CLogger |
| 30 | var ctx = context.TODO() |
| 31 | |
| 32 | func Init() { |
Tinoj Joseph | 1d10832 | 2022-07-13 10:07:39 +0530 | [diff] [blame] | 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 | } |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 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 | } |