Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

[Python] metrics sample errors #708

Open
DazWilkin opened this issue Aug 23, 2019 · 0 comments
Open

[Python] metrics sample errors #708

DazWilkin opened this issue Aug 23, 2019 · 0 comments

Comments

@DazWilkin
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant