1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-24 22:53:52 +02:00

сделал PprofNats1()

This commit is contained in:
Nikitin Aleksandr
2025-04-04 11:08:34 +03:00
parent 85d6d45cf1
commit 9f79b00d6a
2 changed files with 25 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/ManyakRus/starter/stopapp"
"gitlab.aescorp.ru/dsp_dev/claim/common/sync_exchange"
"gitlab.aescorp.ru/dsp_dev/claim/common/sync_exchange/sync_types"
"os"
"runtime/pprof"
"sync"
"time"
@@ -175,7 +176,9 @@ loop:
// PprofNats1 - профилирование памяти отправляет в NATS 1 раз
func PprofNats1() error {
var err error
topicHeapProfile := serviceName + ".heap_profile"
TextTest := TextTestOrEmpty()
topicHeapProfile := serviceName + TextTest + ".heap_profile"
var buf bytes.Buffer
err = pprof.WriteHeapProfile(&buf)
if err != nil {
@@ -194,3 +197,17 @@ func PprofNats1() error {
return err
}
// TextTestOrEmpty - возвращает "_test" или ""
func TextTestOrEmpty() string {
Otvet := "_test"
stage := os.Getenv("STAGE")
switch stage {
case "dev":
Otvet = ""
case "prod":
Otvet = ""
}
return Otvet
}