tracer: update wrapper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -91,7 +91,9 @@ type SpanOptions struct {
|
||||
}
|
||||
|
||||
// EventOptions contains event options
|
||||
type EventOptions struct{}
|
||||
type EventOptions struct {
|
||||
Labels []interface{}
|
||||
}
|
||||
|
||||
func WithSpanLabels(ls ...interface{}) options.Option {
|
||||
return func(src interface{}) error {
|
||||
@@ -110,6 +112,26 @@ func WithSpanLabels(ls ...interface{}) options.Option {
|
||||
}
|
||||
}
|
||||
|
||||
// EventOption func signature
|
||||
type EventOption func(o *EventOptions)
|
||||
|
||||
func WithEventLabels(ls ...interface{}) options.Option {
|
||||
return func(src interface{}) error {
|
||||
v, err := options.Get(src, ".Labels")
|
||||
if err != nil {
|
||||
return err
|
||||
} else if rutil.IsZero(v) {
|
||||
v = reflect.MakeSlice(reflect.TypeOf(v), 0, len(ls)).Interface()
|
||||
}
|
||||
cv := reflect.ValueOf(v)
|
||||
for _, l := range ls {
|
||||
reflect.Append(cv, reflect.ValueOf(l))
|
||||
}
|
||||
err = options.Set(src, cv, ".Labels")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func WithSpanKind(k SpanKind) options.Option {
|
||||
return func(src interface{}) error {
|
||||
return options.Set(src, k, ".Kind")
|
||||
|
Reference in New Issue
Block a user