1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00

added Float64 CounterObserver and UDCounterObserver tests (#2487)

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
Eric Hsueh 2022-01-10 15:22:31 -08:00 committed by GitHub
parent 1e4a609495
commit c37f485678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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...)
@ -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)
}