Skip to content

Commit 5a960b5

Browse files
authored
Create configurable metrics (#3975)
1 parent 7033e29 commit 5a960b5

File tree

15 files changed

+890
-266
lines changed

15 files changed

+890
-266
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ KUBE_RBAC_PROXY_VERSION ?= v0.11.0
2323
SHELLCHECK_VERSION ?= 0.8.0
2424

2525
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
26-
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
26+
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true"
2727

2828
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2929
ifeq (,$(shell go env GOBIN))

apis/actions.github.com/v1alpha1/autoscalinglistener_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ type AutoscalingListenerSpec struct {
6161
// +optional
6262
GitHubServerTLS *GitHubServerTLSConfig `json:"githubServerTLS,omitempty"`
6363

64+
// +optional
65+
Metrics *MetricsConfig `json:"metrics,omitempty"`
66+
6467
// +optional
6568
Template *corev1.PodTemplateSpec `json:"template,omitempty"`
6669
}

apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ type AutoscalingRunnerSetSpec struct {
7474
// Required
7575
Template corev1.PodTemplateSpec `json:"template,omitempty"`
7676

77+
// +optional
78+
ListenerMetrics *MetricsConfig `json:"listenerMetrics,omitempty"`
79+
7780
// +optional
7881
ListenerTemplate *corev1.PodTemplateSpec `json:"listenerTemplate,omitempty"`
7982

@@ -232,6 +235,32 @@ type ProxyServerConfig struct {
232235
CredentialSecretRef string `json:"credentialSecretRef,omitempty"`
233236
}
234237

238+
// MetricsConfig holds configuration parameters for each metric type
239+
type MetricsConfig struct {
240+
// +optional
241+
Counters map[string]*CounterMetric `json:"counters,omitempty"`
242+
// +optional
243+
Gauges map[string]*GaugeMetric `json:"gauges,omitempty"`
244+
// +optional
245+
Histograms map[string]*HistogramMetric `json:"histograms,omitempty"`
246+
}
247+
248+
// CounterMetric holds configuration of a single metric of type Counter
249+
type CounterMetric struct {
250+
Labels []string `json:"labels"`
251+
}
252+
253+
// GaugeMetric holds configuration of a single metric of type Gauge
254+
type GaugeMetric struct {
255+
Labels []string `json:"labels"`
256+
}
257+
258+
// HistogramMetric holds configuration of a single metric of type Histogram
259+
type HistogramMetric struct {
260+
Labels []string `json:"labels"`
261+
Buckets []float64 `json:"buckets,omitempty"`
262+
}
263+
235264
// AutoscalingRunnerSetStatus defines the observed state of AutoscalingRunnerSet
236265
type AutoscalingRunnerSetStatus struct {
237266
// +optional

apis/actions.github.com/v1alpha1/zz_generated.deepcopy.go

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalinglisteners.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,50 @@ spec:
119119
description: Required
120120
minimum: 0
121121
type: integer
122+
metrics:
123+
description: MetricsConfig holds configuration parameters for each metric type
124+
properties:
125+
counters:
126+
additionalProperties:
127+
description: CounterMetric holds configuration of a single metric of type Counter
128+
properties:
129+
labels:
130+
items:
131+
type: string
132+
type: array
133+
required:
134+
- labels
135+
type: object
136+
type: object
137+
gauges:
138+
additionalProperties:
139+
description: GaugeMetric holds configuration of a single metric of type Gauge
140+
properties:
141+
labels:
142+
items:
143+
type: string
144+
type: array
145+
required:
146+
- labels
147+
type: object
148+
type: object
149+
histograms:
150+
additionalProperties:
151+
description: HistogramMetric holds configuration of a single metric of type Histogram
152+
properties:
153+
buckets:
154+
items:
155+
type: number
156+
type: array
157+
labels:
158+
items:
159+
type: string
160+
type: array
161+
required:
162+
- labels
163+
type: object
164+
type: object
165+
type: object
122166
minRunners:
123167
description: Required
124168
minimum: 0

charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,50 @@ spec:
9999
x-kubernetes-map-type: atomic
100100
type: object
101101
type: object
102+
listenerMetrics:
103+
description: MetricsConfig holds configuration parameters for each metric type
104+
properties:
105+
counters:
106+
additionalProperties:
107+
description: CounterMetric holds configuration of a single metric of type Counter
108+
properties:
109+
labels:
110+
items:
111+
type: string
112+
type: array
113+
required:
114+
- labels
115+
type: object
116+
type: object
117+
gauges:
118+
additionalProperties:
119+
description: GaugeMetric holds configuration of a single metric of type Gauge
120+
properties:
121+
labels:
122+
items:
123+
type: string
124+
type: array
125+
required:
126+
- labels
127+
type: object
128+
type: object
129+
histograms:
130+
additionalProperties:
131+
description: HistogramMetric holds configuration of a single metric of type Histogram
132+
properties:
133+
buckets:
134+
items:
135+
type: number
136+
type: array
137+
labels:
138+
items:
139+
type: string
140+
type: array
141+
required:
142+
- labels
143+
type: object
144+
type: object
145+
type: object
102146
listenerTemplate:
103147
description: PodTemplateSpec describes the data a pod should have when created from a template
104148
properties:

charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,16 @@ spec:
106106
minRunners: {{ .Values.minRunners | int }}
107107
{{- end }}
108108

109-
{{- with .Values.listenerTemplate}}
109+
{{- with .Values.listenerTemplate }}
110110
listenerTemplate:
111111
{{- toYaml . | nindent 4}}
112112
{{- end }}
113113

114+
{{- with .Values.listenerMetrics }}
115+
listenerMetrics:
116+
{{- toYaml . | nindent 4 }}
117+
{{- end }}
118+
114119
template:
115120
{{- with .Values.template.metadata }}
116121
metadata:

0 commit comments

Comments
 (0)