server

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BillingMetricsExporter

type BillingMetricsExporter struct {
	GHClient *github.Client
	Logger   log.Logger
	Opts     Opts
}

func NewBillingMetricsExporter

func NewBillingMetricsExporter(logger log.Logger, opts Opts) *BillingMetricsExporter

func (*BillingMetricsExporter) StartOrgBilling

func (c *BillingMetricsExporter) StartOrgBilling(ctx context.Context) error

func (*BillingMetricsExporter) StartUserBilling

func (c *BillingMetricsExporter) StartUserBilling(ctx context.Context) error

type Opts

type Opts struct {
	MetricsPath          string
	ListenAddressMetrics string
	ListenAddressIngress string
	WebhookPath          string
	// GitHub webhook token.
	GitHubToken string
	// GitHub API token.
	GitHubAPIToken        string
	GitHubOrg             string
	GitHubUser            string
	BillingAPIPollSeconds int
}

type PrometheusObserver

type PrometheusObserver struct{}

func (*PrometheusObserver) CountWorkflowJobDuration

func (o *PrometheusObserver) CountWorkflowJobDuration(org, repo, branch, status, conclusion, runnerGroup string, seconds float64)

func (*PrometheusObserver) CountWorkflowJobStatus

func (o *PrometheusObserver) CountWorkflowJobStatus(org, repo, branch, status, conclusion, runnerGroup string)

func (*PrometheusObserver) CountWorkflowRunStatus

func (o *PrometheusObserver) CountWorkflowRunStatus(org, repo, branch, status, conclusion, workflowName string)

func (*PrometheusObserver) ObserveWorkflowJobDuration

func (o *PrometheusObserver) ObserveWorkflowJobDuration(org, repo, branch, state, runnerGroup string, seconds float64)

func (*PrometheusObserver) ObserveWorkflowRunDuration

func (o *PrometheusObserver) ObserveWorkflowRunDuration(org, repo, branch, workflowName string, seconds float64)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(logger log.Logger, opts Opts) *Server

func (*Server) Serve

func (s *Server) Serve(_ context.Context) error

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

type WorkflowMetricsExporter

type WorkflowMetricsExporter struct {
	GHClient           *github.Client
	Logger             log.Logger
	Opts               Opts
	PrometheusObserver WorkflowObserver
}

WorkflowMetricsExporter struct to hold some information

func NewWorkflowMetricsExporter

func NewWorkflowMetricsExporter(logger log.Logger, opts Opts) *WorkflowMetricsExporter

func (*WorkflowMetricsExporter) CollectWorkflowJobEvent

func (c *WorkflowMetricsExporter) CollectWorkflowJobEvent(event *github.WorkflowJobEvent)

func (*WorkflowMetricsExporter) CollectWorkflowRunEvent

func (c *WorkflowMetricsExporter) CollectWorkflowRunEvent(event *github.WorkflowRunEvent)

func (*WorkflowMetricsExporter) HandleGHWebHook

func (c *WorkflowMetricsExporter) HandleGHWebHook(w http.ResponseWriter, r *http.Request)

handleGHWebHook responds to POST /gh_event, when receive a event from GitHub.

type WorkflowObserver

type WorkflowObserver interface {
	ObserveWorkflowJobDuration(org, repo, branch, state, runnerGroup string, seconds float64)
	CountWorkflowJobStatus(org, repo, branch, status, conclusion, runnerGroup string)
	CountWorkflowJobDuration(org, repo, branch, status, conclusion, runnerGroup string, seconds float64)
	ObserveWorkflowRunDuration(org, repo, branch, workflow string, seconds float64)
	CountWorkflowRunStatus(org, repo, branch, status, conclusion, workflow string)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL