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

feat: improve metrics #549

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion venona/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.2
2.0.3
7 changes: 6 additions & 1 deletion venona/pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,19 @@ func (a *Agent) reportTaskStatus(ctx context.Context, taskDef task.Task, err err
}

func (a *Agent) getTasks(ctx context.Context) (task.Tasks, []*workflow.Workflow) {
metrics.IncGetTasksRequests()
tasks := a.pullTasks(ctx)
return a.splitTasks(tasks)
}

func (a *Agent) pullTasks(ctx context.Context) task.Tasks {
start := time.Now()
tasks, err := a.cf.Tasks(ctx)
metrics.ObserveGetTasks(start)
status := "success"
if err != nil {
status = "error"
}
metrics.ObserveGetTasks(start, status)

if err != nil {
a.log.Error("Failed pulling tasks", "error", err)
Expand Down
18 changes: 14 additions & 4 deletions venona/pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ var (
Name: "queue_size",
Help: "Current number of waiting tasks",
})
getTasksDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
getTasksDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: runnerNamespace,
Name: "get_tasks_duration_sec",
Help: "How long each GetTasks request takes (seconds)",
Buckets: []float64{0.25, 0.5, 1, 2, 3, 6},
Buckets: []float64{0.25, 0.5, 1, 2, 3, 6, 12, 30, 60},
}, []string{"status"})
getTasksRequests = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: runnerNamespace,
Name: "get_tasks_requests",
Help: "Number of GetTasks requests",
})
handlingTimeSinceCreation = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: runnerNamespace,
Expand Down Expand Up @@ -136,10 +141,15 @@ func IncWorkflowRetries(podName string) {
wfTaskRetries.With(labels).Inc()
}

func ObserveGetTasks(start time.Time) {
func ObserveGetTasks(start time.Time, status string) {
end := time.Now()
diff := end.Sub(start)
getTasksDuration.Observe(diff.Seconds())
labels := prometheus.Labels{"status": status}
getTasksDuration.With(labels).Observe(diff.Seconds())
}

func IncGetTasksRequests() {
getTasksRequests.Inc()
}

func ObserveAgentTaskMetrics(agentType string, sinceCreation, inRunner, processed time.Duration) {
Expand Down
2 changes: 1 addition & 1 deletion venonactl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.2
2.0.3
Loading