endian 수정
This commit is contained in:
@ -30,7 +30,7 @@ type metricValueAccessor struct {
|
|||||||
ptr *uint64
|
ptr *uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (va metricValueAccessor) set(val float64) {
|
func (va *metricValueAccessor) set(val float64) {
|
||||||
atomic.StoreUint64(va.ptr, math.Float64bits(val))
|
atomic.StoreUint64(va.ptr, math.Float64bits(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +69,7 @@ func (e *exporterForPrometheus) registMetric(namespace string, desc metric.Metri
|
|||||||
func (e *exporterForPrometheus) Describe(ch chan<- *prometheus.Desc) {
|
func (e *exporterForPrometheus) Describe(ch chan<- *prometheus.Desc) {
|
||||||
ptr := atomic.LoadPointer(&e.metricPtr)
|
ptr := atomic.LoadPointer(&e.metricPtr)
|
||||||
container := *(*[]metricDesc)(ptr)
|
container := *(*[]metricDesc)(ptr)
|
||||||
|
|
||||||
for _, v := range container {
|
for _, v := range container {
|
||||||
ch <- v.Desc
|
ch <- v.Desc
|
||||||
}
|
}
|
||||||
@ -77,6 +78,7 @@ func (e *exporterForPrometheus) Describe(ch chan<- *prometheus.Desc) {
|
|||||||
func (e *exporterForPrometheus) Collect(ch chan<- prometheus.Metric) {
|
func (e *exporterForPrometheus) Collect(ch chan<- prometheus.Metric) {
|
||||||
ptr := atomic.LoadPointer(&e.metricPtr)
|
ptr := atomic.LoadPointer(&e.metricPtr)
|
||||||
container := *(*[]metricDesc)(ptr)
|
container := *(*[]metricDesc)(ptr)
|
||||||
|
|
||||||
for _, v := range container {
|
for _, v := range container {
|
||||||
ch <- prometheus.MustNewConstMetric(v.Desc, v.valueType, math.Float64frombits(atomic.LoadUint64(v.val)))
|
ch <- prometheus.MustNewConstMetric(v.Desc, v.valueType, math.Float64frombits(atomic.LoadUint64(v.val)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -277,14 +277,16 @@ func (hc *houstonClient) launch(meta *procmeta) error {
|
|||||||
exporter := newExporterForPrometheus()
|
exporter := newExporterForPrometheus()
|
||||||
accessor := exporter.registMetric(hc.config.MetricNamespace, metric)
|
accessor := exporter.registMetric(hc.config.MetricNamespace, metric)
|
||||||
|
|
||||||
prometheus.Register(exporter)
|
if err := prometheus.Register(exporter); err != nil {
|
||||||
|
logger.Println("prometheus.Register error :", err)
|
||||||
|
} else {
|
||||||
metricValues[metric.Key] = accessor
|
metricValues[metric.Key] = accessor
|
||||||
logger.Println("metric registered :", metric)
|
logger.Println("metric registered :", metric)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
keybytes := metricBuffer[:8]
|
keybytes := metricBuffer[:8]
|
||||||
valbits := binary.BigEndian.Uint64(metricBuffer[8:])
|
valbits := binary.LittleEndian.Uint64(metricBuffer[8:])
|
||||||
val := math.Float64frombits(valbits)
|
val := math.Float64frombits(valbits)
|
||||||
|
|
||||||
if accessor, ok := metricValues[string(keybytes)]; ok {
|
if accessor, ok := metricValues[string(keybytes)]; ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user