Skip to content

Commit

Permalink
fix lint errors and failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ymtdzzz committed Sep 8, 2024
1 parent 8aa8259 commit 9628928
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestValidate(t *testing.T) {
OTLPGRPCPort: 4317,
EnableProm: true,
},
want: errors.New("The target endpoints for the prometheus receiver (--prom-target) must be specified when prometheus receiver enabled"),
want: errors.New("the target endpoints for the prometheus receiver (--prom-target) must be specified when prometheus receiver enabled"),
},
}

Expand Down
12 changes: 10 additions & 2 deletions tuiexporter/internal/tui/component/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ func drawMetricHistogramChart(commands *tview.TextView, m *telemetry.MetricData)
txt.SetBorder(true).SetTitle("Attributes")
for bci := 0; bci < dp.BucketCounts().Len(); bci++ {
if bci == dp.BucketCounts().Len()-1 {
ch.AddBar(fmt.Sprintf("%.1f~", dp.ExplicitBounds().At(bci-1)), int(dp.BucketCounts().At(bci)), tcell.ColorYellow)
ch.AddBar(fmt.Sprintf("%.1f~", dp.ExplicitBounds().At(bci-1)), uint64ToInt(dp.BucketCounts().At(bci)), tcell.ColorYellow)
} else {
ch.AddBar(fmt.Sprintf("%.1f", dp.ExplicitBounds().At(bci)), int(dp.BucketCounts().At(bci)), tcell.ColorYellow)
ch.AddBar(fmt.Sprintf("%.1f", dp.ExplicitBounds().At(bci)), uint64ToInt(dp.BucketCounts().At(bci)), tcell.ColorYellow)
}
}
sts.AddItem(tview.NewTextView().SetText(fmt.Sprintf("● max: %.1f", dp.Max())), 1, 1, false)
Expand Down Expand Up @@ -749,3 +749,11 @@ func getDataToDraw(dataMap map[string]map[string][]*pmetric.NumberDataPoint, att
}
return d, txts
}

// uint64ToInt converts uint64 into int. When the input is larger than math.MaxInt, it returns math.MaxInt.
func uint64ToInt(u uint64) int {
if u >= math.MaxInt {
return math.MaxInt
}
return int(u)
}

0 comments on commit 9628928

Please sign in to comment.