Skip to content

Commit

Permalink
trace names
Browse files Browse the repository at this point in the history
  • Loading branch information
louiseschmidtgen committed Jul 12, 2024
1 parent 0534bef commit 81ef2bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
14 changes: 7 additions & 7 deletions pkg/kine/server/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ func isCreate(txn *etcdserverpb.TxnRequest) *etcdserverpb.PutRequest {
}

func (l *LimitedServer) create(ctx context.Context, put *etcdserverpb.PutRequest, txn *etcdserverpb.TxnRequest) (*etcdserverpb.TxnResponse, error) {
ctx, span := tracer.Start(ctx, "backend.create")
defer span.End()
span.SetAttributes(
attribute.String("key", string(put.Key)),
attribute.Int64("lease", put.Lease),
)

if put.IgnoreLease {
return nil, unsupported("ignoreLease")
} else if put.IgnoreValue {
Expand All @@ -29,13 +36,6 @@ func (l *LimitedServer) create(ctx context.Context, put *etcdserverpb.PutRequest
return nil, unsupported("prevKv")
}

ctx, span := tracer.Start(ctx, "backend.create")
defer span.End()

span.SetAttributes(
attribute.String("key", string(put.Key)),
attribute.Int64("lease", put.Lease),
)
createCnt.Add(ctx, 1)

rev, err := l.backend.Create(ctx, string(put.Key), put.Value, put.Lease)
Expand Down
8 changes: 2 additions & 6 deletions pkg/kine/server/limited.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ type LimitedServer struct {

func (l *LimitedServer) Range(ctx context.Context, r *etcdserverpb.RangeRequest) (*RangeResponse, error) {
if len(r.RangeEnd) == 0 {
ctx, span := tracer.Start(ctx, "limited.get")
ctx, span := tracer.Start(ctx, "range.get")
defer span.End()
return l.get(ctx, r)
}
ctx, span := tracer.Start(ctx, "limited.list")
ctx, span := tracer.Start(ctx, "range.list")
defer span.End()
return l.list(ctx, r)
}
Expand All @@ -30,13 +30,9 @@ func txnHeader(rev int64) *etcdserverpb.ResponseHeader {

func (l *LimitedServer) Txn(ctx context.Context, txn *etcdserverpb.TxnRequest) (*etcdserverpb.TxnResponse, error) {
if put := isCreate(txn); put != nil {
ctx, span := tracer.Start(ctx, "limited.create")
defer span.End()
return l.create(ctx, put, txn)
}
if rev, key, ok := isDelete(txn); ok {
ctx, span := tracer.Start(ctx, "limited.delete")
defer span.End()
return l.delete(ctx, key, rev)
}
if rev, key, value, lease, ok := isUpdate(txn); ok {
Expand Down
14 changes: 8 additions & 6 deletions pkg/kine/server/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import (
)

func (l *LimitedServer) list(ctx context.Context, r *etcdserverpb.RangeRequest) (*RangeResponse, error) {
ctx, span := tracer.Start(ctx, "list")
defer span.End()

span.SetAttributes(
attribute.String("key", string(r.Key)),
attribute.String("rangeEnd", string(r.RangeEnd)),
)
if len(r.RangeEnd) == 0 {
return nil, fmt.Errorf("invalid range end length of 0")
}
Expand Down Expand Up @@ -53,17 +60,12 @@ func (l *LimitedServer) list(ctx context.Context, r *etcdserverpb.RangeRequest)
limit++
}

ctx, span := tracer.Start(ctx, "backend.list")
defer span.End()

span.SetAttributes(
attribute.String("key", string(r.Key)),
attribute.String("rangeEnd", string(r.RangeEnd)),
attribute.String("prefix", prefix),
attribute.String("start", start),
attribute.Int64("limit", limit),
attribute.Int64("revision", revision),
)

listCnt.Add(ctx, 1)

rev, kvs, err := l.backend.List(ctx, prefix, start, limit, revision)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kine/server/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (l *LimitedServer) update(ctx context.Context, rev int64, key string, value
ok bool
err error
)
ctx, updateSpan := tracer.Start(ctx, "limited.update")
ctx, updateSpan := tracer.Start(ctx, "update")
defer updateSpan.End()
updateSpan.SetAttributes(
attribute.String("key", key),
Expand Down

0 comments on commit 81ef2bb

Please sign in to comment.