Skip to content

Commit

Permalink
DAOS-16451 telemetry: Adjust type of (_sum|_sumsquares) (#15028)
Browse files Browse the repository at this point in the history
These stats metrics should be Counter rather than Gauge,
as their values will only increase.

Also includes a small fix for pem_test.go to set the
test dir permissions explicitly irrespective of umask.

Signed-off-by: Michael MacDonald <[email protected]>
  • Loading branch information
mjmac authored Aug 29, 2024
1 parent c101392 commit ec092d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/control/lib/telemetry/promexp/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,18 @@ func getMetricStats(baseName string, m telemetry.Metric) (stats []*metricStat) {
desc: " (mean)",
},
"sum": {
fn: func() float64 { return float64(ms.Sum()) },
desc: " (sum)",
fn: func() float64 { return float64(ms.Sum()) },
isCounter: true,
desc: " (sum)",
},
"stddev": {
fn: ms.StdDev,
desc: " (std dev)",
},
"sumsquares": {
fn: ms.SumSquares,
desc: " (sum of squares)",
fn: ms.SumSquares,
isCounter: true,
desc: " (sum of squares)",
},
"samples": {
fn: func() float64 { return float64(ms.SampleSize()) },
Expand Down
14 changes: 8 additions & 6 deletions src/control/lib/telemetry/promexp/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ func TestPromExp_getMetricStats(t *testing.T) {
value: 3.0,
},
{
name: "stats_gauge_sum",
desc: " (sum)",
value: 15.0,
name: "stats_gauge_sum",
desc: " (sum)",
value: 15.0,
isCounter: true,
},
{
name: "stats_gauge_samples",
Expand All @@ -104,9 +105,10 @@ func TestPromExp_getMetricStats(t *testing.T) {
value: 1.58113883,
},
{
name: "stats_gauge_sumsquares",
desc: " (sum of squares)",
value: 55,
name: "stats_gauge_sumsquares",
desc: " (sum of squares)",
value: 55,
isCounter: true,
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions src/control/security/pem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ func TestSecurity_Pem_ValidateCertDirectory(t *testing.T) {
if err := os.Mkdir(testDir, tc.perms); err != nil {
t.Fatal(err)
}
// Use chmod to set the permissions regardless of umask.
if err := os.Chmod(testDir, tc.perms); err != nil {
t.Fatal(err)
}
testFile := test.CreateTestFile(t, dir, "some content")

path := testDir
Expand Down

0 comments on commit ec092d1

Please sign in to comment.