forked from taskcluster/generic-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics.go
More file actions
33 lines (28 loc) · 705 Bytes
/
metrics.go
File metadata and controls
33 lines (28 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"encoding/json"
"fmt"
"log"
"time"
)
func logEvent(eventType string, task *TaskRun, timestamp time.Time) {
fields := map[string]interface{}{
"eventType": eventType,
"worker": "generic-worker",
"workerPoolId": fmt.Sprintf("%s/%s", config.ProvisionerID, config.WorkerType),
"workerId": config.WorkerID,
"timestamp": timestamp.Unix(),
"region": config.Region,
"instanceType": config.InstanceType,
}
if task != nil {
fields["taskId"] = task.TaskID
fields["runId"] = task.RunID
}
j, err := json.Marshal(fields)
if err != nil {
log.Printf("Error encoding working metrics: %v", err)
return
}
log.Printf("WORKER_METRICS %s", j)
}