You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
log: Remove Value.AsAny (#4963)
This commit is contained in:
@@ -288,8 +288,6 @@ func MapValue(kvs ...KeyValue) Value
|
||||
|
||||
// Value accessors:
|
||||
|
||||
func (v Value) AsAny() any
|
||||
|
||||
func (v Value) AsString() string
|
||||
|
||||
func (v Value) AsInt64() int64
|
||||
|
||||
@@ -126,31 +126,6 @@ func MapValue(kvs ...KeyValue) Value {
|
||||
}
|
||||
}
|
||||
|
||||
// AsAny returns the value held by v as an any.
|
||||
func (v Value) AsAny() any {
|
||||
switch v.Kind() {
|
||||
case KindMap:
|
||||
return v.asMap()
|
||||
case KindSlice:
|
||||
return v.asSlice()
|
||||
case KindInt64:
|
||||
return v.asInt64()
|
||||
case KindFloat64:
|
||||
return v.asFloat64()
|
||||
case KindString:
|
||||
return v.asString()
|
||||
case KindBool:
|
||||
return v.asBool()
|
||||
case KindBytes:
|
||||
return v.asBytes()
|
||||
case KindEmpty:
|
||||
return nil
|
||||
default:
|
||||
global.Error(errKind, "AsAny", "Kind", v.Kind())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// AsString returns the value held by v as a string.
|
||||
func (v Value) AsString() string {
|
||||
if sp, ok := v.any.(stringptr); ok {
|
||||
|
||||
@@ -26,7 +26,6 @@ var (
|
||||
outV log.Value
|
||||
outKV log.KeyValue
|
||||
|
||||
outAny any
|
||||
outBool bool
|
||||
outFloat64 float64
|
||||
outInt64 int64
|
||||
@@ -58,12 +57,6 @@ func BenchmarkBool(b *testing.B) {
|
||||
outBool = kv.Value.AsBool()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkFloat64(b *testing.B) {
|
||||
@@ -89,12 +82,6 @@ func BenchmarkFloat64(b *testing.B) {
|
||||
outFloat64 = kv.Value.AsFloat64()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkInt(b *testing.B) {
|
||||
@@ -120,12 +107,6 @@ func BenchmarkInt(b *testing.B) {
|
||||
outInt64 = kv.Value.AsInt64()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkInt64(b *testing.B) {
|
||||
@@ -151,12 +132,6 @@ func BenchmarkInt64(b *testing.B) {
|
||||
outInt64 = kv.Value.AsInt64()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkMap(b *testing.B) {
|
||||
@@ -183,12 +158,6 @@ func BenchmarkMap(b *testing.B) {
|
||||
outMap = kv.Value.AsMap()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkSlice(b *testing.B) {
|
||||
@@ -215,12 +184,6 @@ func BenchmarkSlice(b *testing.B) {
|
||||
outSlice = kv.Value.AsSlice()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkString(b *testing.B) {
|
||||
@@ -246,10 +209,4 @@ func BenchmarkString(b *testing.B) {
|
||||
outStr = kv.Value.AsString()
|
||||
}
|
||||
})
|
||||
b.Run("AsAny", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
outAny = kv.Value.AsAny()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -88,9 +88,6 @@ func TestEmpty(t *testing.T) {
|
||||
t.Run("Value.Empty", func(t *testing.T) {
|
||||
assert.True(t, v.Empty())
|
||||
})
|
||||
t.Run("Value.AsAny", func(t *testing.T) {
|
||||
assert.Nil(t, v.AsAny())
|
||||
})
|
||||
|
||||
t.Run("Bytes", func(t *testing.T) {
|
||||
assert.Nil(t, log.Bytes("b", nil).Value.AsBytes())
|
||||
@@ -298,7 +295,6 @@ func testKV[T any](t *testing.T, key string, val T, kv log.KeyValue) {
|
||||
|
||||
assert.Equal(t, key, kv.Key, "incorrect key")
|
||||
assert.False(t, kv.Value.Empty(), "value empty")
|
||||
assert.Equal(t, kv.Value.AsAny(), T(val), "AsAny wrong value")
|
||||
}
|
||||
|
||||
func TestAllocationLimits(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user