Skip to content

Commit

Permalink
Merge pull request #310 from authzed/metricns
Browse files Browse the repository at this point in the history
metrics: make metric namespace configurable
  • Loading branch information
vroldanbet authored May 8, 2024
2 parents c0547f9 + 56fe69b commit e44def3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ type Options struct {
BootstrapCRDs bool
BootstrapSpicedbsPath string
OperatorConfigPath string

MetricNamespace string
}

// RecommendedOptions builds a new options config with default values
func RecommendedOptions() *Options {
return &Options{
ConfigFlags: genericclioptions.NewConfigFlags(true),
DebugFlags: ctrlmanageropts.RecommendedDebuggingOptions(),
DebugAddress: ":8080",
ConfigFlags: genericclioptions.NewConfigFlags(true),
DebugFlags: ctrlmanageropts.RecommendedDebuggingOptions(),
DebugAddress: ":8080",
MetricNamespace: "spicedb_operator",
}
}

Expand Down Expand Up @@ -147,7 +150,7 @@ func (o *Options) Run(ctx context.Context, f cmdutil.Factory) error {
controllers = append(controllers, ctrl)

// register with metrics collector
spiceDBClusterMetrics := ctrlmetrics.NewConditionStatusCollector[*v1alpha1.SpiceDBCluster]("spicedb_operator", "clusters", v1alpha1.SpiceDBClusterResourceName)
spiceDBClusterMetrics := ctrlmetrics.NewConditionStatusCollector[*v1alpha1.SpiceDBCluster](o.MetricNamespace, "clusters", v1alpha1.SpiceDBClusterResourceName)
lister := typed.ListerFor[*v1alpha1.SpiceDBCluster](registry, typed.NewRegistryKey(controller.OwnedFactoryKey, v1alpha1ClusterGVR))
spiceDBClusterMetrics.AddListerBuilder(func() ([]*v1alpha1.SpiceDBCluster, error) {
return lister.List(labels.Everything())
Expand Down

0 comments on commit e44def3

Please sign in to comment.