histogram order parse errors
test/input.txt puts the sum and count at the end:
# A histogram, which has a pretty complex representation in the text format:
# HELP http_request_duration_seconds A histogram of the request duration.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320
but @opentelemetry/exporter-prometheus exports count and sum before the buckets.
Moving these in the example
# A histogram, which has a pretty complex representation in the text format:
# HELP http_request_duration_seconds A histogram of the request duration.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
http_request_duration_seconds_bucket{le="+Inf"} 144320
results in parse errors:
TypeError: Cannot set property '0.05' of undefined
at flattenMetrics (node_modules/parse-prometheus-text-format/dist/parse-prometheus-text-format.cjs.js:446:52)
at parsePrometheusTextFormat (node_modules/parse-prometheus-text-format/dist/parse-prometheus-text-format.cjs.js:378:21)
I haven't debugged why yet, but would a PR for this be welcome? I should probably check if this new ordering compliant with the prometheus spec, but if others know that's welcome information 😅 .
Ah, https://github.com/yunyu/parse-prometheus-text-format/blob/22df241b1651de16c9855e9a045a649690d25a96/src/index.js#L170-L171 didn't anticipate https://github.com/yunyu/parse-prometheus-text-format/blob/22df241b1651de16c9855e9a045a649690d25a96/src/index.js#L176 being run first, should be a simple PR 😌