openmetrics-php / exposition-text

Implementation of the text exposition format of OpenMetrics
MIT License
29 stars 8 forks source link

Add openmetrics python parser to integration tests #3

Closed hollodotme closed 5 years ago

hollodotme commented 5 years ago

Expected Behavior

All produces metrics must be able to be parsed by the openmetrics python parser.

Actual Behavior

Metrics are only tested via unit tests.

Specifications

Further comments

The following script is able to parse a file that contains exposed metrics.

Install prometheus_client and forked-path:

pip install prometheus_client forked-path

parseFile.py:

from prometheus_client.openmetrics.parser import text_string_to_metric_families
from path import path

metrics = path('/path/to/metrics.txt').bytes()

for family in text_string_to_metric_families(metrics):
  for sample in family.samples:
    print("Name: {0} Labels: {1} Value: {2} Timestamp: {3}".format(*sample))