메트릭 사용방법 변경
This commit is contained in:
@ -4,12 +4,10 @@ import (
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -20,7 +18,6 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
"repositories.action2quare.com/ayo/gocommon/metric"
|
||||
"repositories.action2quare.com/ayo/houston/shared"
|
||||
@ -233,8 +230,6 @@ func (hc *houstonClient) launch(meta *procmeta) error {
|
||||
|
||||
readingMetric := false
|
||||
var metricBuffer []byte
|
||||
metricValues := make(map[string]metricValueAccessor)
|
||||
|
||||
defer func() {
|
||||
logger.Println("stdReader is terminated :", meta.name)
|
||||
if meta.isState(protos.ProcessState_Running) {
|
||||
@ -273,27 +268,10 @@ func (hc *houstonClient) launch(meta *procmeta) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if _, registered := metricValues[metric.Key]; !registered {
|
||||
exporter := newExporterForPrometheus()
|
||||
accessor := exporter.registMetric(hc.config.MetricNamespace, metric)
|
||||
|
||||
if err := prometheus.Register(exporter); err != nil {
|
||||
logger.Println("prometheus.Register error :", err)
|
||||
} else {
|
||||
metricValues[metric.Key] = accessor
|
||||
logger.Println("metric registered :", metric)
|
||||
}
|
||||
}
|
||||
hc.metricExporter.RegisterMetric(&metric)
|
||||
} else {
|
||||
keybytes := metricBuffer[:8]
|
||||
valbits := binary.LittleEndian.Uint64(metricBuffer[8:])
|
||||
val := math.Float64frombits(valbits)
|
||||
|
||||
if accessor, ok := metricValues[string(keybytes)]; ok {
|
||||
accessor.set(val)
|
||||
} else {
|
||||
logger.Println("metric set but unregistered :", string(keybytes))
|
||||
}
|
||||
key, val := metric.ReadMetricValue(metricBuffer)
|
||||
hc.metricExporter.UpdateMetric(key, val)
|
||||
}
|
||||
|
||||
metricBuffer = metricBuffer[:0]
|
||||
|
||||
Reference in New Issue
Block a user