Skip to content

Commit

Permalink
added Float64 CounterObserver and UDCounterObserver tests (#2487)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
  • Loading branch information
erichsueh3 and Aneurysm9 committed Jan 10, 2022
1 parent 1e4a609 commit c37f485
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions exporters/prometheus/prometheus_test.go
Expand Up @@ -124,11 +124,11 @@ func TestPrometheusExporter(t *testing.T) {

expected = append(expected, expectCounter("counter", `counter{A="B",C="D",R="V"} 15.3`))

_ = metric.Must(meter).NewInt64GaugeObserver("intobserver", func(_ context.Context, result metric.Int64ObserverResult) {
_ = metric.Must(meter).NewInt64GaugeObserver("intgaugeobserver", func(_ context.Context, result metric.Int64ObserverResult) {
result.Observe(1, labels...)
})

expected = append(expected, expectGauge("intobserver", `intobserver{A="B",C="D",R="V"} 1`))
expected = append(expected, expectGauge("intgaugeobserver", `intgaugeobserver{A="B",C="D",R="V"} 1`))

histogram.Record(ctx, -0.6, labels...)
histogram.Record(ctx, -0.4, labels...)
Expand All @@ -148,6 +148,18 @@ func TestPrometheusExporter(t *testing.T) {

expected = append(expected, expectGauge("updowncounter", `updowncounter{A="B",C="D",R="V"} 6.8`))

_ = metric.Must(meter).NewFloat64CounterObserver("floatcounterobserver", func(_ context.Context, result metric.Float64ObserverResult) {
result.Observe(7.7, labels...)
})

expected = append(expected, expectCounter("floatcounterobserver", `floatcounterobserver{A="B",C="D",R="V"} 7.7`))

_ = metric.Must(meter).NewFloat64UpDownCounterObserver("floatupdowncounterobserver", func(_ context.Context, result metric.Float64ObserverResult) {
result.Observe(-7.7, labels...)
})

expected = append(expected, expectGauge("floatupdowncounterobserver", `floatupdowncounterobserver{A="B",C="D",R="V"} -7.7`))

compareExport(t, exporter, expected)
compareExport(t, exporter, expected)
}
Expand Down

0 comments on commit c37f485

Please sign in to comment.