Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
therve committed Apr 1, 2020
1 parent a81d7f5 commit d2692ed
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
from prometheus_client.parser import _parse_sample, _replace_help_escaping


# This copies most of the code from upstream at that version:
# https://github.com/prometheus/client_python/blob/049744296d216e6be65dc8f3d44650310f39c384/prometheus_client/parser.py#L144
# but reverting the behavior to a compatible version, which doesn't change counters to have a total suffix. See
# https://github.com/prometheus/client_python/commit/a4dd93bcc6a0422e10cfa585048d1813909c6786#diff-0adf47ea7f99c66d4866ccb4e557a865L158
def text_fd_to_metric_families(fd):
"""Parse Prometheus text format from a file descriptor.
This is a laxer parser than the main Go parser,
so successful parsing does not imply that the parsed
text meets the specification.
This is a laxer parser than the main Go parser, so successful parsing does
not imply that the parsed text meets the specification.
Yields Metric's.
"""
name = ''
Expand All @@ -20,6 +25,7 @@ def text_fd_to_metric_families(fd):
allowed_names = []

def build_metric(name, documentation, typ, samples):
# This is where the change is happening: we don't munge counters as upstream does.
metric = Metric(name, documentation, typ)
metric.samples = samples
return metric
Expand Down

0 comments on commit d2692ed

Please sign in to comment.