Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Wise-Wizard <[email protected]>
  • Loading branch information
Wise-Wizard committed Aug 8, 2024
1 parent ea6abf0 commit 1b86263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions internal/metrics/otelmetrics/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewFactory(meterProvider metric.MeterProvider) metrics.Factory {
func (f *otelFactory) Counter(opts metrics.Options) metrics.Counter {
name := CounterNamingConvention(f.subScope(opts.Name))
counter, err := f.meter.Int64Counter(name)
counter.Add(context.Background(), 1)
counter.Add(context.Background(), 1, attributeSetOption(f.mergeTags(opts.Tags)))
if err != nil {
log.Printf("Error creating OTEL counter: %v", err)
return metrics.NullCounter
Expand Down Expand Up @@ -64,7 +64,7 @@ func (f *otelFactory) Gauge(opts metrics.Options) metrics.Gauge {
func (f *otelFactory) Histogram(opts metrics.HistogramOptions) metrics.Histogram {
name := f.subScope(opts.Name)
histogram, err := f.meter.Float64Histogram(name)
histogram.Record(context.Background(), 1.0)
histogram.Record(context.Background(), 1.0, attributeSetOption(f.mergeTags(opts.Tags)))
if err != nil {
log.Printf("Error creating OTEL histogram: %v", err)
return metrics.NullHistogram
Expand All @@ -80,7 +80,7 @@ func (f *otelFactory) Histogram(opts metrics.HistogramOptions) metrics.Histogram
func (f *otelFactory) Timer(opts metrics.TimerOptions) metrics.Timer {
name := f.subScope(opts.Name)
timer, err := f.meter.Float64Histogram(name, metric.WithUnit("s"))
timer.Record(context.Background(), 1.0)
timer.Record(context.Background(), 1.0, attributeSetOption(f.mergeTags(opts.Tags)))
if err != nil {
log.Printf("Error creating OTEL timer: %v", err)
return metrics.NullTimer
Expand Down
8 changes: 4 additions & 4 deletions internal/metrics/otelmetrics/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestCounter(t *testing.T) {

testCounter := findMetric(t, registry, "test_counter_total")
metrics := testCounter.GetMetric()
assert.Equal(t, float64(2), metrics[0].GetCounter().GetValue())
assert.Equal(t, float64(3), metrics[0].GetCounter().GetValue())
expectedLabels := map[string]string{
"tag1": "value1",
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestHistogram(t *testing.T) {
testHistogram := findMetric(t, registry, "test_histogram")

metrics := testHistogram.GetMetric()
assert.Equal(t, float64(1), metrics[0].GetHistogram().GetSampleSum())
assert.Equal(t, float64(2), metrics[0].GetHistogram().GetSampleSum())
expectedLabels := map[string]string{
"tag1": "value1",
}
Expand All @@ -168,7 +168,7 @@ func TestTimer(t *testing.T) {
testTimer := findMetric(t, registry, "test_timer_seconds")

metrics := testTimer.GetMetric()
assert.Equal(t, float64(0.1), metrics[0].GetHistogram().GetSampleSum())
assert.Equal(t, float64(1.1), metrics[0].GetHistogram().GetSampleSum())
expectedLabels := map[string]string{
"tag1": "value1",
}
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestNamespace(t *testing.T) {
testCounter := findMetric(t, registry, tc.expectedName)

metrics := testCounter.GetMetric()
assert.Equal(t, float64(1), metrics[0].GetCounter().GetValue())
assert.Equal(t, float64(2), metrics[0].GetCounter().GetValue())
assert.Equal(t, tc.expectedLabels, promLabelsToMap(metrics[0].GetLabel()))
})
}
Expand Down

0 comments on commit 1b86263

Please sign in to comment.