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

[Python] metrics sample errors #708

Description

@DazWilkin

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions