mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-16 02:47:20 +02:00
f5b4e99025
Part of #5412 - Use the recommended package name for the instrumentation exemplified in the repository. - Use the recommended detection of a `TracerProvider` from passed context.
30 lines
606 B
Go
30 lines
606 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"go.opentelemetry.io/contrib/bridges/otelslog"
|
|
"go.opentelemetry.io/otel"
|
|
"go.opentelemetry.io/otel/metric"
|
|
)
|
|
|
|
const name = "go.opentelemetry.io/otel/example/dice"
|
|
|
|
var (
|
|
tracer = otel.Tracer(name)
|
|
meter = otel.Meter(name)
|
|
logger = otelslog.NewLogger(name)
|
|
rollCnt metric.Int64Counter
|
|
)
|
|
|
|
func init() {
|
|
var err error
|
|
rollCnt, err = meter.Int64Counter("dice.rolls",
|
|
metric.WithDescription("The number of rolls by roll value"),
|
|
metric.WithUnit("{roll}"))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|