Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename otel/label -> otel/attribute #1541

Merged
merged 11 commits into from
Feb 18, 2021
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Replaced interface `oteltest.SpanRecorder` with its existing implementation
`StandardSpanRecorder` (#1542).
- Renamed the `otel/label` package to `otel/attribute`. (#1541)

### Added

Expand Down
52 changes: 26 additions & 26 deletions label/benchmark_test.go → attribute/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package label_test
package attribute_test

import (
"testing"

"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/attribute"
)

type test struct{}

var (
arrayVal = []string{"one", "two"}
arrayKeyVal = label.Array("array", arrayVal)
arrayKeyVal = attribute.Array("array", arrayVal)

boolVal = true
boolKeyVal = label.Bool("bool", boolVal)
boolKeyVal = attribute.Bool("bool", boolVal)

intVal = int(1)
intKeyVal = label.Int("int", intVal)
intKeyVal = attribute.Int("int", intVal)

int8Val = int8(1)
int8KeyVal = label.Int("int8", int(int8Val))
int8KeyVal = attribute.Int("int8", int(int8Val))

int16Val = int16(1)
int16KeyVal = label.Int("int16", int(int16Val))
int16KeyVal = attribute.Int("int16", int(int16Val))

int64Val = int64(1)
int64KeyVal = label.Int64("int64", int64Val)
int64KeyVal = attribute.Int64("int64", int64Val)

float64Val = float64(1.0)
float64KeyVal = label.Float64("float64", float64Val)
float64KeyVal = attribute.Float64("float64", float64Val)

stringVal = "string"
stringKeyVal = label.String("string", stringVal)
stringKeyVal = attribute.String("string", stringVal)

bytesVal = []byte("bytes")
structVal = test{}
Expand All @@ -54,112 +54,112 @@ var (
func BenchmarkArrayKey(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Array("array", arrayVal)
_ = attribute.Array("array", arrayVal)
}
}

func BenchmarkArrayKeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("array", arrayVal)
_ = attribute.Any("array", arrayVal)
}
}

func BenchmarkBoolKey(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Bool("bool", boolVal)
_ = attribute.Bool("bool", boolVal)
}
}

func BenchmarkBoolKeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("bool", boolVal)
_ = attribute.Any("bool", boolVal)
}
}

func BenchmarkIntKey(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Int("int", intVal)
_ = attribute.Int("int", intVal)
}
}

func BenchmarkIntKeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("int", intVal)
_ = attribute.Any("int", intVal)
}
}

func BenchmarkInt8KeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("int8", int8Val)
_ = attribute.Any("int8", int8Val)
}
}

func BenchmarkInt16KeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("int16", int16Val)
_ = attribute.Any("int16", int16Val)
}
}

func BenchmarkInt64Key(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Int64("int64", int64Val)
_ = attribute.Int64("int64", int64Val)
}
}

func BenchmarkInt64KeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("int64", int64Val)
_ = attribute.Any("int64", int64Val)
}
}

func BenchmarkFloat64Key(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Float64("float64", float64Val)
_ = attribute.Float64("float64", float64Val)
}
}

func BenchmarkFloat64KeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("float64", float64Val)
_ = attribute.Any("float64", float64Val)
}
}

func BenchmarkStringKey(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.String("string", stringVal)
_ = attribute.String("string", stringVal)
}
}

func BenchmarkStringKeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("string", stringVal)
_ = attribute.Any("string", stringVal)
}
}

func BenchmarkBytesKeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("bytes", bytesVal)
_ = attribute.Any("bytes", bytesVal)
}
}

func BenchmarkStructKeyAny(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = label.Any("struct", structVal)
_ = attribute.Any("struct", structVal)
}
}

Expand Down
4 changes: 2 additions & 2 deletions label/doc.go → attribute/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package label provides key and value labels.
// package attribute provides key and value attributes.
//
// This package is currently in a pre-GA phase. Backwards incompatible changes
// may be introduced in subsequent minor version releases as we work to track
// the evolving OpenTelemetry specification and user feedback.
package label // import "go.opentelemetry.io/otel/label"
package attribute // import "go.opentelemetry.io/otel/attribute"
4 changes: 2 additions & 2 deletions label/encoder.go → attribute/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package label // import "go.opentelemetry.io/otel/label"
package attribute // import "go.opentelemetry.io/otel/attribute"

import (
"bytes"
Expand All @@ -28,7 +28,7 @@ type (
Encoder interface {
// Encode returns the serialized encoding of the label
// set using its Iterator. This result may be cached
// by a label.Set.
// by a attribute.Set.
Encode(iterator Iterator) string

// ID returns a value that is unique for each class of
Expand Down
4 changes: 2 additions & 2 deletions label/iterator.go → attribute/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package label // import "go.opentelemetry.io/otel/label"
package attribute // import "go.opentelemetry.io/otel/attribute"

// Iterator allows iterating over the set of labels in order,
// sorted by key.
Expand Down Expand Up @@ -55,7 +55,7 @@ func (i *Iterator) Attribute() KeyValue {
return i.Label()
}

// IndexedLabel returns current index and label. Must be called only
// IndexedLabel returns current index and attribute. Must be called only
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// IndexedLabel returns current index and attribute. Must be called only
// IndexedAttribute returns current index and attribute. Must be called only

Also the Label() method should be changed to Attribute(). Since these are public API changes I don't think we can defer them.

// after Next returns true.
func (i *Iterator) IndexedLabel() (int, KeyValue) {
return i.idx, i.Label()
Expand Down
22 changes: 11 additions & 11 deletions label/iterator_test.go → attribute/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package label_test
package attribute_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/attribute"
)

func TestIterator(t *testing.T) {
one := label.String("one", "1")
two := label.Int("two", 2)
lbl := label.NewSet(one, two)
one := attribute.String("one", "1")
two := attribute.Int("two", 2)
lbl := attribute.NewSet(one, two)
iter := lbl.Iter()
require.Equal(t, 2, iter.Len())

Expand All @@ -49,7 +49,7 @@ func TestIterator(t *testing.T) {
}

func TestEmptyIterator(t *testing.T) {
lbl := label.NewSet()
lbl := attribute.NewSet()
iter := lbl.Iter()
require.Equal(t, 0, iter.Len())
require.False(t, iter.Next())
Expand All @@ -64,9 +64,9 @@ func TestMergedIterator(t *testing.T) {
expect []string
}

makeLabels := func(keys []string, num int) (result []label.KeyValue) {
makeLabels := func(keys []string, num int) (result []attribute.KeyValue) {
for _, k := range keys {
result = append(result, label.Int(k, num))
result = append(result, attribute.Int(k, num))
}
return
}
Expand Down Expand Up @@ -131,10 +131,10 @@ func TestMergedIterator(t *testing.T) {
labels1 := makeLabels(input.keys1, 1)
labels2 := makeLabels(input.keys2, 2)

set1 := label.NewSet(labels1...)
set2 := label.NewSet(labels2...)
set1 := attribute.NewSet(labels1...)
set2 := attribute.NewSet(labels2...)

merge := label.NewMergeIterator(&set1, &set2)
merge := attribute.NewMergeIterator(&set1, &set2)

var result []string

Expand Down
2 changes: 1 addition & 1 deletion label/key.go → attribute/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package label // import "go.opentelemetry.io/otel/label"
package attribute // import "go.opentelemetry.io/otel/attribute"

// Key represents the key part in key-value pairs. It's a string. The
// allowed character set in the key depends on the use of the key.
Expand Down
Loading