1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-07-03 00:27:03 +02:00

Update metrics API to match current spec (#228)

* Update metrics API to match current spec

* update options to match the spec

* drop the global meter API

* more docs

* get rid of leftover mentions about descriptor
This commit is contained in:
Krzesimir Nowak
2019-10-23 08:29:24 +02:00
committed by rghetia
parent a6e139e1d4
commit b3247f04fc
15 changed files with 643 additions and 591 deletions

View File

@ -32,16 +32,16 @@ var (
barKey = key.New("ex.com/bar")
lemonsKey = key.New("ex.com/lemons")
anotherKey = key.New("ex.com/another")
)
oneMetric = metric.NewFloat64Gauge("ex.com/one",
func main() {
oneMetric := meter.NewFloat64Gauge("ex.com.one",
metric.WithKeys(fooKey, barKey, lemonsKey),
metric.WithDescription("A gauge set to 1.0"),
)
measureTwo = metric.NewFloat64Measure("ex.com/two")
)
measureTwo := meter.NewFloat64Measure("ex.com.two")
func main() {
ctx := context.Background()
ctx = distributedcontext.NewContext(ctx,
@ -49,11 +49,13 @@ func main() {
distributedcontext.Insert(barKey.String("bar1")),
)
commonLabels := meter.DefineLabels(ctx, lemonsKey.Int(10))
commonLabels := meter.Labels(ctx, lemonsKey.Int(10))
gauge := oneMetric.GetHandle(commonLabels)
gauge := oneMetric.AcquireHandle(commonLabels)
defer gauge.Release()
measure := measureTwo.GetHandle(commonLabels)
measure := measureTwo.AcquireHandle(commonLabels)
defer measure.Release()
err := tracer.WithSpan(ctx, "operation", func(ctx context.Context) error {