Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracing information in etcd helper #20159

Merged
merged 1 commit into from
Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/storage/etcd/etcd_helper.go
Expand Up @@ -144,11 +144,14 @@ func (h *etcdHelper) Versioner() storage.Versioner {

// Implements storage.Interface.
func (h *etcdHelper) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error {
trace := util.NewTrace("etcdHelper::Create " + getTypeName(obj))
defer trace.LogIfLong(250 * time.Millisecond)
if ctx == nil {
glog.Errorf("Context is nil")
}
key = h.prefixEtcdKey(key)
data, err := runtime.Encode(h.codec, obj)
trace.Step("Object encoded")
if err != nil {
return err
}
Expand All @@ -157,6 +160,7 @@ func (h *etcdHelper) Create(ctx context.Context, key string, obj, out runtime.Ob
return errors.New("resourceVersion may not be set on objects to be created")
}
}
trace.Step("Version checked")

startTime := time.Now()
opts := etcd.SetOptions{
Expand All @@ -165,6 +169,7 @@ func (h *etcdHelper) Create(ctx context.Context, key string, obj, out runtime.Ob
}
response, err := h.client.Set(ctx, key, string(data), &opts)
metrics.RecordEtcdRequestLatency("create", getTypeName(obj), startTime)
trace.Step("Object created")
if err != nil {
return err
}
Expand Down