-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exception in prometheus exporter AttributeError: 'frozenset' object has no attribute 'items' #2723
Comments
This happens for me, too, when I use the This is the line that is dying for me: https://github.com/open-telemetry/opentelemetry-python/blob/main/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py#L273 as I have changed this line: Line 98 in 7413895
So that it is:
And then I only use I don't know if this is a good change as this is my first time cracking open the SDK. I'm happy to PR. The block essentially becomes: key = frozenset(attributes.items())
if key not in self._attributes_aggregation:
with self._lock:
if key not in self._attributes_aggregation:
if not isinstance(
self._view._aggregation, DefaultAggregation
):
aggregation = (
self._view._aggregation._create_aggregation(
self._instrument,
attributes,
self._start_time_unix_nano,
)
)
else:
aggregation = self._instrument_class_aggregation[
self._instrument.__class__
]._create_aggregation(
self._instrument,
attributes,
self._start_time_unix_nano,
)
self._attributes_aggregation[key] = aggregation
self._attributes_aggregation[key].aggregate(measurement) |
Yes, I had exactly the same experience with otel-exporter too. |
We are in the process of integrating OTLP and hitting this as well. Thank you for finding and taking the time to propose a solution to the issue @agrapsas ! |
@agrapsas The suggested change looks good to me. I believe you are correct and reason frozenset is used there because dict is not hashable for member checking. |
Hi,
Using the code sample from https://github.com/open-telemetry/opentelemetry-python/blob/v1.12.0rc1/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py
when accessing http://localhost:8000 and exception is thrown
File "/Users/m_652923/.pyenv/versions/3.8.9/lib/python3.8/wsgiref/handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "/Users/m_652923/.pyenv/versions/otel/lib/python3.8/site-packages/prometheus_client/exposition.py", line 128, in prometheus_app status, headers, output = _bake_output(registry, accept_header, accept_encoding_header, params, disable_compression) File "/Users/m_652923/.pyenv/versions/otel/lib/python3.8/site-packages/prometheus_client/exposition.py", line 104, in _bake_output output = encoder(registry) File "/Users/m_652923/.pyenv/versions/otel/lib/python3.8/site-packages/prometheus_client/exposition.py", line 197, in generate_latest for metric in registry.collect(): File "/Users/m_652923/.pyenv/versions/otel/lib/python3.8/site-packages/prometheus_client/registry.py", line 97, in collect yield from collector.collect() File "/Users/m_652923/.pyenv/versions/otel/lib/python3.8/site-packages/opentelemetry/exporter/prometheus/__init__.py", line 166, in collect self._translate_to_prometheus( File "/Users/m_652923/.pyenv/versions/otel/lib/python3.8/site-packages/opentelemetry/exporter/prometheus/__init__.py", line 204, in _translate_to_prometheus for key, value in number_data_point.attributes.items(): AttributeError: 'frozenset' object has no attribute 'items'
This also happens when I try an
up_down_counter
The text was updated successfully, but these errors were encountered: