Emit native histograms only when OM 2.0.0 is requested by vesari · Pull Request #1128 · prometheus/client_python

This PR addresses issue #1122 . In the present implementation, if the OM version negotiated is < 2.0.0, native histogram samples are completely ignored during the exposition.

As agreed with @csmarchbanks, I choose the approach of adding a version parameter to the generate_latest function, which this way can be intended as "generating the latest of a major version".

I added some tests; probably the test_native_histogram_version_comparison is a bit redundant, but gives an immediate idea of the different outputs depending on the OM version selected.

I foresee more tests should be added based on whatever OM v1.0.0 vs v2.0.0 differences/divergent expected behaviours are going to be there.