Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

opencensus-ext-python (==0.4.0) is shipped with broken StackdriverStatsExporter. #745

@moriyoshi

Description

@moriyoshi

Environment

Python 3.7.3 on Linux x86_64 w/glibc 2.29.
(These should be irrelevant.)

Problem description

TypeError: '_Stats' object is not iterable occurs during the call to get_exporter_thread(),

opencensus/ext/stackdriver/stats_exporter/__init__.py:404

    transport.get_exporter_thread(stats.stats, exporter, interval=interval)

where get_exporter_thread expects an iterable of metrics_producers.

It actually passes a metric producer (a.k.a. an instance of _Stats) itself. This is fixed in 0.7.x branch but not released yet. Please get it out the door.

What is the expected behavior?

No exceptions raised.

What is the actual behavior?

I see the following traceback.

Traceback (most recent call last):
  File "hello.py", line 6, in <module>
    new_stats_exporter()
  File "/tmp/test/venv/lib/python3.7/site-packages/opencensus/ext/stackdriver/stats_exporter/__init__.py", line 404, in new_stats_exporter
    transport.get_exporter_thread(stats.stats, exporter, interval=interval)
  File "/tmp/test/venv/lib/python3.7/site-packages/opencensus/metrics/transport.py", line 99, in get_exporter_thread
    for producer in metric_producers]
TypeError: '_Stats' object is not iterable

hello.py

# pip install opencensus==0.7.0 opencensus-ext-stackdriver==0.4.0
from opencensus.ext.stackdriver.stats_exporter import new_stats_exporter
from opencensus.stats.view import View
from opencensus.stats import stats, measure, aggregation, view


new_stats_exporter()

m = measure.MeasureInt('count', 'count', '1')
v = View('count', 'count', [], m, aggregation.SumAggregation())
stats.stats.view_manager.register_view(v)

mmap = stats.stats.stats_recorder.new_measurement_map()
mmap.measure_int_put(m, 1)
mmap.record()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions