1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Rename otel/label -> otel/attribute (#1541)

* Rename otel/label -> otel/attr

Leave the imported name alone, to avoid a large diff and conflicts

* Better import comment

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* otel/attr -> otel/attribute

* Missed the changelog entry

* Get rid of import renaming

* Merge remaining conflicts

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
Punya Biswal
2021-02-18 12:59:37 -05:00
committed by GitHub
parent 1b5b662136
commit ecf65d7968
123 changed files with 1715 additions and 1715 deletions

View File

@@ -21,8 +21,8 @@ import (
"log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/trace/jaeger"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
@@ -34,9 +34,9 @@ func initTracer() func() {
jaeger.WithCollectorEndpoint("http://localhost:14268/api/traces"),
jaeger.WithProcess(jaeger.Process{
ServiceName: "trace-demo",
Tags: []label.KeyValue{
label.String("exporter", "jaeger"),
label.Float64("float", 312.23),
Tags: []attribute.KeyValue{
attribute.String("exporter", "jaeger"),
attribute.Float64("float", 312.23),
},
}),
jaeger.WithSDK(&sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),

View File

@@ -18,12 +18,12 @@ import (
"context"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
var (
lemonsKey = label.Key("ex.com/lemons")
lemonsKey = attribute.Key("ex.com/lemons")
)
// SubOperation is an example to demonstrate the use of named tracer.

View File

@@ -19,18 +19,18 @@ import (
"log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/example/namedtracer/foo"
"go.opentelemetry.io/otel/exporters/stdout"
"go.opentelemetry.io/otel/label"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
)
var (
fooKey = label.Key("ex.com/foo")
barKey = label.Key("ex.com/bar")
anotherKey = label.Key("ex.com/another")
fooKey = attribute.Key("ex.com/foo")
barKey = attribute.Key("ex.com/bar")
anotherKey = attribute.Key("ex.com/another")
)
var tp *sdktrace.TracerProvider
@@ -68,7 +68,7 @@ func main() {
var span trace.Span
ctx, span = tracer.Start(ctx, "operation")
defer span.End()
span.AddEvent("Nice operation!", trace.WithAttributes(label.Int("bogons", 100)))
span.AddEvent("Nice operation!", trace.WithAttributes(attribute.Int("bogons", 100)))
span.SetAttributes(anotherKey.String("yes"))
if err := foo.SubOperation(ctx); err != nil {
panic(err)

View File

@@ -26,9 +26,9 @@ import (
"google.golang.org/grpc"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp"
"go.opentelemetry.io/otel/exporters/otlp/otlpgrpc"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/propagation"
@@ -109,10 +109,10 @@ func main() {
// labels represent additional key-value descriptors that can be bound to a
// metric observer or recorder.
commonLabels := []label.KeyValue{
label.String("labelA", "chocolate"),
label.String("labelB", "raspberry"),
label.String("labelC", "vanilla"),
commonLabels := []attribute.KeyValue{
attribute.String("labelA", "chocolate"),
attribute.String("labelB", "raspberry"),
attribute.String("labelC", "vanilla"),
}
// Recorder metric example

View File

@@ -23,10 +23,10 @@ import (
"google.golang.org/grpc"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/metric/prometheus"
"go.opentelemetry.io/otel/exporters/otlp"
"go.opentelemetry.io/otel/exporters/otlp/otlpgrpc"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
@@ -41,7 +41,7 @@ func initMeter() {
res, err := resource.New(
ctx,
resource.WithAttributes(label.String("R", "V")),
resource.WithAttributes(attribute.String("R", "V")),
)
if err != nil {
log.Fatal("could not initialize resource:", err)
@@ -94,8 +94,8 @@ func initMeter() {
func main() {
initMeter()
labels := []label.KeyValue{
label.String("label1", "value1"),
labels := []attribute.KeyValue{
attribute.String("label1", "value1"),
}
meter := global.Meter("ex.com/prom-collector")

View File

@@ -22,14 +22,14 @@ import (
"sync"
"time"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/metric/prometheus"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
)
var (
lemonsKey = label.Key("ex.com/lemons")
lemonsKey = attribute.Key("ex.com/lemons")
)
func initMeter() {
@@ -51,7 +51,7 @@ func main() {
meter := global.Meter("ex.com/basic")
observerLock := new(sync.RWMutex)
observerValueToReport := new(float64)
observerLabelsToReport := new([]label.KeyValue)
observerLabelsToReport := new([]attribute.KeyValue)
cb := func(_ context.Context, result metric.Float64ObserverResult) {
(*observerLock).RLock()
value := *observerValueToReport
@@ -66,8 +66,8 @@ func main() {
valuerecorder := metric.Must(meter).NewFloat64ValueRecorder("ex.com.two")
counter := metric.Must(meter).NewFloat64Counter("ex.com.three")
commonLabels := []label.KeyValue{lemonsKey.Int(10), label.String("A", "1"), label.String("B", "2"), label.String("C", "3")}
notSoCommonLabels := []label.KeyValue{lemonsKey.Int(13)}
commonLabels := []attribute.KeyValue{lemonsKey.Int(10), attribute.String("A", "1"), attribute.String("B", "2"), attribute.String("C", "3")}
notSoCommonLabels := []attribute.KeyValue{lemonsKey.Int(13)}
ctx := context.Background()