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
Introduce metric constructor errors, MeterMust
wrapper (#529)
* Update api for Must constructors, with SDK helpers * Update for Must constructors, leaving TODOs about global errors * Add tests * Move Must methods into metric.Must * Apply the feedback * Remove interfaces * Remove more interfaces * Again... * Remove a sentence about a dead inteface
This commit is contained in:
@ -67,9 +67,6 @@ func main() {
|
||||
defer initMeter().Stop()
|
||||
initTracer()
|
||||
|
||||
// Note: Have to get the meter and tracer after the global is
|
||||
// initialized. See OTEP 0005.
|
||||
|
||||
tracer := global.Tracer("ex.com/basic")
|
||||
meter := global.Meter("ex.com/basic")
|
||||
|
||||
@ -78,13 +75,13 @@ func main() {
|
||||
oneMetricCB := func(result metric.Float64ObserverResult) {
|
||||
result.Observe(1, commonLabels)
|
||||
}
|
||||
oneMetric := meter.RegisterFloat64Observer("ex.com.one", oneMetricCB,
|
||||
oneMetric := metric.Must(meter).RegisterFloat64Observer("ex.com.one", oneMetricCB,
|
||||
metric.WithKeys(fooKey, barKey, lemonsKey),
|
||||
metric.WithDescription("An observer set to 1.0"),
|
||||
)
|
||||
defer oneMetric.Unregister()
|
||||
|
||||
measureTwo := meter.NewFloat64Measure("ex.com.two")
|
||||
measureTwo := metric.Must(meter).NewFloat64Measure("ex.com.two")
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
|
Reference in New Issue
Block a user