Skip to content

Commit

Permalink
Log incorrect metrics for debugging test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed May 23, 2022
1 parent d65bc3d commit c4ffcb2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions util/metrics/counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestMetricCounter(t *testing.T) {
defer test.Unlock()
// the the loop above we've created a single metric name with five different labels set ( host0, host1 .. host 4)
// let's see if we received all the 5 different labels.
require.Equal(t, 5, len(test.metrics), "Missing metric counts were reported.")
require.Equal(t, 5, len(test.metrics), "Missing metric counts were reported: %+v", test.metrics)

for k, v := range test.metrics {
// we have increased each one of the labels exactly 4 times. See that the counter was counting correctly.
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestMetricCounterFastInts(t *testing.T) {
defer test.Unlock()
// the the loop above we've created a single metric name with five different labels set ( host0, host1 .. host 4)
// let's see if we received all the 5 different labels.
require.Equal(t, 1, len(test.metrics), "Missing metric counts were reported.")
require.Equal(t, 1, len(test.metrics), "Missing metric counts were reported: %+v", test.metrics)

for k, v := range test.metrics {
// we have increased each one of the labels exactly 4 times. See that the counter was counting correctly.
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestMetricCounterMixed(t *testing.T) {
defer test.Unlock()
// the the loop above we've created a single metric name with five different labels set ( host0, host1 .. host 4)
// let's see if we received all the 5 different labels.
require.Equal(t, 1, len(test.metrics), "Missing metric counts were reported.")
require.Equal(t, 1, len(test.metrics), "Missing metric counts were reported: %+v", test.metrics)

for k, v := range test.metrics {
// we have increased each one of the labels exactly 4 times. See that the counter was counting correctly.
Expand Down
2 changes: 1 addition & 1 deletion util/metrics/gauge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestMetricGauge(t *testing.T) {

// the the loop above we've created a single metric name with five different labels set ( host0, host1 .. host 4)
// let's see if we received all the 5 different labels.
require.Equal(t, 5, len(test.metrics), "Missing metric counts were reported.")
require.Equal(t, 5, len(test.metrics), "Missing metric counts were reported: %+v", test.metrics)

// iterate through the metrics and check the each of the metrics reached it's correct count.
for k, v := range test.metrics {
Expand Down
2 changes: 1 addition & 1 deletion util/metrics/segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func testMetricSegmentHelper(t *testing.T, functionTime time.Duration) bool {
// test the metrics values. see if we received all the 4 metrics back correctly.
// we expect the get 4 metrics : test_segment_name1_sec, test_segment_name1_sec_total, test_segment_name1_total and test_segment_name1_concurrent
// ( we don't know in which order they would appear, but the total count should be 4 )
require.Equal(t, 4, len(test.metrics), "Missing metric counts were reported.")
require.Equal(t, 4, len(test.metrics), "Missing metric counts were reported: %+v", test.metrics)

for k, v := range test.metrics {
if strings.Contains(k, "test_segment_name1_sec{") {
Expand Down

0 comments on commit c4ffcb2

Please sign in to comment.