census-instrumentation / opencensus-go

A stats collection and distributed tracing framework
http://opencensus.io
Apache License 2.0
2.05k stars 327 forks source link

Memory statistics never collected unless UseDerivedCumulative is used #1295

Open kfcss opened 1 year ago

kfcss commented 1 year ago

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: https://github.com/census-instrumentation/opencensus-go/commit/49838f207d61097fc0ebb8aeef306913388376ca

Metrics are created here: https://github.com/census-instrumentation/opencensus-go/blob/06ffb6a91ef660d6a1a085dd8489758232c19bca/plugin/runmetrics/producer.go#L125-L138

The problem is that p.deprecatedMemStats.read() is never called in func (p *producer) Read(): https://github.com/census-instrumentation/opencensus-go/blob/06ffb6a91ef660d6a1a085dd8489758232c19bca/plugin/runmetrics/producer.go#L167-L177