This repository was archived by the owner on Jul 31, 2023. It is now read-only.
-
Couldn't load subscription status.
- Fork 328
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Memory statistics never collected unless UseDerivedCumulative is used #1295
Copy link
Copy link
Open
Labels
Description
Please answer these questions before submitting a bug report.
What version of OpenCensus are you using?
go.opencensus.io v0.23.0
What version of Go are you using?
1.18
What did you do?
Callled
runmetrics.Enable(runmetrics.RunMetricOptions{
EnableCPU: true,
EnableMemory: true,
})
What did you expect to see?
That memory metrics were being updated
What did you see instead?
Memory metrics are NOT updated.
Additional context
I think the bug was created with the commit: 49838f2
Metrics are created here:
opencensus-go/plugin/runmetrics/producer.go
Lines 125 to 138 in 06ffb6a
| if options.EnableMemory { | |
| switch options.UseDerivedCumulative { | |
| case true: | |
| producer.memStats, err = newMemStats(producer) | |
| if err != nil { | |
| return err | |
| } | |
| default: | |
| producer.deprecatedMemStats, err = newDeprecatedMemStats(producer) | |
| if err != nil { | |
| return err | |
| } | |
| } | |
| } |
The problem is that p.deprecatedMemStats.read() is never called in func (p *producer) Read():
opencensus-go/plugin/runmetrics/producer.go
Lines 167 to 177 in 06ffb6a
| func (p *producer) Read() []*metricdata.Metric { | |
| if p.memStats != nil { | |
| p.memStats.read() | |
| } | |
| if p.cpuStats != nil { | |
| p.cpuStats.read() | |
| } | |
| return p.reg.Read() | |
| } |