use scheduler
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
22db6d86ba
commit
ad6e4fed09
@ -114,22 +114,27 @@ func main() {
|
||||
l.Error(ctx, "failed to unmarshal", err)
|
||||
continue
|
||||
}
|
||||
labels := []string{"check", check.Name, "task", task.Name, "service", svc, "endpoint", mth}
|
||||
m.Counter(semconv.ClientRequestInflight, labels...).Inc()
|
||||
ts := time.Now()
|
||||
l.Info(ctx, fmt.Sprintf("try to call %s.%s via %s", svc, mth, task.Addr))
|
||||
err = grpcconn.Call(ctx, l, c, task.Addr, time.Duration(task.Timeout),
|
||||
c.NewRequest(pkg, svc+"."+mth, req),
|
||||
rsp)
|
||||
te := time.Since(ts)
|
||||
m.Summary(semconv.ClientRequestLatencyMicroseconds, labels...).Update(te.Seconds())
|
||||
m.Histogram(semconv.ClientRequestDurationSeconds, labels...).Update(te.Seconds())
|
||||
m.Counter(semconv.ClientRequestInflight, labels...).Dec()
|
||||
if err != nil {
|
||||
m.Counter(semconv.ClientRequestTotal, append(labels, "status", "failure")...).Inc()
|
||||
} else {
|
||||
m.Counter(semconv.ClientRequestTotal, append(labels, "status", "success")...).Inc()
|
||||
}
|
||||
|
||||
treq := c.NewRequest(pkg, svc+"."+mth, req)
|
||||
|
||||
s.NewJob(time.Duration(check.Interval), func() {
|
||||
labels := []string{"check", check.Name, "task", task.Name, "service", svc, "endpoint", mth}
|
||||
m.Counter(semconv.ClientRequestInflight, labels...).Inc()
|
||||
ts := time.Now()
|
||||
l.Info(ctx, fmt.Sprintf("try to call %s.%s via %s", svc, mth, task.Addr))
|
||||
err = grpcconn.Call(ctx, l, c, task.Addr, time.Duration(task.Timeout),
|
||||
treq,
|
||||
rsp)
|
||||
te := time.Since(ts)
|
||||
m.Summary(semconv.ClientRequestLatencyMicroseconds, labels...).Update(te.Seconds())
|
||||
m.Histogram(semconv.ClientRequestDurationSeconds, labels...).Update(te.Seconds())
|
||||
m.Counter(semconv.ClientRequestInflight, labels...).Dec()
|
||||
if err != nil {
|
||||
m.Counter(semconv.ClientRequestTotal, append(labels, "status", "failure")...).Inc()
|
||||
} else {
|
||||
m.Counter(semconv.ClientRequestTotal, append(labels, "status", "success")...).Inc()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user