Skip to content

Commit

Permalink
Return 0.0.1 with no version for backwards compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
  • Loading branch information
gouthamve committed Apr 28, 2023
1 parent 5012e7c commit ad42fa5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions expfmt/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
return FmtText
}
if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") {
if ver == OpenMetricsVersion_0_0_1 {
return FmtOpenMetrics_0_0_1
if ver == OpenMetricsVersion_1_0_0 {
return FmtOpenMetrics_1_0_0
}
return FmtOpenMetrics_1_0_0
return FmtOpenMetrics_0_0_1
}
}
return FmtText
Expand Down
2 changes: 1 addition & 1 deletion expfmt/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestNegotiateOpenMetrics(t *testing.T) {
{
name: "OM format, no version",
acceptHeaderValue: "application/openmetrics-text",
expectedFmt: string(FmtOpenMetrics_1_0_0),
expectedFmt: string(FmtOpenMetrics_0_0_1),
},
{
name: "OM format, 0.0.1 version",
Expand Down

0 comments on commit ad42fa5

Please sign in to comment.