mirror of https://github.com/golang/go.git
internal/telemetry: delay the conversion of metrics
convert to wire form only when we need to encode it Change-Id: Ib36ee2fbef773241a30b9aa707ebf311119b8705 Reviewed-on: https://go-review.googlesource.com/c/tools/+/208658 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Nathan Dias <nathan.dias@orijtech.com>
This commit is contained in:
parent
b0650ceb63
commit
fc82735a89
|
|
@ -48,7 +48,7 @@ type exporter struct {
|
|||
config Config
|
||||
node *wire.Node
|
||||
spans []*telemetry.Span
|
||||
metrics []*wire.Metric
|
||||
metrics []telemetry.MetricData
|
||||
}
|
||||
|
||||
// Connect creates a process specific exporter with the specified
|
||||
|
|
@ -114,7 +114,7 @@ func (e *exporter) Log(context.Context, telemetry.Event) {}
|
|||
func (e *exporter) Metric(ctx context.Context, data telemetry.MetricData) {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
e.metrics = append(e.metrics, convertMetric(data, e.config.Start))
|
||||
e.metrics = append(e.metrics, data)
|
||||
}
|
||||
|
||||
func (e *exporter) Flush() {
|
||||
|
|
@ -125,7 +125,10 @@ func (e *exporter) Flush() {
|
|||
spans[i] = convertSpan(s)
|
||||
}
|
||||
e.spans = nil
|
||||
metrics := e.metrics
|
||||
metrics := make([]*wire.Metric, len(e.metrics))
|
||||
for i, m := range e.metrics {
|
||||
metrics[i] = convertMetric(m, e.config.Start)
|
||||
}
|
||||
e.metrics = nil
|
||||
|
||||
if len(spans) > 0 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue