refactor(test): add lint rule for messages starting with the component (#2045)

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
LaurentiuNiculae
2023-12-08 00:05:02 -08:00
committed by GitHub
parent 262a904286
commit 79e14027ee
81 changed files with 855 additions and 681 deletions
+4 -2
View File
@@ -157,7 +157,8 @@ func (ms *metricServer) SendMetric(mfunc interface{}) {
if ms.enabled {
mfn, ok := mfunc.(func())
if !ok {
ms.log.Error().Err(errors.ErrInvalidMetric).Msg("type conversion")
ms.log.Error().Err(errors.ErrInvalidMetric).
Msgf("failed to cast type, expected '%T' but got '%T'", func() {}, mfunc)
return
}
@@ -169,7 +170,8 @@ func (ms *metricServer) SendMetric(mfunc interface{}) {
func (ms *metricServer) ForceSendMetric(mfunc interface{}) {
mfn, ok := mfunc.(func())
if !ok {
ms.log.Error().Err(errors.ErrInvalidMetric).Msg("type conversion")
ms.log.Error().Err(errors.ErrInvalidMetric).
Msgf("failed to cast type, expected '%T' but got '%T'", func() {}, mfunc)
return
}
+4 -4
View File
@@ -354,7 +354,7 @@ func (ms *metricServer) CounterInc(cv *CounterValue) {
if err != nil {
// The last thing we want is to panic/stop the server due to instrumentation
// thus log a message (should be detected during development of new metrics)
ms.log.Error().Err(err).Msg("Instrumentation error")
ms.log.Error().Err(err).Msg("failed due to instrumentation error")
return
}
@@ -374,7 +374,7 @@ func (ms *metricServer) GaugeSet(gv *GaugeValue) {
err := sanityChecks(gv.Name, labels, ok, gv.LabelNames, gv.LabelValues)
if err != nil {
ms.log.Error().Err(err).Msg("Instrumentation error")
ms.log.Error().Err(err).Msg("failed due to instrumentation error")
return
}
@@ -393,7 +393,7 @@ func (ms *metricServer) SummaryObserve(sv *SummaryValue) {
err := sanityChecks(sv.Name, labels, ok, sv.LabelNames, sv.LabelValues)
if err != nil {
ms.log.Error().Err(err).Msg("Instrumentation error")
ms.log.Error().Err(err).Msg("failed due to instrumentation error")
return
}
@@ -414,7 +414,7 @@ func (ms *metricServer) HistogramObserve(hv *HistogramValue) {
err := sanityChecks(hv.Name, labels, ok, hv.LabelNames, hv.LabelValues)
if err != nil {
ms.log.Error().Err(err).Msg("Instrumentation error")
ms.log.Error().Err(err).Msg("failed due to instrumentation error")
return
}
+2 -2
View File
@@ -70,12 +70,12 @@ func (mc *MetricsClient) GetMetrics() (*MetricsInfo, error) {
func (mc *MetricsClient) makeGETRequest(url string, resultsPtr interface{}) (http.Header, error) {
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil)
if err != nil {
return nil, fmt.Errorf("metric scraping: %w", err)
return nil, fmt.Errorf("metric scraping failed: %w", err)
}
resp, err := mc.config.HTTPClient.Do(req)
if err != nil {
return nil, fmt.Errorf("metric scraping error: %w", err)
return nil, fmt.Errorf("metric scraping failed: %w", err)
}
defer resp.Body.Close()
+2 -2
View File
@@ -477,11 +477,11 @@ func TestPopulateStorageMetrics(t *testing.T) {
// Wait for storage metrics to update
found, err := test.ReadLogFileAndSearchString(logPath,
"monitoring: computed storage usage for repo alpine", time.Minute)
"computed storage usage for repo alpine", time.Minute)
So(err, ShouldBeNil)
So(found, ShouldBeTrue)
found, err = test.ReadLogFileAndSearchString(logPath,
"monitoring: computed storage usage for repo busybox", time.Minute)
"computed storage usage for repo busybox", time.Minute)
So(err, ShouldBeNil)
So(found, ShouldBeTrue)