prometheus / OpenMetrics

Evolving the Prometheus exposition format into a standard.
https://openmetrics.io
Apache License 2.0
2.37k stars 171 forks source link

Trailing comma in label sets #251

Open Victor-N-Suadicani opened 2 years ago

Victor-N-Suadicani commented 2 years ago

Prometheus' docs on the exposition format quite clearly allow for a trailing comma in label sets.

However, the exposition format in the spec doesn't seem to allow this.

I think trailing commas are fine and should be allowed. It makes it easier to generate the label set as you can just put a comma after each label without having to worry if there's more labels.

brian-brazil commented 2 years ago

This is on purpose, to keep the grammar as small as we can. At this point it'd be a breaking change to the format to do otherwise.

Victor-N-Suadicani commented 2 years ago

Doesn't it just amount to doing this?

labels = "{" [label *(COMMA label) [COMMA]] "}"

That doesn't seem to make it very much bigger? Or do you mean "small" as in the implementation? I can't imagine this would make it very much more difficult.

Not sure if there's anything to do about the breaking change though.

brian-brazil commented 2 years ago

That's a larger grammar, so more work for all parsers. If every little deviance was allowed for then you end up with a far more complex parser, which is an issue with the Prometheus text format. Accordibgly the OM grammar is strict at little to no cost to exposition. Asking for an extra line of code in exposition isn't much.

On Fri 29 Jul 2022, 11:53 Victor Nordam Suadicani, @.***> wrote:

Doesn't it just amount to doing this?

labels = "{" [label *(COMMA label) [COMMA]] "}"

That doesn't seem to make it very much bigger? Or do you mean "small" as in the implementation? I can't imagine this would make it very much more difficult.

Not sure if there's anything to do about the breaking change though.

— Reply to this email directly, view it on GitHub https://github.com/OpenObservability/OpenMetrics/issues/251#issuecomment-1199140148, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWJG5TOWNM5AYGKKFA4GTTVWOZZZANCNFSM55AAQ2CA . You are receiving this because you commented.Message ID: @.***>