diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc906ab464..876808ecac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed +- Rename `kv.Infer` to `kv.Any`. (#969) - Jaeger exporter helpers: added InstallNewPipeline and removed RegisterGlobal option instead. (#944) - Zipkin exporter helpers: pipeline methods introduced, new exporter method adjusted. (#944) - The trace (`go.opentelemetry.io/otel/exporters/trace/stdout`) and metric (`go.opentelemetry.io/otel/exporters/metric/stdout`) `stdout` exporters are now merged into a single exporter at `go.opentelemetry.io/otel/exporters/stdout`. (#956) diff --git a/api/kv/benchmark_test.go b/api/kv/benchmark_test.go index a258e06ac04..33aa93424f7 100644 --- a/api/kv/benchmark_test.go +++ b/api/kv/benchmark_test.go @@ -34,9 +34,9 @@ func getSpan() trace.Span { return sp } -func BenchmarkKeyInfer(b *testing.B) { +func BenchmarkKeyAny(b *testing.B) { for i := 0; i < b.N; i++ { - kv.Infer("Attr", int(256)) + kv.Any("Attr", int(256)) } } @@ -58,7 +58,7 @@ func BenchmarkMultiWithKeyInference(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - sp.SetAttributes(kv.Infer("Attr", 1)) + sp.SetAttributes(kv.Any("Attr", 1)) } } diff --git a/api/kv/kv.go b/api/kv/kv.go index 83ed878b896..c09823e85df 100644 --- a/api/kv/kv.go +++ b/api/kv/kv.go @@ -100,9 +100,9 @@ func Array(k string, v interface{}) KeyValue { return Key(k).Array(v) } -// Infer creates a new key-value pair instance with a passed name and +// Any creates a new key-value pair instance with a passed name and // automatic type inference. This is slower, and not type-safe. -func Infer(k string, value interface{}) KeyValue { +func Any(k string, value interface{}) KeyValue { if value == nil { return String(k, "") } diff --git a/api/kv/kv_test.go b/api/kv/kv_test.go index 40be1ceee51..018dd878f34 100644 --- a/api/kv/kv_test.go +++ b/api/kv/kv_test.go @@ -120,7 +120,7 @@ func TestKeyValueConstructors(t *testing.T) { } } -func TestInfer(t *testing.T) { +func TestAny(t *testing.T) { builder := &strings.Builder{} builder.WriteString("foo") jsonifyStruct := struct { @@ -214,7 +214,7 @@ func TestInfer(t *testing.T) { }, } { t.Logf("Running test case %s", testcase.key) - keyValue := kv.Infer(testcase.key, testcase.value) + keyValue := kv.Any(testcase.key, testcase.value) if keyValue.Value.Type() != testcase.wantType { t.Errorf("wrong value type, got %#v, expected %#v", keyValue.Value.Type(), testcase.wantType) } diff --git a/api/trace/testtrace/span.go b/api/trace/testtrace/span.go index 66f6e005efa..ea39dc61b9e 100644 --- a/api/trace/testtrace/span.go +++ b/api/trace/testtrace/span.go @@ -178,7 +178,7 @@ func (s *Span) SetAttributes(attrs ...kv.KeyValue) { } func (s *Span) SetAttribute(k string, v interface{}) { - s.SetAttributes(kv.Infer(k, v)) + s.SetAttributes(kv.Any(k, v)) } // Name returns the name most recently set on the Span, either at or after creation time. diff --git a/bridge/opentracing/internal/mock.go b/bridge/opentracing/internal/mock.go index 718a1f044eb..ea763731b94 100644 --- a/bridge/opentracing/internal/mock.go +++ b/bridge/opentracing/internal/mock.go @@ -239,7 +239,7 @@ func (s *MockSpan) SetAttributes(attributes ...otelcore.KeyValue) { } func (s *MockSpan) SetAttribute(k string, v interface{}) { - s.SetAttributes(otelcore.Infer(k, v)) + s.SetAttributes(otelcore.Any(k, v)) } func (s *MockSpan) applyUpdate(update otelcorrelation.MapUpdate) { diff --git a/sdk/trace/span.go b/sdk/trace/span.go index 6c782d7eef3..a312f68d1be 100644 --- a/sdk/trace/span.go +++ b/sdk/trace/span.go @@ -103,7 +103,7 @@ func (s *span) SetAttributes(attributes ...kv.KeyValue) { } func (s *span) SetAttribute(k string, v interface{}) { - attr := kv.Infer(k, v) + attr := kv.Any(k, v) if attr.Value.Type() != kv.INVALID { s.SetAttributes(attr) }