feat(collector): add HTTP push for metrics to receiver
All checks were successful
ci / build (push) Successful in 46s

Add push client that sends run summary to a configurable HTTP endpoint
on shutdown. Execution context is read from GitHub Actions style
environment variables (with Gitea fallbacks).

New flag: -push-endpoint <url>

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Manuel Ganter 2026-02-06 11:44:20 +01:00
parent c309bd810d
commit cfe583fbc4
No known key found for this signature in database
4 changed files with 304 additions and 7 deletions

View file

@ -30,6 +30,7 @@ func main() {
logLevel := flag.String("log-level", defaultLogLevel, "Log level: debug, info, warn, error")
logFormat := flag.String("log-format", defaultLogFormat, "Output format: json, text")
topN := flag.Int("top", defaultTopN, "Number of top processes to include")
pushEndpoint := flag.String("push-endpoint", "", "HTTP endpoint to push metrics to (e.g., http://localhost:8080/api/v1/metrics)")
flag.Parse()
// Setup structured logging for application logs
@ -58,6 +59,21 @@ func main() {
summaryWriter := summary.NewSummaryWriter(os.Stdout, *logFormat)
c.SetSummaryWriter(summaryWriter)
// Setup push client if endpoint is configured
if *pushEndpoint != "" {
pushClient := summary.NewPushClient(*pushEndpoint)
c.SetPushClient(pushClient)
execCtx := pushClient.ExecutionContext()
appLogger.Info("push client configured",
slog.String("endpoint", *pushEndpoint),
slog.String("organization", execCtx.Organization),
slog.String("repository", execCtx.Repository),
slog.String("workflow", execCtx.Workflow),
slog.String("job", execCtx.Job),
slog.String("run_id", execCtx.RunID),
)
}
// Setup signal handling for graceful shutdown
ctx, cancel := context.WithCancel(context.Background())
defer cancel()