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