Skip to content

Commit

Permalink
Send label as tag
Browse files Browse the repository at this point in the history
  • Loading branch information
chaspy committed Jan 24, 2021
1 parent ca18ee0 commit 8cd750c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ func run() error {
client := github.NewClient(tc)

prs, _, err := client.PullRequests.List(ctx, "quipper", "kubernetes-clusters", nil)
fmt.Printf("%v\n", *prs[0].Labels[0].Name)
fmt.Printf("%v\n", *prs[0].User.Login)
fmt.Printf("%v\n", *prs[0].RequestedReviewers[0].Login)

var prinfos []PR

Expand All @@ -65,8 +62,6 @@ func run() error {
})
}

fmt.Println("%v",prinfos)

ddClient := datadog.NewClient(apikey, appkey)

const timeDifferencesToJapan = +9 * 60 * 60
Expand All @@ -82,14 +77,22 @@ func run() error {
return fmt.Errorf("failed to parse. count %v, error %w", count, err)
}

var labelsTag []string
// var reviewersTag string
for _, prinfo := range prinfos {
labelsTag = []string{}

for _, label := range prinfo.Labels{
labelsTag = append(labelsTag,"label:" + *label.Name)
}

customMetrics = append(customMetrics, datadog.Metric{
Metric: datadog.String("datadog.custom.github.pr.count"),
Points: []datadog.DataPoint{
{datadog.Float64(nowF), datadog.Float64(countf)},
},
Type: datadog.String("gauge"),
Tags: []string{"number:" + strconv.Itoa(*prinfo.Number),"author:" + *prinfo.User, "repo:" + "quipper/kubernetes-clusters"},
Tags: append([]string{"number:" + strconv.Itoa(*prinfo.Number),"author:" + *prinfo.User, "repo:" + "quipper/kubernetes-clusters"}, labelsTag...),
})
}

Expand Down

0 comments on commit 8cd750c

Please sign in to comment.