You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the expected behavior?
Type annotated as Sequence should work with len(), subscription, etc.. A more subtle bug the generator causes is that data_points can only be iterated over once, which will consume the generator.
What is the actual behavior?
TypeError: object of type 'generator' has no len()
Additional context
Possible fixes
I'd recommend adding calls to list() or tuple() to convert the generator to a sequence or alter _ViewInstrumentMatch.collect() to return a sequence itself. I think this is appropriate as the generators are actually holding SDK locks which can remain locked if the generator is not consumed.
The text was updated successfully, but these errors were encountered:
This seems like an approachable first issue for me, would give me some introduction to the metrics implementation and force me to get the project up and running. Do you mind if I give it a shot?
This applies to all of the MetricsData data types
Sum
,Histogram
andGauge
. The type annotation isSequence
:opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py
Line 68 in 778c4b1
But the implementation assigns an
Iterable
(specifically a generator which is not a validSequence
):opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/metric_reader_storage.py
Line 160 in 778c4b1
What is the expected behavior?
Type annotated as
Sequence
should work withlen()
, subscription, etc.. A more subtle bug the generator causes is thatdata_points
can only be iterated over once, which will consume the generator.What is the actual behavior?
Additional context
Possible fixes
I'd recommend adding calls to
list()
ortuple()
to convert the generator to a sequence or alter_ViewInstrumentMatch.collect()
to return a sequence itself. I think this is appropriate as the generators are actually holding SDK locks which can remain locked if the generator is not consumed.The text was updated successfully, but these errors were encountered: