Skip to content

WIP: Text format parser for Python#54

Merged
brian-brazil merged 4 commits into
masterfrom
parser
Oct 9, 2015
Merged

WIP: Text format parser for Python#54
brian-brazil merged 4 commits into
masterfrom
parser

Conversation

@brian-brazil

Copy link
Copy Markdown
Contributor

@beorn7 Would you mind taking a peek at this to see if I've missed anything major? Main code is in parser.py, the rest is surrounding changes for this to make sense and have the right data structures.

The motivation is that Zalando's Zmon has a partial implementation of the text parser, so I'd like to offer them an official option.

@beorn7

beorn7 commented Oct 5, 2015

Copy link
Copy Markdown
Contributor

I'll have a look ASAP.

Comment thread prometheus_client/core.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has nothing to do with the change, but: Why typ and not type?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NM, keywords are evil... :-(

@beorn7

beorn7 commented Oct 7, 2015

Copy link
Copy Markdown
Contributor

Before checking further: Let's confirm what the intention WRT whitespace is. The text format is supposed to have any amount of non-new-line whitespace between tokens. text_parse_test.go includes things like

 # HELP  name2      doc str"ing 2
  #    TYPE    name2 gauge
name2{labelname="val2"  ,basename   =   "basevalue2"        } +Inf 54321
name2{ labelname = "val1" , }-Inf

@beorn7

beorn7 commented Oct 8, 2015

Copy link
Copy Markdown
Contributor

OK, looks sane to me. Just sprinkle a few crazy whitespace characters over the test cases to see if it works.

@brian-brazil

Copy link
Copy Markdown
Contributor Author

The test_spaces test should cover that. If we ever make a breaking change to the text format, it'd be good to get rid of all this space flexibility from a parsing standpoint.

@beorn7

beorn7 commented Oct 8, 2015

Copy link
Copy Markdown
Contributor

Ah, didn't see that... with the pre-squashed commits, it's difficult to see what has changed...

👍

But definitely leave the whitespace flexibility in place. That's what people expect when they see this kind of syntax. Remember that the text format is also meant to be easy for humans to assemble.

Split out test files.
Add missing histogram exposition test.
Add unittests for metric families.
Fix exposition of 'NaN' in text format (Python uses 'nan').
brian-brazil added a commit that referenced this pull request Oct 9, 2015
WIP: Text format parser for Python
@brian-brazil brian-brazil merged commit ac1c45f into master Oct 9, 2015
@brian-brazil brian-brazil deleted the parser branch October 9, 2015 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants