Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
unmarshall committed Feb 19, 2024
1 parent 01dcdfb commit 1a7f952
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/azure/instrument/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package instrument

import (
"errors"
"fmt"
"strconv"
"time"

Expand Down Expand Up @@ -51,6 +52,7 @@ func RecordAzAPIMetric(err error, azServiceName string, invocationTime time.Time

// compute the time taken to complete the AZ service call and record it as a metric
elapsed := time.Since(invocationTime)
fmt.Printf("Elapsed time: %v\n", elapsed)
metrics.APIRequestDuration.WithLabelValues(
prometheusProviderLabelValue,
azServiceName,
Expand Down
3 changes: 3 additions & 0 deletions pkg/azure/instrument/instrument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ func TestAPIMetricRecorderFn(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
defer metrics.APIRequestCount.Reset()
defer metrics.APIFailedRequestCount.Reset()
defer metrics.APIRequestDuration.Reset()
_ = deferredMetricsRecorderInvoker(tc.err != nil, false, AZAPIMetricRecorderFn)
if tc.err != nil {
g.Expect(testutil.CollectAndCount(metrics.APIRequestCount)).To(Equal(0))
g.Expect(testutil.CollectAndCount(metrics.APIFailedRequestCount)).To(Equal(1))
g.Expect(testutil.ToFloat64(metrics.APIFailedRequestCount.WithLabelValues(prometheusProviderLabelValue, serviceName))).To(Equal(float64(1)))
} else {
g.Expect(testutil.CollectAndCount(metrics.APIRequestCount)).To(Equal(1))
g.Expect(testutil.CollectAndCount(metrics.APIFailedRequestCount)).To(Equal(0))
g.Expect(testutil.ToFloat64(metrics.APIRequestCount.WithLabelValues(prometheusProviderLabelValue, serviceName))).To(Equal(float64(1)))
}
})
Expand Down

0 comments on commit 1a7f952

Please sign in to comment.