1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-03-03 14:52:56 +02:00

Remove NewKey and update doc comment (#721)

* Update doc comment

* Remove NewKey

* NewKey->Key
This commit is contained in:
Joshua MacDonald 2020-05-13 16:21:23 -07:00 committed by GitHub
parent 1301b6f3e4
commit 587cde3352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 155 additions and 164 deletions

View File

@ -97,7 +97,7 @@ func (CorrelationContext) Extract(ctx context.Context, supplier propagation.HTTP
trimmedValueWithProps.WriteString(prop)
}
keyValues = append(keyValues, kv.NewKey(trimmedName).String(trimmedValueWithProps.String()))
keyValues = append(keyValues, kv.Key(trimmedName).String(trimmedValueWithProps.String()))
}
return ContextWithMap(ctx, NewMap(MapUpdate{
MultiKV: keyValues,

View File

@ -40,48 +40,48 @@ func TestExtractValidDistributedContextFromHTTPReq(t *testing.T) {
name: "valid w3cHeader",
header: "key1=val1,key2=val2",
wantKVs: []kv.KeyValue{
kv.NewKey("key1").String("val1"),
kv.NewKey("key2").String("val2"),
kv.Key("key1").String("val1"),
kv.Key("key2").String("val2"),
},
},
{
name: "valid w3cHeader with spaces",
header: "key1 = val1, key2 =val2 ",
wantKVs: []kv.KeyValue{
kv.NewKey("key1").String("val1"),
kv.NewKey("key2").String("val2"),
kv.Key("key1").String("val1"),
kv.Key("key2").String("val2"),
},
},
{
name: "valid w3cHeader with properties",
header: "key1=val1,key2=val2;prop=1",
wantKVs: []kv.KeyValue{
kv.NewKey("key1").String("val1"),
kv.NewKey("key2").String("val2;prop=1"),
kv.Key("key1").String("val1"),
kv.Key("key2").String("val2;prop=1"),
},
},
{
name: "valid header with url-escaped comma",
header: "key1=val1,key2=val2%2Cval3",
wantKVs: []kv.KeyValue{
kv.NewKey("key1").String("val1"),
kv.NewKey("key2").String("val2,val3"),
kv.Key("key1").String("val1"),
kv.Key("key2").String("val2,val3"),
},
},
{
name: "valid header with an invalid header",
header: "key1=val1,key2=val2,a,val3",
wantKVs: []kv.KeyValue{
kv.NewKey("key1").String("val1"),
kv.NewKey("key2").String("val2"),
kv.Key("key1").String("val1"),
kv.Key("key2").String("val2"),
},
},
{
name: "valid header with no value",
header: "key1=,key2=val2",
wantKVs: []kv.KeyValue{
kv.NewKey("key1").String(""),
kv.NewKey("key2").String("val2"),
kv.Key("key1").String(""),
kv.Key("key2").String("val2"),
},
},
}
@ -157,31 +157,31 @@ func TestInjectCorrelationContextToHTTPReq(t *testing.T) {
{
name: "two simple values",
kvs: []kv.KeyValue{
kv.NewKey("key1").String("val1"),
kv.NewKey("key2").String("val2"),
kv.Key("key1").String("val1"),
kv.Key("key2").String("val2"),
},
wantInHeader: []string{"key1=val1", "key2=val2"},
},
{
name: "two values with escaped chars",
kvs: []kv.KeyValue{
kv.NewKey("key1").String("val1,val2"),
kv.NewKey("key2").String("val3=4"),
kv.Key("key1").String("val1,val2"),
kv.Key("key2").String("val3=4"),
},
wantInHeader: []string{"key1=val1%2Cval2", "key2=val3%3D4"},
},
{
name: "values of non-string types",
kvs: []kv.KeyValue{
kv.NewKey("key1").Bool(true),
kv.NewKey("key2").Int(123),
kv.NewKey("key3").Int64(123),
kv.NewKey("key4").Int32(123),
kv.NewKey("key5").Uint(123),
kv.NewKey("key6").Uint32(123),
kv.NewKey("key7").Uint64(123),
kv.NewKey("key8").Float64(123.567),
kv.NewKey("key9").Float32(123.567),
kv.Key("key1").Bool(true),
kv.Key("key2").Int(123),
kv.Key("key3").Int64(123),
kv.Key("key4").Int32(123),
kv.Key("key5").Uint(123),
kv.Key("key6").Uint32(123),
kv.Key("key7").Uint64(123),
kv.Key("key8").Float64(123.567),
kv.Key("key9").Float32(123.567),
},
wantInHeader: []string{
"key1=true",

View File

@ -86,7 +86,7 @@ func TestSizeComputation(t *testing.T) {
func getTestCases() []testCase {
return []testCase{
{
name: "NewKey map with MultiKV",
name: "map with MultiKV",
value: MapUpdate{MultiKV: []kv.KeyValue{
kv.Int64("key1", 1),
kv.String("key2", "val2")},
@ -98,7 +98,7 @@ func getTestCases() []testCase {
},
},
{
name: "NewKey map with SingleKV",
name: "map with SingleKV",
value: MapUpdate{SingleKV: kv.String("key1", "val1")},
init: []int{},
wantKVs: []kv.KeyValue{
@ -106,7 +106,7 @@ func getTestCases() []testCase {
},
},
{
name: "NewKey map with both add fields",
name: "map with both add fields",
value: MapUpdate{SingleKV: kv.Int64("key1", 3),
MultiKV: []kv.KeyValue{
kv.String("key1", ""),
@ -119,19 +119,19 @@ func getTestCases() []testCase {
},
},
{
name: "NewKey map with empty MapUpdate",
name: "map with empty MapUpdate",
value: MapUpdate{},
init: []int{},
wantKVs: []kv.KeyValue{},
},
{
name: "NewKey map with DropSingleK",
name: "map with DropSingleK",
value: MapUpdate{DropSingleK: kv.Key("key1")},
init: []int{},
wantKVs: []kv.KeyValue{},
},
{
name: "NewKey map with DropMultiK",
name: "map with DropMultiK",
value: MapUpdate{DropMultiK: []kv.Key{
kv.Key("key1"), kv.Key("key2"),
}},
@ -139,7 +139,7 @@ func getTestCases() []testCase {
wantKVs: []kv.KeyValue{},
},
{
name: "NewKey map with both drop fields",
name: "map with both drop fields",
value: MapUpdate{
DropSingleK: kv.Key("key1"),
DropMultiK: []kv.Key{
@ -151,7 +151,7 @@ func getTestCases() []testCase {
wantKVs: []kv.KeyValue{},
},
{
name: "NewKey map with all fields",
name: "map with all fields",
value: MapUpdate{
DropSingleK: kv.Key("key1"),
DropMultiK: []kv.Key{

View File

@ -12,9 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// This package provides basic types used in OpenTelemetry - keys,
// values, numbers and span contexts.
//
// See the api/key package for convenience functions for creating keys
// and key-value pairs.
// package kv provides basic key and value types.
package kv // import "go.opentelemetry.io/otel/api/kv"

View File

@ -22,11 +22,6 @@ import (
// allowed character set in the key depends on the use of the key.
type Key string
// NewKey creates a new key with a passed name.
func NewKey(name string) Key {
return Key(name)
}
// Bool creates a KeyValue instance with a BOOL Value.
//
// If creating both key and a bool value at the same time, then

View File

@ -30,69 +30,69 @@ type KeyValue struct {
// Bool creates a new key-value pair with a passed name and a bool
// value.
func Bool(k string, v bool) KeyValue {
return NewKey(k).Bool(v)
return Key(k).Bool(v)
}
// Int64 creates a new key-value pair with a passed name and an int64
// value.
func Int64(k string, v int64) KeyValue {
return NewKey(k).Int64(v)
return Key(k).Int64(v)
}
// Uint64 creates a new key-value pair with a passed name and a uint64
// value.
func Uint64(k string, v uint64) KeyValue {
return NewKey(k).Uint64(v)
return Key(k).Uint64(v)
}
// Float64 creates a new key-value pair with a passed name and a float64
// value.
func Float64(k string, v float64) KeyValue {
return NewKey(k).Float64(v)
return Key(k).Float64(v)
}
// Int32 creates a new key-value pair with a passed name and an int32
// value.
func Int32(k string, v int32) KeyValue {
return NewKey(k).Int32(v)
return Key(k).Int32(v)
}
// Uint32 creates a new key-value pair with a passed name and a uint32
// value.
func Uint32(k string, v uint32) KeyValue {
return NewKey(k).Uint32(v)
return Key(k).Uint32(v)
}
// Float32 creates a new key-value pair with a passed name and a float32
// value.
func Float32(k string, v float32) KeyValue {
return NewKey(k).Float32(v)
return Key(k).Float32(v)
}
// String creates a new key-value pair with a passed name and a string
// value.
func String(k, v string) KeyValue {
return NewKey(k).String(v)
return Key(k).String(v)
}
// Stringer creates a new key-value pair with a passed name and a string
// value generated by the passed Stringer interface.
func Stringer(k string, v fmt.Stringer) KeyValue {
return NewKey(k).String(v.String())
return Key(k).String(v.String())
}
// Int creates a new key-value pair instance with a passed name and
// either an int32 or an int64 value, depending on whether the int
// type is 32 or 64 bits wide.
func Int(k string, v int) KeyValue {
return NewKey(k).Int(v)
return Key(k).Int(v)
}
// Uint creates a new key-value pair instance with a passed name and
// either an uint32 or an uint64 value, depending on whether the uint
// type is 32 or 64 bits wide.
func Uint(k string, v uint) KeyValue {
return NewKey(k).Uint(v)
return Key(k).Uint(v)
}
// Infer creates a new key-value pair instance with a passed name and

View File

@ -66,12 +66,12 @@ func (c *bridgeSpanContext) ForeachBaggageItem(handler func(k, v string) bool) {
func (c *bridgeSpanContext) setBaggageItem(restrictedKey, value string) {
crk := http.CanonicalHeaderKey(restrictedKey)
c.baggageItems = c.baggageItems.Apply(otelcorrelation.MapUpdate{SingleKV: otelcore.NewKey(crk).String(value)})
c.baggageItems = c.baggageItems.Apply(otelcorrelation.MapUpdate{SingleKV: otelcore.Key(crk).String(value)})
}
func (c *bridgeSpanContext) baggageItem(restrictedKey string) string {
crk := http.CanonicalHeaderKey(restrictedKey)
val, _ := c.baggageItems.Value(otelcore.NewKey(crk))
val, _ := c.baggageItems.Value(otelcore.Key(crk))
return val.Emit()
}

View File

@ -32,12 +32,12 @@ import (
)
var (
ComponentKey = otelcore.NewKey("component")
ServiceKey = otelcore.NewKey("service")
StatusCodeKey = otelcore.NewKey("status.code")
StatusMessageKey = otelcore.NewKey("status.message")
ErrorKey = otelcore.NewKey("error")
NameKey = otelcore.NewKey("name")
ComponentKey = otelcore.Key("component")
ServiceKey = otelcore.Key("service")
StatusCodeKey = otelcore.Key("status.code")
StatusMessageKey = otelcore.Key("status.message")
ErrorKey = otelcore.Key("error")
NameKey = otelcore.Key("name")
)
type MockContextKeyValue struct {

View File

@ -30,10 +30,10 @@ import (
)
var (
fooKey = kv.NewKey("ex.com/foo")
barKey = kv.NewKey("ex.com/bar")
lemonsKey = kv.NewKey("ex.com/lemons")
anotherKey = kv.NewKey("ex.com/another")
fooKey = kv.Key("ex.com/foo")
barKey = kv.Key("ex.com/bar")
lemonsKey = kv.Key("ex.com/lemons")
anotherKey = kv.Key("ex.com/another")
)
// initTracer creates and registers trace provider instance.
@ -94,7 +94,7 @@ func main() {
err := tracer.WithSpan(ctx, "operation", func(ctx context.Context) error {
trace.SpanFromContext(ctx).AddEvent(ctx, "Nice operation!", kv.NewKey("bogons").Int(100))
trace.SpanFromContext(ctx).AddEvent(ctx, "Nice operation!", kv.Key("bogons").Int(100))
trace.SpanFromContext(ctx).SetAttributes(anotherKey.String("yes"))

View File

@ -23,7 +23,7 @@ import (
)
var (
lemonsKey = kv.NewKey("ex.com/lemons")
lemonsKey = kv.Key("ex.com/lemons")
)
// SubOperation is an example to demonstrate the use of named tracer.

View File

@ -29,9 +29,9 @@ import (
)
var (
fooKey = kv.NewKey("ex.com/foo")
barKey = kv.NewKey("ex.com/bar")
anotherKey = kv.NewKey("ex.com/another")
fooKey = kv.Key("ex.com/foo")
barKey = kv.Key("ex.com/bar")
anotherKey = kv.Key("ex.com/another")
)
var tp *sdktrace.Provider
@ -67,7 +67,7 @@ func main() {
err := tracer.WithSpan(ctx, "operation", func(ctx context.Context) error {
trace.SpanFromContext(ctx).AddEvent(ctx, "Nice operation!", kv.NewKey("bogons").Int(100))
trace.SpanFromContext(ctx).AddEvent(ctx, "Nice operation!", kv.Key("bogons").Int(100))
trace.SpanFromContext(ctx).SetAttributes(anotherKey.String("yes"))

View File

@ -29,7 +29,7 @@ import (
)
var (
lemonsKey = kv.NewKey("ex.com/lemons")
lemonsKey = kv.Key("ex.com/lemons")
)
func initMeter() *push.Controller {

View File

@ -51,8 +51,8 @@ func TestPrometheusExporter(t *testing.T) {
"histogram_measure", metric.MeasureKind, metric.Float64NumberKind)
labels := []kv.KeyValue{
kv.NewKey("A").String("B"),
kv.NewKey("C").String("D"),
kv.Key("A").String("B"),
kv.Key("C").String("D"),
}
checkpointSet.AddCounter(&counter, 15.3, labels...)
@ -83,8 +83,8 @@ func TestPrometheusExporter(t *testing.T) {
expected = append(expected, `histogram_measure_sum{A="B",C="D"} 19.6`)
missingLabels := []kv.KeyValue{
kv.NewKey("A").String("E"),
kv.NewKey("C").String(""),
kv.Key("A").String("E"),
kv.Key("C").String(""),
}
checkpointSet.AddCounter(&counter, 12, missingLabels...)

View File

@ -37,7 +37,7 @@ func ExampleNewExportPipeline() {
ctx := context.Background()
key := kv.NewKey("key")
key := kv.Key("key")
meter := pusher.Meter("example")
// Create and update a single counter:

View File

@ -34,13 +34,13 @@ import (
)
var (
rpcServiceKey = kv.NewKey("rpc.service")
netPeerIPKey = kv.NewKey("net.peer.ip")
netPeerPortKey = kv.NewKey("net.peer.port")
rpcServiceKey = kv.Key("rpc.service")
netPeerIPKey = kv.Key("net.peer.ip")
netPeerPortKey = kv.Key("net.peer.port")
messageTypeKey = kv.NewKey("message.type")
messageIDKey = kv.NewKey("message.id")
messageUncompressedSizeKey = kv.NewKey("message.uncompressed_size")
messageTypeKey = kv.Key("message.type")
messageIDKey = kv.Key("message.id")
messageUncompressedSizeKey = kv.Key("message.uncompressed_size")
)
const (

View File

@ -30,10 +30,10 @@ import (
)
var (
HTTPStatus = kv.NewKey("http.status")
HTTPHeaderMIME = kv.NewKey("http.mime")
HTTPRemoteAddr = kv.NewKey("http.remote")
HTTPLocalAddr = kv.NewKey("http.local")
HTTPStatus = kv.Key("http.status")
HTTPHeaderMIME = kv.Key("http.mime")
HTTPRemoteAddr = kv.Key("http.remote")
HTTPLocalAddr = kv.Key("http.local")
)
var (

View File

@ -151,7 +151,7 @@ func TestHTTPRequestWithClientTrace(t *testing.T) {
}
if tl.name == "http.getconn" {
local := kv.NewKey("http.local")
local := kv.Key("http.local")
// http.local attribute is not deterministic, just make sure it exists for `getconn`.
if _, ok := actualAttrs[local]; ok {
delete(actualAttrs, local)

View File

@ -26,8 +26,8 @@ import (
)
var (
HostKey = kv.NewKey("http.host")
URLKey = kv.NewKey("http.url")
HostKey = kv.Key("http.host")
URLKey = kv.Key("http.url")
)
// Returns the Attributes, Context Entries, and SpanContext that were encoded by Inject.

View File

@ -111,7 +111,7 @@ func makeLabels(n int) []kv.KeyValue {
break
}
}
l[i] = kv.NewKey(k).String(fmt.Sprint("v", rand.Intn(1000000000)))
l[i] = kv.Key(k).String(fmt.Sprint("v", rand.Intn(1000000000)))
}
return l
}

View File

@ -37,7 +37,7 @@ func ExampleNew() {
ctx := context.Background()
key := kv.NewKey("key")
key := kv.Key("key")
meter := pusher.Meter("example")
counter := metric.Must(meter).NewInt64Counter("a.counter")

View File

@ -82,8 +82,8 @@ func NewOutput(labelEncoder label.Encoder) Output {
}
// NewAggregationSelector returns a policy that is consistent with the
// test descriptors above. I.e., it returns sum.NewKey() for counter
// instruments and lastvalue.NewKey for lastValue instruments.
// test descriptors above. I.e., it returns sum.New() for counter
// instruments and lastvalue.New() for lastValue instruments.
func NewAggregationSelector() export.AggregationSelector {
return &testAggregationSelector{}
}

View File

@ -142,7 +142,7 @@ func (f *testFixture) someLabels() []kv.KeyValue {
break
}
}
l[i] = kv.NewKey(k).String(fmt.Sprint("v", rand.Intn(1000000000)))
l[i] = kv.Key(k).String(fmt.Sprint("v", rand.Intn(1000000000)))
}
lc := canonicalizeLabels(l)
f.lock.Lock()

View File

@ -34,7 +34,7 @@ type Resource struct {
var emptyResource Resource
// NewKey creates a resource from a set of attributes. If there are
// Key creates a resource from a set of attributes. If there are
// duplicate keys present in the list of attributes, then the last
// value found for the key is preserved.
func New(kvs ...kv.KeyValue) *Resource {
@ -96,7 +96,7 @@ func Merge(a, b *Resource) *Resource {
b = Empty()
}
// Note: 'b' is listed first so that 'a' will overwrite with
// last-value-wins in label.NewKey()
// last-value-wins in label.Key()
combine := append(b.Attributes(), a.Attributes()...)
return New(combine...)
}

View File

@ -43,17 +43,17 @@ func TestNew(t *testing.T) {
want []kv.KeyValue
}{
{
name: "NewKey with common key order1",
name: "Key with common key order1",
in: []kv.KeyValue{kv12, kv11, kv21},
want: []kv.KeyValue{kv11, kv21},
},
{
name: "NewKey with common key order2",
name: "Key with common key order2",
in: []kv.KeyValue{kv11, kv12, kv21},
want: []kv.KeyValue{kv12, kv21},
},
{
name: "NewKey with nil",
name: "Key with nil",
in: nil,
want: nil,
},

View File

@ -43,10 +43,10 @@ func BenchmarkSpanWithAttributes_4(b *testing.B) {
for i := 0; i < b.N; i++ {
_, span := t.Start(ctx, "/foo")
span.SetAttributes(
kv.NewKey("key1").Bool(false),
kv.NewKey("key2").String("hello"),
kv.NewKey("key3").Uint64(123),
kv.NewKey("key4").Float64(123.456),
kv.Key("key1").Bool(false),
kv.Key("key2").String("hello"),
kv.Key("key3").Uint64(123),
kv.Key("key4").Float64(123.456),
)
span.End()
}
@ -61,14 +61,14 @@ func BenchmarkSpanWithAttributes_8(b *testing.B) {
for i := 0; i < b.N; i++ {
_, span := t.Start(ctx, "/foo")
span.SetAttributes(
kv.NewKey("key1").Bool(false),
kv.NewKey("key2").String("hello"),
kv.NewKey("key3").Uint64(123),
kv.NewKey("key4").Float64(123.456),
kv.NewKey("key21").Bool(false),
kv.NewKey("key22").String("hello"),
kv.NewKey("key23").Uint64(123),
kv.NewKey("key24").Float64(123.456),
kv.Key("key1").Bool(false),
kv.Key("key2").String("hello"),
kv.Key("key3").Uint64(123),
kv.Key("key4").Float64(123.456),
kv.Key("key21").Bool(false),
kv.Key("key22").String("hello"),
kv.Key("key23").Uint64(123),
kv.Key("key24").Float64(123.456),
)
span.End()
}
@ -83,16 +83,16 @@ func BenchmarkSpanWithAttributes_all(b *testing.B) {
for i := 0; i < b.N; i++ {
_, span := t.Start(ctx, "/foo")
span.SetAttributes(
kv.NewKey("key1").Bool(false),
kv.NewKey("key2").String("hello"),
kv.NewKey("key3").Int64(123),
kv.NewKey("key4").Uint64(123),
kv.NewKey("key5").Int32(123),
kv.NewKey("key6").Uint32(123),
kv.NewKey("key7").Float64(123.456),
kv.NewKey("key8").Float32(123.456),
kv.NewKey("key9").Int(123),
kv.NewKey("key10").Uint(123),
kv.Key("key1").Bool(false),
kv.Key("key2").String("hello"),
kv.Key("key3").Int64(123),
kv.Key("key4").Uint64(123),
kv.Key("key5").Int32(123),
kv.Key("key6").Uint32(123),
kv.Key("key7").Float64(123.456),
kv.Key("key8").Float32(123.456),
kv.Key("key9").Int(123),
kv.Key("key10").Uint(123),
)
span.End()
}
@ -107,26 +107,26 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) {
for i := 0; i < b.N; i++ {
_, span := t.Start(ctx, "/foo")
span.SetAttributes(
kv.NewKey("key1").Bool(false),
kv.NewKey("key2").String("hello"),
kv.NewKey("key3").Int64(123),
kv.NewKey("key4").Uint64(123),
kv.NewKey("key5").Int32(123),
kv.NewKey("key6").Uint32(123),
kv.NewKey("key7").Float64(123.456),
kv.NewKey("key8").Float32(123.456),
kv.NewKey("key10").Int(123),
kv.NewKey("key11").Uint(123),
kv.NewKey("key21").Bool(false),
kv.NewKey("key22").String("hello"),
kv.NewKey("key23").Int64(123),
kv.NewKey("key24").Uint64(123),
kv.NewKey("key25").Int32(123),
kv.NewKey("key26").Uint32(123),
kv.NewKey("key27").Float64(123.456),
kv.NewKey("key28").Float32(123.456),
kv.NewKey("key210").Int(123),
kv.NewKey("key211").Uint(123),
kv.Key("key1").Bool(false),
kv.Key("key2").String("hello"),
kv.Key("key3").Int64(123),
kv.Key("key4").Uint64(123),
kv.Key("key5").Int32(123),
kv.Key("key6").Uint32(123),
kv.Key("key7").Float64(123.456),
kv.Key("key8").Float32(123.456),
kv.Key("key10").Int(123),
kv.Key("key11").Uint(123),
kv.Key("key21").Bool(false),
kv.Key("key22").String("hello"),
kv.Key("key23").Int64(123),
kv.Key("key24").Uint64(123),
kv.Key("key25").Int32(123),
kv.Key("key26").Uint32(123),
kv.Key("key27").Float64(123.456),
kv.Key("key28").Float32(123.456),
kv.Key("key210").Int(123),
kv.Key("key211").Uint(123),
)
span.End()
}

View File

@ -306,7 +306,7 @@ func TestSetSpanAttributes(t *testing.T) {
te := &testExporter{}
tp, _ := NewProvider(WithSyncer(te))
span := startSpan(tp, "SpanAttribute")
span.SetAttributes(kv.NewKey("key1").String("value1"))
span.SetAttributes(kv.Key("key1").String("value1"))
got, err := endSpan(te, span)
if err != nil {
t.Fatal(err)
@ -372,11 +372,11 @@ func TestEvents(t *testing.T) {
tp, _ := NewProvider(WithSyncer(te))
span := startSpan(tp, "Events")
k1v1 := kv.NewKey("key1").String("value1")
k1v1 := kv.Key("key1").String("value1")
k2v2 := kv.Bool("key2", true)
k3v3 := kv.Int64("key3", 3)
span.AddEvent(context.Background(), "foo", kv.NewKey("key1").String("value1"))
span.AddEvent(context.Background(), "foo", kv.Key("key1").String("value1"))
span.AddEvent(context.Background(), "bar",
kv.Bool("key2", true),
kv.Int64("key3", 3),
@ -417,19 +417,19 @@ func TestEventsOverLimit(t *testing.T) {
tp, _ := NewProvider(WithConfig(cfg), WithSyncer(te))
span := startSpan(tp, "EventsOverLimit")
k1v1 := kv.NewKey("key1").String("value1")
k1v1 := kv.Key("key1").String("value1")
k2v2 := kv.Bool("key2", false)
k3v3 := kv.NewKey("key3").String("value3")
k3v3 := kv.Key("key3").String("value3")
span.AddEvent(context.Background(), "fooDrop", kv.NewKey("key1").String("value1"))
span.AddEvent(context.Background(), "fooDrop", kv.Key("key1").String("value1"))
span.AddEvent(context.Background(), "barDrop",
kv.Bool("key2", true),
kv.NewKey("key3").String("value3"),
kv.Key("key3").String("value3"),
)
span.AddEvent(context.Background(), "foo", kv.NewKey("key1").String("value1"))
span.AddEvent(context.Background(), "foo", kv.Key("key1").String("value1"))
span.AddEvent(context.Background(), "bar",
kv.Bool("key2", false),
kv.NewKey("key3").String("value3"),
kv.Key("key3").String("value3"),
)
got, err := endSpan(te, span)
if err != nil {
@ -466,18 +466,18 @@ func TestLinks(t *testing.T) {
te := &testExporter{}
tp, _ := NewProvider(WithSyncer(te))
k1v1 := kv.NewKey("key1").String("value1")
k2v2 := kv.NewKey("key2").String("value2")
k3v3 := kv.NewKey("key3").String("value3")
k1v1 := kv.Key("key1").String("value1")
k2v2 := kv.Key("key2").String("value2")
k3v3 := kv.Key("key3").String("value3")
sc1 := apitrace.SpanContext{TraceID: apitrace.ID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
sc2 := apitrace.SpanContext{TraceID: apitrace.ID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
span := startSpan(tp, "Links",
apitrace.LinkedTo(sc1, kv.NewKey("key1").String("value1")),
apitrace.LinkedTo(sc1, kv.Key("key1").String("value1")),
apitrace.LinkedTo(sc2,
kv.NewKey("key2").String("value2"),
kv.NewKey("key3").String("value3"),
kv.Key("key2").String("value2"),
kv.Key("key3").String("value3"),
),
)
@ -516,13 +516,13 @@ func TestLinksOverLimit(t *testing.T) {
tp, _ := NewProvider(WithConfig(cfg), WithSyncer(te))
span := startSpan(tp, "LinksOverLimit",
apitrace.LinkedTo(sc1, kv.NewKey("key1").String("value1")),
apitrace.LinkedTo(sc2, kv.NewKey("key2").String("value2")),
apitrace.LinkedTo(sc3, kv.NewKey("key3").String("value3")),
apitrace.LinkedTo(sc1, kv.Key("key1").String("value1")),
apitrace.LinkedTo(sc2, kv.Key("key2").String("value2")),
apitrace.LinkedTo(sc3, kv.Key("key3").String("value3")),
)
k2v2 := kv.NewKey("key2").String("value2")
k3v3 := kv.NewKey("key3").String("value3")
k2v2 := kv.Key("key2").String("value2")
k3v3 := kv.Key("key3").String("value3")
got, err := endSpan(te, span)
if err != nil {