You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +02:00
Drop the gauge instrument (#537)
* drop gauge instrument * Restore the benchmark and stress test for lastvalue aggregator, but remove monotonic last-value support * Rename gauge->lastvalue and remove remaining uses of the word 'gauge' Co-authored-by: Krzesimir Nowak <krzesimir@kinvolk.io>
This commit is contained in:
@ -73,10 +73,16 @@ func main() {
|
||||
tracer := global.TraceProvider().Tracer("ex.com/basic")
|
||||
meter := global.MeterProvider().Meter("ex.com/basic")
|
||||
|
||||
oneMetric := meter.NewFloat64Gauge("ex.com.one",
|
||||
commonLabels := meter.Labels(lemonsKey.Int(10), key.String("A", "1"), key.String("B", "2"), key.String("C", "3"))
|
||||
|
||||
oneMetricCB := func(result metric.Float64ObserverResult) {
|
||||
result.Observe(1, commonLabels)
|
||||
}
|
||||
oneMetric := meter.RegisterFloat64Observer("ex.com.one", oneMetricCB,
|
||||
metric.WithKeys(fooKey, barKey, lemonsKey),
|
||||
metric.WithDescription("A gauge set to 1.0"),
|
||||
metric.WithDescription("An observer set to 1.0"),
|
||||
)
|
||||
defer oneMetric.Unregister()
|
||||
|
||||
measureTwo := meter.NewFloat64Measure("ex.com.two")
|
||||
|
||||
@ -87,11 +93,6 @@ func main() {
|
||||
barKey.String("bar1"),
|
||||
)
|
||||
|
||||
commonLabels := meter.Labels(lemonsKey.Int(10), key.String("A", "1"), key.String("B", "2"), key.String("C", "3"))
|
||||
|
||||
gauge := oneMetric.Bind(commonLabels)
|
||||
defer gauge.Unbind()
|
||||
|
||||
measure := measureTwo.Bind(commonLabels)
|
||||
defer measure.Unbind()
|
||||
|
||||
@ -101,14 +102,11 @@ func main() {
|
||||
|
||||
trace.SpanFromContext(ctx).SetAttributes(anotherKey.String("yes"))
|
||||
|
||||
gauge.Set(ctx, 1)
|
||||
|
||||
meter.RecordBatch(
|
||||
// Note: call-site variables added as context Entries:
|
||||
correlation.NewContext(ctx, anotherKey.String("xyz")),
|
||||
commonLabels,
|
||||
|
||||
oneMetric.Measurement(1.0),
|
||||
measureTwo.Measurement(2.0),
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user