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
Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.
I am running from a virtual env with the latest main branch installed (f8d6795).
Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
With the following example code I get the following traceback after the attribute value for my gauge changes
import time
from typing import Iterable
# METRICS
from prometheus_client import start_http_server
from opentelemetry import metrics
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.exporter.prometheus import PrometheusMetricReader#
# METRICS
start_http_server(port=9092, addr='localhost')
metrics.set_meter_provider(MeterProvider(
metric_readers=[PrometheusMetricReader("test")])
)
meter = metrics.get_meter("test")
c = meter.create_counter(name="exceptions", description="number of exceptions caught", unit="1")
staging_attributes = {"environment": "staging"}
c.add(1, {})
b = 1
def gauge_cb(opts: metrics.CallbackOptions) -> Iterable[metrics.Observation]:
global b
b += 1
labels = {"activityId": str(b % 3)}
yield metrics.Observation(1, labels)
gauge = meter.create_observable_gauge(name="activity_state", description="1 while in activity", callbacks=[gauge_cb])
while True:
time.sleep(3)
c.add(1, staging_attributes)
# requests_size.record(100, staging_attributes)
Traceback (most recent call last):
File "/usr/lib/python3.10/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/stupid/venv/lib/python3.10/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 "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/stupid/venv/lib/python3.10/site-packages/prometheus_client/exposition.py", line 104, in _bake_output
output = encoder(registry)
File "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/stupid/venv/lib/python3.10/site-packages/prometheus_client/exposition.py", line 197, in generate_latest
for metric in registry.collect():
File "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/stupid/venv/lib/python3.10/site-packages/prometheus_client/registry.py", line 97, in collect
yield from collector.collect()
File "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py", line 166, in collect
self._translate_to_prometheus(
File "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py", line 204, in _translate_to_prometheus
for key, value in number_data_point.attributes.items():
AttributeError: 'NoneType' object has no attribute 'attributes'
^CTraceback (most recent call last):
File "/home/tony.kinsley/code/github.com/open-telemetry/opentelemetry-python/stupid/metrics-test.py", line 40, in <module>
time.sleep(3)
KeyboardInterrupt
What is the expected behavior?
What did you expect to see?
I expected to be able to export gauge metrics with differing label values based on when the scrape happened
What is the actual behavior?
What did you see instead?
See traceback
Additional context
Add any other context about the problem here.
I assume this is a misunderstanding on my part, but the code is fairly abstracted so its been difficult for me to follow along.
The text was updated successfully, but these errors were encountered:
Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.
I am running from a virtual env with the latest main branch installed (f8d6795).
Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
With the following example code I get the following traceback after the attribute value for my gauge changes
What is the expected behavior?
What did you expect to see?
I expected to be able to export gauge metrics with differing label values based on when the scrape happened
What is the actual behavior?
What did you see instead?
See traceback
Additional context
Add any other context about the problem here.
I assume this is a misunderstanding on my part, but the code is fairly abstracted so its been difficult for me to follow along.
The text was updated successfully, but these errors were encountered: