opencensus-website icon indicating copy to clipboard operation
opencensus-website copied to clipboard

[Python] metrics sample errors

Open DazWilkin opened this issue 5 years ago • 0 comments

https://opencensus.io/quickstart/python/metrics/

The code appears to contain errors.

I have a working sample and I'll provide snippets from that where I think errors appear in the sample.

Coming from the Golang SDK, and having some experience with the Node.JS SDK, the Python SDK feels 'awkward'. This may just be how it needs to be to be idiomatic Python.

Duplicative imports:

from opencensus.stats import stats
...
from opencensus.stats import stats as stats_module

Then:

stats_recorder = stats.Stats().stats_recorder
...
stats = stats_module.Stats()
view_manager = stats.view_manager

IIUC not only is the duplication unncessary|confusing, but stats does not publish a Stats class: https://github.com/census-instrumentation/opencensus-python/blob/a8c3415a58257f1c644e5c087c0c4b0bbb3d8482/opencensus/stats/stats.py#L43

Works but is the correct approach?

s = stats.stats
stats_recorder = s.stats_recorder
view_manager = s.view_manager

IMO aliasing the class constructor is confusing, I'd prefer s = stats.Stats() as this is more transparent.

DazWilkin avatar Aug 23 '19 22:08 DazWilkin