-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,111 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
VERSION=`git branch | grep '*' | awk '{print $2}'` | ||
if [[ $VERSION == "master" ]]; | ||
then | ||
VERSION=`git describe --tags --abbrev=0` | ||
fi | ||
|
||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=$VERSION'" -o bin/app |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
module github-actions-exporter | ||
|
||
go 1.13 | ||
go 1.16 | ||
|
||
require ( | ||
github.com/prometheus/client_golang v1.4.0 | ||
github.com/urfave/cli v1.22.2 | ||
github.com/fasthttp/router v1.3.9 // indirect | ||
github.com/google/go-github/v33 v33.0.1-0.20210311004518-0540c33dca8b // indirect | ||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect | ||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect | ||
github.com/prometheus/client_golang v1.9.0 // indirect | ||
github.com/urfave/cli/v2 v2.3.0 // indirect | ||
github.com/valyala/fasthttp v1.22.0 // indirect | ||
golang.org/x/oauth2 v0.0.0-20210311163135-5366d9dc1934 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,28 @@ | ||
/* | ||
Main application package | ||
*/ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"github.com/urfave/cli" | ||
|
||
"github-actions-exporter/config" | ||
"github-actions-exporter/metrics" | ||
"github-actions-exporter/pkg/config" | ||
"github-actions-exporter/pkg/server" | ||
) | ||
|
||
var version = "v1.6.0" | ||
var ( | ||
version = "development" | ||
) | ||
|
||
// main init configuration | ||
func main() { | ||
app := cli.NewApp() | ||
app.Name = "github-actions-exporter" | ||
app.Flags = config.NewContext() | ||
app.Action = runWeb | ||
app.Flags = config.InitConfiguration() | ||
app.Version = version | ||
app.Action = server.RunServer | ||
|
||
app.Run(os.Args) | ||
} | ||
|
||
// runWeb start http server | ||
func runWeb(ctx *cli.Context) { | ||
go metrics.WorkflowsCache() | ||
go metrics.GetRunnersFromGithub() | ||
go metrics.GetRunnersOrganizationFromGithub() | ||
go metrics.GetWorkflowRunsFromGithub() | ||
go metrics.GetBillableFromGithub() | ||
|
||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, "/metrics") | ||
}) | ||
http.Handle("/metrics", promhttp.Handler()) | ||
log.Printf("starting exporter with port %v", config.Port) | ||
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(config.Port), nil)) | ||
} | ||
|
||
// init prometheus metrics | ||
func init() { | ||
prometheus.MustRegister(metrics.RunnersGauge) | ||
prometheus.MustRegister(metrics.RunnersOrganizationGauge) | ||
prometheus.MustRegister(metrics.WorkflowRunStatusGauge) | ||
prometheus.MustRegister(metrics.WorkflowRunStatusDeprecatedGauge) | ||
prometheus.MustRegister(metrics.WorkflowRunDurationGauge) | ||
prometheus.MustRegister(metrics.WorkflowBillGauge) | ||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.