use scheduler

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-11-16 19:59:37 +03:00
parent 22db6d86ba
commit ad6e4fed09

View File

@ -114,12 +114,16 @@ func main() {
l.Error(ctx, "failed to unmarshal", err) l.Error(ctx, "failed to unmarshal", err)
continue continue
} }
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} labels := []string{"check", check.Name, "task", task.Name, "service", svc, "endpoint", mth}
m.Counter(semconv.ClientRequestInflight, labels...).Inc() m.Counter(semconv.ClientRequestInflight, labels...).Inc()
ts := time.Now() ts := time.Now()
l.Info(ctx, fmt.Sprintf("try to call %s.%s via %s", svc, mth, task.Addr)) 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), err = grpcconn.Call(ctx, l, c, task.Addr, time.Duration(task.Timeout),
c.NewRequest(pkg, svc+"."+mth, req), treq,
rsp) rsp)
te := time.Since(ts) te := time.Since(ts)
m.Summary(semconv.ClientRequestLatencyMicroseconds, labels...).Update(te.Seconds()) m.Summary(semconv.ClientRequestLatencyMicroseconds, labels...).Update(te.Seconds())
@ -130,6 +134,7 @@ func main() {
} else { } else {
m.Counter(semconv.ClientRequestTotal, append(labels, "status", "success")...).Inc() m.Counter(semconv.ClientRequestTotal, append(labels, "status", "success")...).Inc()
} }
})
} }
} }