메트릭 사용방법 변경

This commit is contained in:
2023-11-28 22:31:42 +09:00
parent ad3382db89
commit afa270c9a0
5 changed files with 29 additions and 133 deletions

View File

@ -23,6 +23,7 @@ import (
"unsafe"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/gocommon/metric"
"repositories.action2quare.com/ayo/houston/shared"
"repositories.action2quare.com/ayo/houston/shared/protos"
@ -93,19 +94,20 @@ func (pm *procmeta) setState(s protos.ProcessState) {
}
type houstonClient struct {
childProcs []*procmeta
extraMetrics unsafe.Pointer // map[string]float32
deploys map[string][]*protos.VersionAndArgs
shutdownFunc context.CancelFunc
ctx context.Context
operationChan chan *protos.OperationQueryResponse
exitChan chan *exec.Cmd
clientChan chan *grpc.ClientConn
timestamp string
wg sync.WaitGroup
config clientConfig
version string
standalone bool
childProcs []*procmeta
extraMetrics unsafe.Pointer // map[string]float32
deploys map[string][]*protos.VersionAndArgs
shutdownFunc context.CancelFunc
ctx context.Context
operationChan chan *protos.OperationQueryResponse
exitChan chan *exec.Cmd
clientChan chan *grpc.ClientConn
timestamp string
wg sync.WaitGroup
config clientConfig
version string
standalone bool
metricExporter metric.Exporter
}
func unmarshal[T any](val *T, src map[string]string) {
@ -258,13 +260,14 @@ func NewClient(standalone bool) (HoustonClient, error) {
}
hc := &houstonClient{
config: clientConfig,
clientChan: make(chan *grpc.ClientConn),
extraMetrics: unsafe.Pointer(&map[string]float32{}),
deploys: deploys,
timestamp: exefi.ModTime().String(),
version: string(ver),
standalone: standalone,
config: clientConfig,
clientChan: make(chan *grpc.ClientConn),
extraMetrics: unsafe.Pointer(&map[string]float32{}),
deploys: deploys,
timestamp: exefi.ModTime().String(),
version: string(ver),
standalone: standalone,
metricExporter: metric.NewPrometheusExport(clientConfig.MetricNamespace),
}
ctx, cancel := context.WithCancel(context.Background())