metrics

package
v0.0.0-...-a53de21 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ThemeExporter = exporter.Exporter[*webhostingv1alpha1.Theme, *webhostingv1alpha1.ThemeList]{
	Namespace: namespace,
	Subsystem: "theme",

	StaticLabelKeys: []string{"theme", "uid"},
	GenerateStaticLabelValues: func(theme *webhostingv1alpha1.Theme) []string {
		return []string{theme.Name, string(theme.UID)}
	},

	Metrics: []exporter.Metric[*webhostingv1alpha1.Theme]{
		{
			Name:      "info",
			Help:      "Information about a Theme",
			LabelKeys: []string{"color", "font_family"},

			Generate: func(desc *prometheus.Desc, theme *webhostingv1alpha1.Theme, staticLabelValues []string, ch chan<- prometheus.Metric) {
				ch <- prometheus.MustNewConstMetric(
					desc,
					prometheus.GaugeValue,
					1,
					append(staticLabelValues, theme.Spec.Color, theme.Spec.FontFamily)...,
				)
			},
		},
		{
			Name: "metadata_generation",
			Help: "The generation of a Theme",

			Generate: func(desc *prometheus.Desc, theme *webhostingv1alpha1.Theme, staticLabelValues []string, ch chan<- prometheus.Metric) {
				ch <- prometheus.MustNewConstMetric(
					desc,
					prometheus.GaugeValue,
					float64(theme.Generation),
					staticLabelValues...,
				)
			},
		},
	},
}
View Source
var WebsiteExporter = exporter.Exporter[*webhostingv1alpha1.Website, *webhostingv1alpha1.WebsiteList]{
	Namespace: namespace,
	Subsystem: "website",

	StaticLabelKeys: []string{"namespace", "website", "uid"},
	GenerateStaticLabelValues: func(website *webhostingv1alpha1.Website) []string {
		return []string{website.Namespace, website.Name, string(website.UID)}
	},

	Metrics: []exporter.Metric[*webhostingv1alpha1.Website]{
		{
			Name:      "info",
			Help:      "Information about a Website",
			LabelKeys: []string{"theme"},

			Generate: func(desc *prometheus.Desc, website *webhostingv1alpha1.Website, staticLabelValues []string, ch chan<- prometheus.Metric) {
				ch <- prometheus.MustNewConstMetric(
					desc,
					prometheus.GaugeValue,
					1,
					append(staticLabelValues, website.Spec.Theme)...,
				)
			},
		},
		{
			Name:      "shard",
			Help:      "Sharding information about a Website",
			LabelKeys: []string{"shard", "drain"},

			Generate: func(desc *prometheus.Desc, website *webhostingv1alpha1.Website, staticLabelValues []string, ch chan<- prometheus.Metric) {
				ch <- prometheus.MustNewConstMetric(
					desc,
					prometheus.GaugeValue,
					1,
					append(staticLabelValues,
						website.Labels[shardingv1alpha1.LabelShard(webhostingv1alpha1.WebhostingOperatorName)],
						website.Labels[shardingv1alpha1.LabelDrain(webhostingv1alpha1.WebhostingOperatorName)],
					)...,
				)
			},
		},
		{
			Name: "metadata_generation",
			Help: "The generation of a Website",

			Generate: func(desc *prometheus.Desc, website *webhostingv1alpha1.Website, staticLabelValues []string, ch chan<- prometheus.Metric) {
				ch <- prometheus.MustNewConstMetric(
					desc,
					prometheus.GaugeValue,
					float64(website.Generation),
					staticLabelValues...,
				)
			},
		},
		{
			Name: "observed_generation",
			Help: "The latest generation observed by the Website controller",

			Generate: func(desc *prometheus.Desc, website *webhostingv1alpha1.Website, staticLabelValues []string, ch chan<- prometheus.Metric) {
				ch <- prometheus.MustNewConstMetric(
					desc,
					prometheus.GaugeValue,
					float64(website.Status.ObservedGeneration),
					staticLabelValues...,
				)
			},
		},
		{
			Name:      "status_phase",
			Help:      "The Website's current phase (StateSet)",
			LabelKeys: []string{"phase"},

			Generate: exporter.GenerateStateSet[*webhostingv1alpha1.Website](
				exporter.KnownStates(webhostingv1alpha1.AllWebsitePhases), nil,
				func(website *webhostingv1alpha1.Website) string {
					return string(website.Status.Phase)
				},
			),
		},
	},
}

Functions

func AddToManager

func AddToManager(mgr manager.Manager) error

AddToManager adds all metrics exporters for webhosting objects to the manager.

Types

This section is empty.

Jump to

Keyboard shortcuts

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