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
Steps to reproduce
Prometheus expects labels to be string key-value pairs.
Currently, the labels are not cast to string for the target_info
Here is a minimal example which causes this problem:
importtimefromprometheus_clientimportstart_http_serverfromopentelemetryimportmetricsfromopentelemetry.exporter.prometheusimportPrometheusMetricReaderfromopentelemetry.sdk.metricsimportMeterProviderfromopentelemetry.sdk.resourcesimportSERVICE_NAME, Resourceresource=Resource(attributes={
SERVICE_NAME: "your-service-name",
"foo": "bar",
"hist": 1,
})
start_http_server(port=8000, addr="localhost")
reader=PrometheusMetricReader()
provider=MeterProvider(resource=resource, metric_readers=[reader])
metrics.set_meter_provider(provider)
meter=metrics.get_meter("my.meter.name")
work_counter=meter.create_counter(
"work.counter", unit="1", description="Counts the amount of work done"
)
whileTrue:
work_counter.add(1, {"work.type": "Debug"})
print("doing some work...")
time.sleep(1)
It raises an exception in the Prometheus client: AttributeError: ("'int' object has no attribute 'replace'", Metric(target, Target metadata, info ... here prometheus_client\openmetrics\exposition.py", line 33, in <listcomp> k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"'))
What is the expected behavior?
Find a string representation for the target_info labels as it is done for the other metrics.
What is the actual behavior?
The target_info labels are exported in their original representation (non-strings).
Additional context
...
The text was updated successfully, but these errors were encountered:
Describe your environment
...
Steps to reproduce
Prometheus expects labels to be string key-value pairs.
Currently, the labels are not cast to string for the
target_info
Here is a minimal example which causes this problem:
It raises an exception in the Prometheus client:
AttributeError: ("'int' object has no attribute 'replace'", Metric(target, Target metadata, info ...
hereprometheus_client\openmetrics\exposition.py", line 33, in <listcomp> k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"'))
What is the expected behavior?
Find a string representation for the
target_info
labels as it is done for the other metrics.What is the actual behavior?
The
target_info
labels are exported in their original representation (non-strings).Additional context
...
The text was updated successfully, but these errors were encountered: