Skip to content

comments for metrics #72

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

Open
wants to merge 1 commit into
base: metrics/replicaset-name
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,6 @@ func (r *Router) Call(ctx context.Context, bucketID uint64, mode CallMode,

for {
if spent := time.Since(requestStartTime); spent > timeout {
r.metrics().RequestDuration(spent, fnc, "", false, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don`t send metric if request done with error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we decided to send metrics for particular requests to storage tarantools. This deleted code sends something else: aggregated metrics over several calls to different storage tarantools; also includes sleep time, timings to bucket_set/bucket_reset and etc. Finally, the aggregated timing can be measured by the caller outside of this function.


r.log().Debugf(ctx, "Return result on timeout; spent %s of timeout %s", spent, timeout)
if err == nil {
err = fmt.Errorf("cant get call cause call impl timeout")
Expand Down Expand Up @@ -313,18 +311,26 @@ func (r *Router) Call(ctx context.Context, bucketID uint64, mode CallMode,

storageCallResponse := vshardStorageCallResponseProto{}

singleRequestStartTime := time.Now()
err = rs.conn.Do(tntReq, poolMode).GetTyped(&storageCallResponse)
if err != nil {
// Don't track metrics, because the do request has not been performed.
return VshardRouterCallResp{}, fmt.Errorf("got error on future.GetTyped(): %w", err)
}
singleRequestDuration := time.Since(singleRequestStartTime)

r.log().Debugf(ctx, "Got call result response data %+v", storageCallResponse)

if storageCallResponse.AssertError != nil {
// Request has failed with assert error, but do request has been performed.
r.metrics().RequestDuration(singleRequestDuration, fnc, rs.info.Name, false, false)
return VshardRouterCallResp{}, fmt.Errorf("%s: %s failed: %+v", vshardStorageClientCall, fnc, storageCallResponse.AssertError)
}

if storageCallResponse.VshardError != nil {
// Request has failed with vshard error, but do request has been performed
r.metrics().RequestDuration(singleRequestDuration, fnc, rs.info.Name, false, false)

vshardError := storageCallResponse.VshardError

switch vshardError.Name {
Expand Down Expand Up @@ -407,7 +413,8 @@ func (r *Router) Call(ctx context.Context, bucketID uint64, mode CallMode,
}
}

r.metrics().RequestDuration(time.Since(requestStartTime), fnc, rs.info.Name, true, false)
// Request has succeed, do request has been performed too.
r.metrics().RequestDuration(singleRequestDuration, fnc, rs.info.Name, true, false)

return storageCallResponse.CallResp, nil
}
Expand Down Expand Up @@ -584,6 +591,7 @@ func RouterMapCallRW[T any](r *Router, ctx context.Context,
fnc string, args interface{}, opts RouterMapCallRWOptions,
) (map[string]T, error) {
const vshardStorageServiceCall = "vshard.storage._call"
const rsNameUndefined = ""

timeout := callTimeoutDefault
if opts.Timeout > 0 {
Expand Down Expand Up @@ -681,7 +689,7 @@ func RouterMapCallRW[T any](r *Router, ctx context.Context,
nameToResult[rsFuture.name] = storageMapResponse.value
}

r.metrics().RequestDuration(time.Since(timeStart), fnc, "all", true, true)
r.metrics().RequestDuration(time.Since(timeStart), fnc, rsNameUndefined, true, true)

return nameToResult, nil
}
Expand Down