From d99ac0993ef027dc9d4fac95b2accbbc2fc15572 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Fri, 24 Jul 2020 12:25:27 -0700 Subject: [PATCH] Remove sub-package value from kv (#968) * Remove sub-package value from kv * Update refs to `go.opentelemetry.io/api/kv/value` * Update Changelog --- CHANGELOG.md | 1 + .../correlation_context_propagator_test.go | 6 +- api/correlation/map.go | 5 +- api/correlation/map_test.go | 4 +- api/global/internal/meter_test.go | 8 +- api/kv/key.go | 26 ++-- api/kv/key_test.go | 30 ++-- api/kv/kv.go | 4 +- api/kv/kv_test.go | 49 ++++--- api/kv/{value => }/type_string.go | 2 +- api/kv/{value => }/value.go | 42 +++--- api/kv/{value => }/value_test.go | 58 ++++---- api/label/encoder.go | 4 +- api/label/set.go | 10 +- api/trace/testtrace/event.go | 4 +- api/trace/testtrace/span.go | 10 +- api/trace/testtrace/span_test.go | 16 +-- api/trace/testtrace/tracer.go | 4 +- .../otlp/internal/transform/attribute.go | 12 +- exporters/trace/jaeger/env.go | 11 +- exporters/trace/jaeger/env_test.go | 45 +++--- exporters/trace/jaeger/jaeger.go | 17 ++- instrumentation/grpctrace/interceptor_test.go | 133 +++++++++--------- sdk/resource/resource_test.go | 6 +- sdk/trace/span.go | 5 +- sdk/trace/trace_test.go | 3 +- 26 files changed, 239 insertions(+), 276 deletions(-) rename api/kv/{value => }/type_string.go (98%) rename api/kv/{value => }/value.go (89%) rename api/kv/{value => }/value_test.go (86%) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa84e16d2d..ac70e572c56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Removed - Removed dependency on `github.com/open-telemetry/opentelemetry-collector`. (#943) +- Removed `go.opentelemetry.io/otel/api/kv/value` by flattening all value functionality and structures into the `go.opentelemetry.io/otel/api/kv` package. (#968) ## [0.8.0] - 2020-07-09 diff --git a/api/correlation/correlation_context_propagator_test.go b/api/correlation/correlation_context_propagator_test.go index e5569c0ade2..e6d7804b88a 100644 --- a/api/correlation/correlation_context_propagator_test.go +++ b/api/correlation/correlation_context_propagator_test.go @@ -20,8 +20,6 @@ import ( "strings" "testing" - "go.opentelemetry.io/otel/api/kv/value" - "github.com/google/go-cmp/cmp" "go.opentelemetry.io/otel/api/correlation" @@ -105,7 +103,7 @@ func TestExtractValidDistributedContextFromHTTPReq(t *testing.T) { totalDiff := "" wantCorCtx.Foreach(func(keyValue kv.KeyValue) bool { val, _ := gotCorCtx.Value(keyValue.Key) - diff := cmp.Diff(keyValue, kv.KeyValue{Key: keyValue.Key, Value: val}, cmp.AllowUnexported(value.Value{})) + diff := cmp.Diff(keyValue, kv.KeyValue{Key: keyValue.Key, Value: val}, cmp.AllowUnexported(kv.Value{})) if diff != "" { totalDiff += diff + "\n" } @@ -166,7 +164,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) { totalDiff := "" wantCorCtx.Foreach(func(keyValue kv.KeyValue) bool { val, _ := gotCorCtx.Value(keyValue.Key) - diff := cmp.Diff(keyValue, kv.KeyValue{Key: keyValue.Key, Value: val}, cmp.AllowUnexported(value.Value{})) + diff := cmp.Diff(keyValue, kv.KeyValue{Key: keyValue.Key, Value: val}, cmp.AllowUnexported(kv.Value{})) if diff != "" { totalDiff += diff + "\n" } diff --git a/api/correlation/map.go b/api/correlation/map.go index 93e92eedde8..2bbb0435611 100644 --- a/api/correlation/map.go +++ b/api/correlation/map.go @@ -16,10 +16,9 @@ package correlation import ( "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" ) -type rawMap map[kv.Key]value.Value +type rawMap map[kv.Key]kv.Value type keySet map[kv.Key]struct{} // Map is an immutable storage for correlations. @@ -147,7 +146,7 @@ func getNewMapSize(m rawMap, delSet, addSet keySet) int { // Value gets a value from correlations map and returns a boolean // value indicating whether the key exist in the map. -func (m Map) Value(k kv.Key) (value.Value, bool) { +func (m Map) Value(k kv.Key) (kv.Value, bool) { value, ok := m.m[k] return value, ok } diff --git a/api/correlation/map_test.go b/api/correlation/map_test.go index c886b842dbd..f2eb2abc960 100644 --- a/api/correlation/map_test.go +++ b/api/correlation/map_test.go @@ -18,8 +18,6 @@ import ( "fmt" "testing" - "go.opentelemetry.io/otel/api/kv/value" - "go.opentelemetry.io/otel/api/kv" ) @@ -281,7 +279,7 @@ func getTestCases() []testCase { func makeTestMap(ints []int) Map { r := make(rawMap, len(ints)) for _, v := range ints { - r[kv.Key(fmt.Sprintf("key%d", v))] = value.Int(v) + r[kv.Key(fmt.Sprintf("key%d", v))] = kv.IntValue(v) } return newMap(r) } diff --git a/api/global/internal/meter_test.go b/api/global/internal/meter_test.go index 5413ac25fbe..6bc65c350cb 100644 --- a/api/global/internal/meter_test.go +++ b/api/global/internal/meter_test.go @@ -22,8 +22,6 @@ import ( "io/ioutil" "testing" - "go.opentelemetry.io/otel/api/kv/value" - "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/api/global" @@ -39,7 +37,7 @@ type measured struct { Name string InstrumentationName string InstrumentationVersion string - Labels map[kv.Key]value.Value + Labels map[kv.Key]kv.Value Number metric.Number } @@ -59,8 +57,8 @@ func asStructs(batches []metrictest.Batch) []measured { return r } -func asMap(kvs ...kv.KeyValue) map[kv.Key]value.Value { - m := map[kv.Key]value.Value{} +func asMap(kvs ...kv.KeyValue) map[kv.Key]kv.Value { + m := map[kv.Key]kv.Value{} for _, kv := range kvs { m[kv.Key] = kv.Value } diff --git a/api/kv/key.go b/api/kv/key.go index fb4b9e6cf53..a6ca9499864 100644 --- a/api/kv/key.go +++ b/api/kv/key.go @@ -14,10 +14,6 @@ package kv -import ( - "go.opentelemetry.io/otel/api/kv/value" -) - // 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. type Key string @@ -31,7 +27,7 @@ type Key string func (k Key) Bool(v bool) KeyValue { return KeyValue{ Key: k, - Value: value.Bool(v), + Value: BoolValue(v), } } @@ -44,7 +40,7 @@ func (k Key) Bool(v bool) KeyValue { func (k Key) Int64(v int64) KeyValue { return KeyValue{ Key: k, - Value: value.Int64(v), + Value: Int64Value(v), } } @@ -57,7 +53,7 @@ func (k Key) Int64(v int64) KeyValue { func (k Key) Uint64(v uint64) KeyValue { return KeyValue{ Key: k, - Value: value.Uint64(v), + Value: Uint64Value(v), } } @@ -70,7 +66,7 @@ func (k Key) Uint64(v uint64) KeyValue { func (k Key) Float64(v float64) KeyValue { return KeyValue{ Key: k, - Value: value.Float64(v), + Value: Float64Value(v), } } @@ -83,7 +79,7 @@ func (k Key) Float64(v float64) KeyValue { func (k Key) Int32(v int32) KeyValue { return KeyValue{ Key: k, - Value: value.Int32(v), + Value: Int32Value(v), } } @@ -96,7 +92,7 @@ func (k Key) Int32(v int32) KeyValue { func (k Key) Uint32(v uint32) KeyValue { return KeyValue{ Key: k, - Value: value.Uint32(v), + Value: Uint32Value(v), } } @@ -109,7 +105,7 @@ func (k Key) Uint32(v uint32) KeyValue { func (k Key) Float32(v float32) KeyValue { return KeyValue{ Key: k, - Value: value.Float32(v), + Value: Float32Value(v), } } @@ -122,7 +118,7 @@ func (k Key) Float32(v float32) KeyValue { func (k Key) String(v string) KeyValue { return KeyValue{ Key: k, - Value: value.String(v), + Value: StringValue(v), } } @@ -136,7 +132,7 @@ func (k Key) String(v string) KeyValue { func (k Key) Int(v int) KeyValue { return KeyValue{ Key: k, - Value: value.Int(v), + Value: IntValue(v), } } @@ -150,7 +146,7 @@ func (k Key) Int(v int) KeyValue { func (k Key) Uint(v uint) KeyValue { return KeyValue{ Key: k, - Value: value.Uint(v), + Value: UintValue(v), } } @@ -168,6 +164,6 @@ func (k Key) Defined() bool { func (k Key) Array(v interface{}) KeyValue { return KeyValue{ Key: k, - Value: value.Array(v), + Value: ArrayValue(v), } } diff --git a/api/kv/key_test.go b/api/kv/key_test.go index 277750e02c9..f8c7311c6d3 100644 --- a/api/kv/key_test.go +++ b/api/kv/key_test.go @@ -21,8 +21,6 @@ import ( "go.opentelemetry.io/otel/api/kv" "github.com/stretchr/testify/require" - - "go.opentelemetry.io/otel/api/kv/value" ) func TestDefined(t *testing.T) { @@ -68,47 +66,47 @@ func TestJSONValue(t *testing.T) { func TestEmit(t *testing.T) { for _, testcase := range []struct { name string - v value.Value + v kv.Value want string }{ { name: `test Key.Emit() can emit a string representing self.BOOL`, - v: value.Bool(true), + v: kv.BoolValue(true), want: "true", }, { name: `test Key.Emit() can emit a string representing self.INT32`, - v: value.Int32(42), + v: kv.Int32Value(42), want: "42", }, { name: `test Key.Emit() can emit a string representing self.INT64`, - v: value.Int64(42), + v: kv.Int64Value(42), want: "42", }, { name: `test Key.Emit() can emit a string representing self.UINT32`, - v: value.Uint32(42), + v: kv.Uint32Value(42), want: "42", }, { name: `test Key.Emit() can emit a string representing self.UINT64`, - v: value.Uint64(42), + v: kv.Uint64Value(42), want: "42", }, { name: `test Key.Emit() can emit a string representing self.FLOAT32`, - v: value.Float32(42.1), + v: kv.Float32Value(42.1), want: "42.1", }, { name: `test Key.Emit() can emit a string representing self.FLOAT64`, - v: value.Float64(42.1), + v: kv.Float64Value(42.1), want: "42.1", }, { name: `test Key.Emit() can emit a string representing self.STRING`, - v: value.String("foo"), + v: kv.StringValue("foo"), want: "foo", }, } { @@ -125,7 +123,7 @@ func TestEmit(t *testing.T) { func BenchmarkEmitBool(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - n := value.Bool(i%2 == 0) + n := kv.BoolValue(i%2 == 0) _ = n.Emit() } } @@ -133,7 +131,7 @@ func BenchmarkEmitBool(b *testing.B) { func BenchmarkEmitInt64(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - n := value.Int64(int64(i)) + n := kv.Int64Value(int64(i)) _ = n.Emit() } } @@ -141,7 +139,7 @@ func BenchmarkEmitInt64(b *testing.B) { func BenchmarkEmitUInt64(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - n := value.Uint64(uint64(i)) + n := kv.Uint64Value(uint64(i)) _ = n.Emit() } } @@ -149,7 +147,7 @@ func BenchmarkEmitUInt64(b *testing.B) { func BenchmarkEmitFloat64(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - n := value.Float64(float64(i)) + n := kv.Float64Value(float64(i)) _ = n.Emit() } } @@ -157,7 +155,7 @@ func BenchmarkEmitFloat64(b *testing.B) { func BenchmarkEmitFloat32(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - n := value.Float32(float32(i)) + n := kv.Float32Value(float32(i)) _ = n.Emit() } } diff --git a/api/kv/kv.go b/api/kv/kv.go index 826c2b27591..83ed878b896 100644 --- a/api/kv/kv.go +++ b/api/kv/kv.go @@ -18,14 +18,12 @@ import ( "encoding/json" "fmt" "reflect" - - "go.opentelemetry.io/otel/api/kv/value" ) // KeyValue holds a key and value pair. type KeyValue struct { Key Key - Value value.Value + Value Value } // Bool creates a new key-value pair with a passed name and a bool diff --git a/api/kv/kv_test.go b/api/kv/kv_test.go index 5d6b9d00a5f..40be1ceee51 100644 --- a/api/kv/kv_test.go +++ b/api/kv/kv_test.go @@ -21,7 +21,6 @@ import ( "github.com/google/go-cmp/cmp" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" ) func TestKeyValueConstructors(t *testing.T) { @@ -35,7 +34,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Bool("k1", true), expected: kv.KeyValue{ Key: "k1", - Value: value.Bool(true), + Value: kv.BoolValue(true), }, }, { @@ -43,7 +42,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Int64("k1", 123), expected: kv.KeyValue{ Key: "k1", - Value: value.Int64(123), + Value: kv.Int64Value(123), }, }, { @@ -51,7 +50,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Uint64("k1", 1), expected: kv.KeyValue{ Key: "k1", - Value: value.Uint64(1), + Value: kv.Uint64Value(1), }, }, { @@ -59,7 +58,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Float64("k1", 123.5), expected: kv.KeyValue{ Key: "k1", - Value: value.Float64(123.5), + Value: kv.Float64Value(123.5), }, }, { @@ -67,7 +66,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Int32("k1", 123), expected: kv.KeyValue{ Key: "k1", - Value: value.Int32(123), + Value: kv.Int32Value(123), }, }, { @@ -75,7 +74,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Uint32("k1", 123), expected: kv.KeyValue{ Key: "k1", - Value: value.Uint32(123), + Value: kv.Uint32Value(123), }, }, { @@ -83,7 +82,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Float32("k1", 123.5), expected: kv.KeyValue{ Key: "k1", - Value: value.Float32(123.5), + Value: kv.Float32Value(123.5), }, }, { @@ -91,7 +90,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.String("k1", "123.5"), expected: kv.KeyValue{ Key: "k1", - Value: value.String("123.5"), + Value: kv.StringValue("123.5"), }, }, { @@ -99,7 +98,7 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Int("k1", 123), expected: kv.KeyValue{ Key: "k1", - Value: value.Int(123), + Value: kv.IntValue(123), }, }, { @@ -107,14 +106,14 @@ func TestKeyValueConstructors(t *testing.T) { actual: kv.Uint("k1", 123), expected: kv.KeyValue{ Key: "k1", - Value: value.Uint(123), + Value: kv.UintValue(123), }, }, } for _, test := range tt { t.Run(test.name, func(t *testing.T) { - if diff := cmp.Diff(test.actual, test.expected, cmp.AllowUnexported(value.Value{})); diff != "" { + if diff := cmp.Diff(test.actual, test.expected, cmp.AllowUnexported(kv.Value{})); diff != "" { t.Fatal(diff) } }) @@ -138,79 +137,79 @@ func TestInfer(t *testing.T) { for _, testcase := range []struct { key string value interface{} - wantType value.Type + wantType kv.Type wantValue interface{} }{ { key: "bool type inferred", value: true, - wantType: value.BOOL, + wantType: kv.BOOL, wantValue: true, }, { key: "int64 type inferred", value: int64(42), - wantType: value.INT64, + wantType: kv.INT64, wantValue: int64(42), }, { key: "uint64 type inferred", value: uint64(42), - wantType: value.UINT64, + wantType: kv.UINT64, wantValue: uint64(42), }, { key: "float64 type inferred", value: float64(42.1), - wantType: value.FLOAT64, + wantType: kv.FLOAT64, wantValue: 42.1, }, { key: "int32 type inferred", value: int32(42), - wantType: value.INT32, + wantType: kv.INT32, wantValue: int32(42), }, { key: "uint32 type inferred", value: uint32(42), - wantType: value.UINT32, + wantType: kv.UINT32, wantValue: uint32(42), }, { key: "float32 type inferred", value: float32(42.1), - wantType: value.FLOAT32, + wantType: kv.FLOAT32, wantValue: float32(42.1), }, { key: "string type inferred", value: "foo", - wantType: value.STRING, + wantType: kv.STRING, wantValue: "foo", }, { key: "stringer type inferred", value: builder, - wantType: value.STRING, + wantType: kv.STRING, wantValue: "foo", }, { key: "unknown value serialized as %v", value: nil, - wantType: value.STRING, + wantType: kv.STRING, wantValue: "", }, { key: "JSON struct serialized correctly", value: &jsonifyStruct, - wantType: value.STRING, + wantType: kv.STRING, wantValue: `{"Public":"foo","tagName":"baz","Empty":""}`, }, { key: "Invalid JSON struct falls back to string", value: &invalidStruct, - wantType: value.STRING, + wantType: kv.STRING, wantValue: "&{(0+0i)}", }, } { diff --git a/api/kv/value/type_string.go b/api/kv/type_string.go similarity index 98% rename from api/kv/value/type_string.go rename to api/kv/type_string.go index b7d130d0b4b..7b1d143ef2e 100644 --- a/api/kv/value/type_string.go +++ b/api/kv/type_string.go @@ -1,6 +1,6 @@ // Code generated by "stringer -type=Type"; DO NOT EDIT. -package value +package kv import "strconv" diff --git a/api/kv/value/value.go b/api/kv/value.go similarity index 89% rename from api/kv/value/value.go rename to api/kv/value.go index b3641a1535b..fa44cfd9d52 100644 --- a/api/kv/value/value.go +++ b/api/kv/value.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package value +package kv import ( "encoding/json" @@ -53,40 +53,40 @@ const ( ARRAY // Array value of arbitrary type, use AsArray() to get it. ) -// Bool creates a BOOL Value. -func Bool(v bool) Value { +// BoolValue creates a BOOL Value. +func BoolValue(v bool) Value { return Value{ vtype: BOOL, numeric: internal.BoolToRaw(v), } } -// Int64 creates an INT64 Value. -func Int64(v int64) Value { +// Int64Value creates an INT64 Value. +func Int64Value(v int64) Value { return Value{ vtype: INT64, numeric: internal.Int64ToRaw(v), } } -// Uint64 creates a UINT64 Value. -func Uint64(v uint64) Value { +// Uint64Value creates a UINT64 Value. +func Uint64Value(v uint64) Value { return Value{ vtype: UINT64, numeric: internal.Uint64ToRaw(v), } } -// Float64 creates a FLOAT64 Value. -func Float64(v float64) Value { +// Float64Value creates a FLOAT64 Value. +func Float64Value(v float64) Value { return Value{ vtype: FLOAT64, numeric: internal.Float64ToRaw(v), } } -// Int32 creates an INT32 Value. -func Int32(v int32) Value { +// Int32Value creates an INT32 Value. +func Int32Value(v int32) Value { return Value{ vtype: INT32, numeric: internal.Int32ToRaw(v), @@ -94,7 +94,7 @@ func Int32(v int32) Value { } // Uint32 creates a UINT32 Value. -func Uint32(v uint32) Value { +func Uint32Value(v uint32) Value { return Value{ vtype: UINT32, numeric: internal.Uint32ToRaw(v), @@ -102,7 +102,7 @@ func Uint32(v uint32) Value { } // Float32 creates a FLOAT32 Value. -func Float32(v float32) Value { +func Float32Value(v float32) Value { return Value{ vtype: FLOAT32, numeric: internal.Float32ToRaw(v), @@ -110,7 +110,7 @@ func Float32(v float32) Value { } // String creates a STRING Value. -func String(v string) Value { +func StringValue(v string) Value { return Value{ vtype: STRING, stringly: v, @@ -119,24 +119,24 @@ func String(v string) Value { // Int creates either an INT32 or an INT64 Value, depending on whether // the int type is 32 or 64 bits wide. -func Int(v int) Value { +func IntValue(v int) Value { if unsafe.Sizeof(v) == 4 { - return Int32(int32(v)) + return Int32Value(int32(v)) } - return Int64(int64(v)) + return Int64Value(int64(v)) } // Uint creates either a UINT32 or a UINT64 Value, depending on // whether the uint type is 32 or 64 bits wide. -func Uint(v uint) Value { +func UintValue(v uint) Value { if unsafe.Sizeof(v) == 4 { - return Uint32(uint32(v)) + return Uint32Value(uint32(v)) } - return Uint64(uint64(v)) + return Uint64Value(uint64(v)) } // Array creates an ARRAY value. -func Array(array interface{}) Value { +func ArrayValue(array interface{}) Value { switch reflect.TypeOf(array).Kind() { case reflect.Array, reflect.Slice: isValidType := func() bool { diff --git a/api/kv/value/value_test.go b/api/kv/value_test.go similarity index 86% rename from api/kv/value/value_test.go rename to api/kv/value_test.go index cd9a17dc8d3..5d7e9bb1c3c 100644 --- a/api/kv/value/value_test.go +++ b/api/kv/value_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package value_test +package kv_test import ( "testing" @@ -21,8 +21,6 @@ import ( "go.opentelemetry.io/otel/api/kv" "github.com/google/go-cmp/cmp" - - "go.opentelemetry.io/otel/api/kv/value" ) func TestValue(t *testing.T) { @@ -30,62 +28,62 @@ func TestValue(t *testing.T) { bli := getBitlessInfo(42) for _, testcase := range []struct { name string - value value.Value - wantType value.Type + value kv.Value + wantType kv.Type wantValue interface{} }{ { name: "Key.Bool() correctly returns keys's internal bool value", value: k.Bool(true).Value, - wantType: value.BOOL, + wantType: kv.BOOL, wantValue: true, }, { name: "Key.Array([]bool) correctly return key's internal bool values", value: k.Array([]bool{true, false}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []bool{true, false}, }, { name: "Key.Int64() correctly returns keys's internal int64 value", value: k.Int64(42).Value, - wantType: value.INT64, + wantType: kv.INT64, wantValue: int64(42), }, { name: "Key.Uint64() correctly returns keys's internal uint64 value", value: k.Uint64(42).Value, - wantType: value.UINT64, + wantType: kv.UINT64, wantValue: uint64(42), }, { name: "Key.Float64() correctly returns keys's internal float64 value", value: k.Float64(42.1).Value, - wantType: value.FLOAT64, + wantType: kv.FLOAT64, wantValue: 42.1, }, { name: "Key.Int32() correctly returns keys's internal int32 value", value: k.Int32(42).Value, - wantType: value.INT32, + wantType: kv.INT32, wantValue: int32(42), }, { name: "Key.Uint32() correctly returns keys's internal uint32 value", value: k.Uint32(42).Value, - wantType: value.UINT32, + wantType: kv.UINT32, wantValue: uint32(42), }, { name: "Key.Float32() correctly returns keys's internal float32 value", value: k.Float32(42.1).Value, - wantType: value.FLOAT32, + wantType: kv.FLOAT32, wantValue: float32(42.1), }, { name: "Key.String() correctly returns keys's internal string value", value: k.String("foo").Value, - wantType: value.STRING, + wantType: kv.STRING, wantValue: "foo", }, { @@ -103,61 +101,61 @@ func TestValue(t *testing.T) { { name: "Key.Array([]int64) correctly returns keys's internal int64 values", value: k.Array([]int64{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []int64{42, 43}, }, { name: "KeyArray([]uint64) correctly returns keys's internal uint64 values", value: k.Array([]uint64{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []uint64{42, 43}, }, { name: "Key.Array([]float64) correctly returns keys's internal float64 values", value: k.Array([]float64{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []float64{42, 43}, }, { name: "Key.Array([]int32) correctly returns keys's internal int32 values", value: k.Array([]int32{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []int32{42, 43}, }, { name: "Key.Array([]uint32) correctly returns keys's internal uint32 values", value: k.Array([]uint32{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []uint32{42, 43}, }, { name: "Key.Array([]float32) correctly returns keys's internal float32 values", value: k.Array([]float32{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []float32{42, 43}, }, { name: "Key.Array([]string) correctly return key's internal string values", value: k.Array([]string{"foo", "bar"}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []string{"foo", "bar"}, }, { name: "Key.Array([]int) correctly returns keys's internal signed integral values", value: k.Array([]int{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []int{42, 43}, }, { name: "Key.Array([]uint) correctly returns keys's internal unsigned integral values", value: k.Array([]uint{42, 43}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: []uint{42, 43}, }, { name: "Key.Array([][]int) correctly return key's multi dimensional array", value: k.Array([][]int{{1, 2}, {3, 4}}).Value, - wantType: value.ARRAY, + wantType: kv.ARRAY, wantValue: [][]int{{1, 2}, {3, 4}}, }, } { @@ -175,8 +173,8 @@ func TestValue(t *testing.T) { type bitlessInfo struct { intValue int uintValue uint - signedType value.Type - unsignedType value.Type + signedType kv.Type + unsignedType kv.Type signedValue interface{} unsignedValue interface{} } @@ -186,8 +184,8 @@ func getBitlessInfo(i int) bitlessInfo { return bitlessInfo{ intValue: i, uintValue: uint(i), - signedType: value.INT32, - unsignedType: value.UINT32, + signedType: kv.INT32, + unsignedType: kv.UINT32, signedValue: int32(i), unsignedValue: uint32(i), } @@ -195,8 +193,8 @@ func getBitlessInfo(i int) bitlessInfo { return bitlessInfo{ intValue: i, uintValue: uint(i), - signedType: value.INT64, - unsignedType: value.UINT64, + signedType: kv.INT64, + unsignedType: kv.UINT64, signedValue: int64(i), unsignedValue: uint64(i), } diff --git a/api/label/encoder.go b/api/label/encoder.go index 0c14ee520a2..915b437dd69 100644 --- a/api/label/encoder.go +++ b/api/label/encoder.go @@ -19,7 +19,7 @@ import ( "sync" "sync/atomic" - "go.opentelemetry.io/otel/api/kv/value" + "go.opentelemetry.io/otel/api/kv" ) type ( @@ -119,7 +119,7 @@ func (d *defaultLabelEncoder) Encode(iter Iterator) string { _, _ = buf.WriteRune('=') - if keyValue.Value.Type() == value.STRING { + if keyValue.Value.Type() == kv.STRING { copyAndEscape(buf, keyValue.Value.AsString()) } else { _, _ = buf.WriteString(keyValue.Value.Emit()) diff --git a/api/label/set.go b/api/label/set.go index 5b39287f5a5..2f281e909e9 100644 --- a/api/label/set.go +++ b/api/label/set.go @@ -20,8 +20,6 @@ import ( "sort" "sync" - "go.opentelemetry.io/otel/api/kv/value" - "go.opentelemetry.io/otel/api/kv" ) @@ -114,9 +112,9 @@ func (l *Set) Get(idx int) (kv.KeyValue, bool) { } // Value returns the value of a specified key in this set. -func (l *Set) Value(k kv.Key) (value.Value, bool) { +func (l *Set) Value(k kv.Key) (kv.Value, bool) { if l == nil { - return value.Value{}, false + return kv.Value{}, false } rValue := l.equivalent.reflect() vlen := rValue.Len() @@ -125,13 +123,13 @@ func (l *Set) Value(k kv.Key) (value.Value, bool) { return rValue.Index(idx).Interface().(kv.KeyValue).Key >= k }) if idx >= vlen { - return value.Value{}, false + return kv.Value{}, false } keyValue := rValue.Index(idx).Interface().(kv.KeyValue) if k == keyValue.Key { return keyValue.Value, true } - return value.Value{}, false + return kv.Value{}, false } // HasValue tests whether a key is defined in this set. diff --git a/api/trace/testtrace/event.go b/api/trace/testtrace/event.go index 69e0e1dba67..84598df4252 100644 --- a/api/trace/testtrace/event.go +++ b/api/trace/testtrace/event.go @@ -18,13 +18,11 @@ import ( "time" "go.opentelemetry.io/otel/api/kv" - - "go.opentelemetry.io/otel/api/kv/value" ) // Event encapsulates the properties of calls to AddEvent or AddEventWithTimestamp. type Event struct { Timestamp time.Time Name string - Attributes map[kv.Key]value.Value + Attributes map[kv.Key]kv.Value } diff --git a/api/trace/testtrace/span.go b/api/trace/testtrace/span.go index 9053bfff7e3..66f6e005efa 100644 --- a/api/trace/testtrace/span.go +++ b/api/trace/testtrace/span.go @@ -21,8 +21,6 @@ import ( "sync" "time" - "go.opentelemetry.io/otel/api/kv/value" - "google.golang.org/grpc/codes" "go.opentelemetry.io/otel/api/kv" @@ -48,7 +46,7 @@ type Span struct { endTime time.Time statusCode codes.Code statusMessage string - attributes map[kv.Key]value.Value + attributes map[kv.Key]kv.Value events []Event links map[trace.SpanContext][]kv.KeyValue } @@ -122,7 +120,7 @@ func (s *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, n return } - attributes := make(map[kv.Key]value.Value) + attributes := make(map[kv.Key]kv.Value) for _, attr := range attrs { attributes[attr.Key] = attr.Value @@ -199,11 +197,11 @@ func (s *Span) ParentSpanID() trace.SpanID { // Attributes returns the attributes set on the Span, either at or after creation time. // If the same attribute key was set multiple times, the last call will be used. // Attributes cannot be changed after End has been called on the Span. -func (s *Span) Attributes() map[kv.Key]value.Value { +func (s *Span) Attributes() map[kv.Key]kv.Value { s.lock.RLock() defer s.lock.RUnlock() - attributes := make(map[kv.Key]value.Value) + attributes := make(map[kv.Key]kv.Value) for k, v := range s.attributes { attributes[k] = v diff --git a/api/trace/testtrace/span_test.go b/api/trace/testtrace/span_test.go index 9b46bd6e0c3..e5229e24614 100644 --- a/api/trace/testtrace/span_test.go +++ b/api/trace/testtrace/span_test.go @@ -22,8 +22,6 @@ import ( "testing" "time" - "go.opentelemetry.io/otel/api/kv/value" - "google.golang.org/grpc/codes" "go.opentelemetry.io/otel/api/kv" @@ -161,9 +159,9 @@ func TestSpan(t *testing.T) { expectedEvents := []testtrace.Event{{ Timestamp: testTime, Name: "error", - Attributes: map[kv.Key]value.Value{ - kv.Key("error.type"): value.String(s.typ), - kv.Key("error.message"): value.String(s.msg), + Attributes: map[kv.Key]kv.Value{ + kv.Key("error.type"): kv.StringValue(s.typ), + kv.Key("error.message"): kv.StringValue(s.msg), }, }} e.Expect(subject.Events()).ToEqual(expectedEvents) @@ -192,9 +190,9 @@ func TestSpan(t *testing.T) { expectedEvents := []testtrace.Event{{ Timestamp: testTime, Name: "error", - Attributes: map[kv.Key]value.Value{ - kv.Key("error.type"): value.String("go.opentelemetry.io/otel/internal/testing.TestError"), - kv.Key("error.message"): value.String(errMsg), + Attributes: map[kv.Key]kv.Value{ + kv.Key("error.type"): kv.StringValue("go.opentelemetry.io/otel/internal/testing.TestError"), + kv.Key("error.message"): kv.StringValue(errMsg), }, }} e.Expect(subject.Events()).ToEqual(expectedEvents) @@ -327,7 +325,7 @@ func TestSpan(t *testing.T) { subject, ok := span.(*testtrace.Span) e.Expect(ok).ToBeTrue() - e.Expect(subject.Attributes()).ToEqual(map[kv.Key]value.Value{}) + e.Expect(subject.Attributes()).ToEqual(map[kv.Key]kv.Value{}) }) t.Run("returns the most recently set attributes", func(t *testing.T) { diff --git a/api/trace/testtrace/tracer.go b/api/trace/testtrace/tracer.go index cbb1c88388c..fe383a672df 100644 --- a/api/trace/testtrace/tracer.go +++ b/api/trace/testtrace/tracer.go @@ -19,8 +19,6 @@ import ( "sync" "time" - "go.opentelemetry.io/otel/api/kv/value" - "go.opentelemetry.io/otel/api/kv" "go.opentelemetry.io/otel/api/trace" @@ -82,7 +80,7 @@ func (t *Tracer) Start(ctx context.Context, name string, opts ...trace.StartOpti SpanID: spanID, }, parentSpanID: parentSpanID, - attributes: make(map[kv.Key]value.Value), + attributes: make(map[kv.Key]kv.Value), links: make(map[trace.SpanContext][]kv.KeyValue), } diff --git a/exporters/otlp/internal/transform/attribute.go b/exporters/otlp/internal/transform/attribute.go index d3ef165768c..51ba32f9307 100644 --- a/exporters/otlp/internal/transform/attribute.go +++ b/exporters/otlp/internal/transform/attribute.go @@ -17,8 +17,6 @@ package transform import ( commonpb "go.opentelemetry.io/otel/internal/opentelemetry-proto-gen/common/v1" - "go.opentelemetry.io/otel/api/kv/value" - "go.opentelemetry.io/otel/api/kv" "go.opentelemetry.io/otel/sdk/resource" ) @@ -56,23 +54,23 @@ func toAttribute(v kv.KeyValue) *commonpb.KeyValue { Value: new(commonpb.AnyValue), } switch v.Value.Type() { - case value.BOOL: + case kv.BOOL: result.Value.Value = &commonpb.AnyValue_BoolValue{ BoolValue: v.Value.AsBool(), } - case value.INT64, value.INT32, value.UINT32, value.UINT64: + case kv.INT64, kv.INT32, kv.UINT32, kv.UINT64: result.Value.Value = &commonpb.AnyValue_IntValue{ IntValue: v.Value.AsInt64(), } - case value.FLOAT32: + case kv.FLOAT32: result.Value.Value = &commonpb.AnyValue_DoubleValue{ DoubleValue: float64(v.Value.AsFloat32()), } - case value.FLOAT64: + case kv.FLOAT64: result.Value.Value = &commonpb.AnyValue_DoubleValue{ DoubleValue: v.Value.AsFloat64(), } - case value.STRING: + case kv.STRING: result.Value.Value = &commonpb.AnyValue_StringValue{ StringValue: v.Value.AsString(), } diff --git a/exporters/trace/jaeger/env.go b/exporters/trace/jaeger/env.go index ad99b633ac5..abff351a7c3 100644 --- a/exporters/trace/jaeger/env.go +++ b/exporters/trace/jaeger/env.go @@ -22,7 +22,6 @@ import ( "go.opentelemetry.io/otel/api/global" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" ) // Environment variable names @@ -147,17 +146,17 @@ func parseKeyValue(k, v string) kv.KeyValue { } } -func parseValue(str string) value.Value { +func parseValue(str string) kv.Value { if v, err := strconv.ParseInt(str, 10, 64); err == nil { - return value.Int64(v) + return kv.Int64Value(v) } if v, err := strconv.ParseFloat(str, 64); err == nil { - return value.Float64(v) + return kv.Float64Value(v) } if v, err := strconv.ParseBool(str); err == nil { - return value.Bool(v) + return kv.BoolValue(v) } // Fallback - return value.String(str) + return kv.StringValue(str) } diff --git a/exporters/trace/jaeger/env_test.go b/exporters/trace/jaeger/env_test.go index 9fcfc0c283d..51b459c4ddc 100644 --- a/exporters/trace/jaeger/env_test.go +++ b/exporters/trace/jaeger/env_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" ottest "go.opentelemetry.io/otel/internal/testing" ) @@ -48,7 +47,7 @@ func Test_parseTags(t *testing.T) { expectedTags: []kv.KeyValue{ { Key: "key", - Value: value.String("value"), + Value: kv.StringValue("value"), }, }, }, @@ -58,11 +57,11 @@ func Test_parseTags(t *testing.T) { expectedTags: []kv.KeyValue{ { Key: "k", - Value: value.Int64(math.MaxInt64), + Value: kv.Int64Value(math.MaxInt64), }, { Key: "k2", - Value: value.Int64(math.MinInt64), + Value: kv.Int64Value(math.MinInt64), }, }, }, @@ -72,15 +71,15 @@ func Test_parseTags(t *testing.T) { expectedTags: []kv.KeyValue{ { Key: "k", - Value: value.Float64(math.MaxFloat64), + Value: kv.Float64Value(math.MaxFloat64), }, { Key: "k2", - Value: value.Float64(math.SmallestNonzeroFloat64), + Value: kv.Float64Value(math.SmallestNonzeroFloat64), }, { Key: "k3", - Value: value.Float64(-1.2), + Value: kv.Float64Value(-1.2), }, }, }, @@ -90,27 +89,27 @@ func Test_parseTags(t *testing.T) { expectedTags: []kv.KeyValue{ { Key: "k", - Value: value.String("v"), + Value: kv.StringValue("v"), }, { Key: "k2", - Value: value.Int64(123), + Value: kv.Int64Value(123), }, { Key: "k3", - Value: value.String("v3"), + Value: kv.StringValue("v3"), }, { Key: "k4", - Value: value.Float64(-1.2), + Value: kv.Float64Value(-1.2), }, { Key: "k5", - Value: value.String("not-default"), + Value: kv.StringValue("not-default"), }, { Key: "k6", - Value: value.String("default"), + Value: kv.StringValue("default"), }, }, }, @@ -145,52 +144,52 @@ func Test_parseValue(t *testing.T) { testCases := []struct { name string str string - expected value.Value + expected kv.Value }{ { name: "bool: true", str: "true", - expected: value.Bool(true), + expected: kv.BoolValue(true), }, { name: "bool: false", str: "false", - expected: value.Bool(false), + expected: kv.BoolValue(false), }, { name: "int64: 012340", str: "012340", - expected: value.Int64(12340), + expected: kv.Int64Value(12340), }, { name: "int64: -012340", str: "-012340", - expected: value.Int64(-12340), + expected: kv.Int64Value(-12340), }, { name: "int64: 0", str: "0", - expected: value.Int64(0), + expected: kv.Int64Value(0), }, { name: "float64: -0.1", str: "-0.1", - expected: value.Float64(-0.1), + expected: kv.Float64Value(-0.1), }, { name: "float64: 00.001", str: "00.001", - expected: value.Float64(0.001), + expected: kv.Float64Value(0.001), }, { name: "float64: 1E23", str: "1E23", - expected: value.Float64(1e23), + expected: kv.Float64Value(1e23), }, { name: "string: foo", str: "foo", - expected: value.String("foo"), + expected: kv.StringValue("foo"), }, } diff --git a/exporters/trace/jaeger/jaeger.go b/exporters/trace/jaeger/jaeger.go index 9d9fd325ce2..281adc884d0 100644 --- a/exporters/trace/jaeger/jaeger.go +++ b/exporters/trace/jaeger/jaeger.go @@ -23,7 +23,6 @@ import ( "go.opentelemetry.io/otel/api/global" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" apitrace "go.opentelemetry.io/otel/api/trace" gen "go.opentelemetry.io/otel/exporters/trace/jaeger/internal/gen-go/jaeger" export "go.opentelemetry.io/otel/sdk/export/trace" @@ -295,42 +294,42 @@ func spanDataToThrift(data *export.SpanData) *gen.Span { func keyValueToTag(keyValue kv.KeyValue) *gen.Tag { var tag *gen.Tag switch keyValue.Value.Type() { - case value.STRING: + case kv.STRING: s := keyValue.Value.AsString() tag = &gen.Tag{ Key: string(keyValue.Key), VStr: &s, VType: gen.TagType_STRING, } - case value.BOOL: + case kv.BOOL: b := keyValue.Value.AsBool() tag = &gen.Tag{ Key: string(keyValue.Key), VBool: &b, VType: gen.TagType_BOOL, } - case value.INT32: + case kv.INT32: i := int64(keyValue.Value.AsInt32()) tag = &gen.Tag{ Key: string(keyValue.Key), VLong: &i, VType: gen.TagType_LONG, } - case value.INT64: + case kv.INT64: i := keyValue.Value.AsInt64() tag = &gen.Tag{ Key: string(keyValue.Key), VLong: &i, VType: gen.TagType_LONG, } - case value.UINT32: + case kv.UINT32: i := int64(keyValue.Value.AsUint32()) tag = &gen.Tag{ Key: string(keyValue.Key), VLong: &i, VType: gen.TagType_LONG, } - case value.UINT64: + case kv.UINT64: // we'll ignore the value if it overflows if i := int64(keyValue.Value.AsUint64()); i >= 0 { tag = &gen.Tag{ @@ -339,14 +338,14 @@ func keyValueToTag(keyValue kv.KeyValue) *gen.Tag { VType: gen.TagType_LONG, } } - case value.FLOAT32: + case kv.FLOAT32: f := float64(keyValue.Value.AsFloat32()) tag = &gen.Tag{ Key: string(keyValue.Key), VDouble: &f, VType: gen.TagType_DOUBLE, } - case value.FLOAT64: + case kv.FLOAT64: f := keyValue.Value.AsFloat64() tag = &gen.Tag{ Key: string(keyValue.Key), diff --git a/instrumentation/grpctrace/interceptor_test.go b/instrumentation/grpctrace/interceptor_test.go index fce3be59058..68a812f8c78 100644 --- a/instrumentation/grpctrace/interceptor_test.go +++ b/instrumentation/grpctrace/interceptor_test.go @@ -32,7 +32,6 @@ import ( "google.golang.org/grpc/status" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" export "go.opentelemetry.io/otel/sdk/export/trace" sdktrace "go.opentelemetry.io/otel/sdk/trace" ) @@ -92,119 +91,119 @@ func TestUnaryClientInterceptor(t *testing.T) { checks := []struct { method string name string - expectedAttr map[kv.Key]value.Value - eventsAttr []map[kv.Key]value.Value + expectedAttr map[kv.Key]kv.Value + eventsAttr []map[kv.Key]kv.Value }{ { method: "/github.com.serviceName/bar", name: "github.com.serviceName/bar", - expectedAttr: map[kv.Key]value.Value{ - standard.RPCSystemKey: value.String("grpc"), - standard.RPCServiceKey: value.String("github.com.serviceName"), - standard.RPCMethodKey: value.String("bar"), - standard.NetPeerIPKey: value.String("fake"), - standard.NetPeerPortKey: value.String("connection"), + expectedAttr: map[kv.Key]kv.Value{ + standard.RPCSystemKey: kv.StringValue("grpc"), + standard.RPCServiceKey: kv.StringValue("github.com.serviceName"), + standard.RPCMethodKey: kv.StringValue("bar"), + standard.NetPeerIPKey: kv.StringValue("fake"), + standard.NetPeerPortKey: kv.StringValue("connection"), }, - eventsAttr: []map[kv.Key]value.Value{ + eventsAttr: []map[kv.Key]kv.Value{ { - standard.RPCMessageTypeKey: value.String("SENT"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(req))), + standard.RPCMessageTypeKey: kv.StringValue("SENT"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))), }, { - standard.RPCMessageTypeKey: value.String("RECEIVED"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(reply))), + standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))), }, }, }, { method: "/serviceName/bar", name: "serviceName/bar", - expectedAttr: map[kv.Key]value.Value{ - standard.RPCSystemKey: value.String("grpc"), - standard.RPCServiceKey: value.String("serviceName"), - standard.RPCMethodKey: value.String("bar"), - standard.NetPeerIPKey: value.String("fake"), - standard.NetPeerPortKey: value.String("connection"), + expectedAttr: map[kv.Key]kv.Value{ + standard.RPCSystemKey: kv.StringValue("grpc"), + standard.RPCServiceKey: kv.StringValue("serviceName"), + standard.RPCMethodKey: kv.StringValue("bar"), + standard.NetPeerIPKey: kv.StringValue("fake"), + standard.NetPeerPortKey: kv.StringValue("connection"), }, - eventsAttr: []map[kv.Key]value.Value{ + eventsAttr: []map[kv.Key]kv.Value{ { - standard.RPCMessageTypeKey: value.String("SENT"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(req))), + standard.RPCMessageTypeKey: kv.StringValue("SENT"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))), }, { - standard.RPCMessageTypeKey: value.String("RECEIVED"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(reply))), + standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))), }, }, }, { method: "serviceName/bar", name: "serviceName/bar", - expectedAttr: map[kv.Key]value.Value{ - standard.RPCSystemKey: value.String("grpc"), - standard.RPCServiceKey: value.String("serviceName"), - standard.RPCMethodKey: value.String("bar"), - standard.NetPeerIPKey: value.String("fake"), - standard.NetPeerPortKey: value.String("connection"), + expectedAttr: map[kv.Key]kv.Value{ + standard.RPCSystemKey: kv.StringValue("grpc"), + standard.RPCServiceKey: kv.StringValue("serviceName"), + standard.RPCMethodKey: kv.StringValue("bar"), + standard.NetPeerIPKey: kv.StringValue("fake"), + standard.NetPeerPortKey: kv.StringValue("connection"), }, - eventsAttr: []map[kv.Key]value.Value{ + eventsAttr: []map[kv.Key]kv.Value{ { - standard.RPCMessageTypeKey: value.String("SENT"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(req))), + standard.RPCMessageTypeKey: kv.StringValue("SENT"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))), }, { - standard.RPCMessageTypeKey: value.String("RECEIVED"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(reply))), + standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))), }, }, }, { method: "invalidName", name: "invalidName", - expectedAttr: map[kv.Key]value.Value{ - standard.RPCSystemKey: value.String("grpc"), - standard.NetPeerIPKey: value.String("fake"), - standard.NetPeerPortKey: value.String("connection"), + expectedAttr: map[kv.Key]kv.Value{ + standard.RPCSystemKey: kv.StringValue("grpc"), + standard.NetPeerIPKey: kv.StringValue("fake"), + standard.NetPeerPortKey: kv.StringValue("connection"), }, - eventsAttr: []map[kv.Key]value.Value{ + eventsAttr: []map[kv.Key]kv.Value{ { - standard.RPCMessageTypeKey: value.String("SENT"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(req))), + standard.RPCMessageTypeKey: kv.StringValue("SENT"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))), }, { - standard.RPCMessageTypeKey: value.String("RECEIVED"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(reply))), + standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))), }, }, }, { method: "/github.com.foo.serviceName_123/method", name: "github.com.foo.serviceName_123/method", - expectedAttr: map[kv.Key]value.Value{ - standard.RPCSystemKey: value.String("grpc"), - standard.RPCServiceKey: value.String("github.com.foo.serviceName_123"), - standard.RPCMethodKey: value.String("method"), - standard.NetPeerIPKey: value.String("fake"), - standard.NetPeerPortKey: value.String("connection"), + expectedAttr: map[kv.Key]kv.Value{ + standard.RPCSystemKey: kv.StringValue("grpc"), + standard.RPCServiceKey: kv.StringValue("github.com.foo.serviceName_123"), + standard.RPCMethodKey: kv.StringValue("method"), + standard.NetPeerIPKey: kv.StringValue("fake"), + standard.NetPeerPortKey: kv.StringValue("connection"), }, - eventsAttr: []map[kv.Key]value.Value{ + eventsAttr: []map[kv.Key]kv.Value{ { - standard.RPCMessageTypeKey: value.String("SENT"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(req))), + standard.RPCMessageTypeKey: kv.StringValue("SENT"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))), }, { - standard.RPCMessageTypeKey: value.String("RECEIVED"), - standard.RPCMessageIDKey: value.Int(1), - standard.RPCMessageUncompressedSizeKey: value.Int(proto.Size(proto.Message(reply))), + standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"), + standard.RPCMessageIDKey: kv.IntValue(1), + standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))), }, }, }, @@ -389,7 +388,7 @@ func TestStreamClientInterceptor(t *testing.T) { if attr.Key == standard.RPCMessageTypeKey && attr.Value.AsString() != eventName { t.Errorf("invalid event on index: %d expecting %s event, receive %s event", i, eventName, attr.Value.AsString()) } - if attr.Key == standard.RPCMessageIDKey && attr.Value != value.Int(msgID) { + if attr.Key == standard.RPCMessageIDKey && attr.Value != kv.IntValue(msgID) { t.Errorf("invalid id for message event expected %d received %d", msgID, attr.Value.AsInt32()) } } diff --git a/sdk/resource/resource_test.go b/sdk/resource/resource_test.go index e9b560f1ae2..10222023207 100644 --- a/sdk/resource/resource_test.go +++ b/sdk/resource/resource_test.go @@ -19,8 +19,6 @@ import ( "fmt" "testing" - "go.opentelemetry.io/otel/api/kv/value" - "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" @@ -64,7 +62,7 @@ func TestNew(t *testing.T) { if diff := cmp.Diff( res.Attributes(), c.want, - cmp.AllowUnexported(value.Value{})); diff != "" { + cmp.AllowUnexported(kv.Value{})); diff != "" { t.Fatalf("unwanted result: diff %+v,", diff) } }) @@ -144,7 +142,7 @@ func TestMerge(t *testing.T) { if diff := cmp.Diff( res.Attributes(), c.want, - cmp.AllowUnexported(value.Value{})); diff != "" { + cmp.AllowUnexported(kv.Value{})); diff != "" { t.Fatalf("unwanted result: diff %+v,", diff) } }) diff --git a/sdk/trace/span.go b/sdk/trace/span.go index 3cabdd4a035..6c782d7eef3 100644 --- a/sdk/trace/span.go +++ b/sdk/trace/span.go @@ -26,7 +26,6 @@ import ( "go.opentelemetry.io/otel/api/global" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/kv/value" apitrace "go.opentelemetry.io/otel/api/trace" export "go.opentelemetry.io/otel/sdk/export/trace" "go.opentelemetry.io/otel/sdk/internal" @@ -105,7 +104,7 @@ func (s *span) SetAttributes(attributes ...kv.KeyValue) { func (s *span) SetAttribute(k string, v interface{}) { attr := kv.Infer(k, v) - if attr.Value.Type() != value.INVALID { + if attr.Value.Type() != kv.INVALID { s.SetAttributes(attr) } } @@ -297,7 +296,7 @@ func (s *span) copyToCappedAttributes(attributes ...kv.KeyValue) { s.mu.Lock() defer s.mu.Unlock() for _, a := range attributes { - if a.Value.Type() != value.INVALID { + if a.Value.Type() != kv.INVALID { s.attributes.add(a) } } diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 86a8398bc36..752c80a6707 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -25,7 +25,6 @@ import ( "time" "go.opentelemetry.io/otel/api/global" - "go.opentelemetry.io/otel/api/kv/value" "github.com/google/go-cmp/cmp" "google.golang.org/grpc/codes" @@ -617,7 +616,7 @@ func TestSetSpanStatus(t *testing.T) { func cmpDiff(x, y interface{}) string { return cmp.Diff(x, y, - cmp.AllowUnexported(value.Value{}), + cmp.AllowUnexported(kv.Value{}), cmp.AllowUnexported(export.Event{})) }