Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prometheus metrics #190

Conversation

mrlihanbo
Copy link
Collaborator

No description provided.

if s.logMetrics {
fields := convertTToFields(tags)
msg := fmt.Sprintf("counter %s.%s + %v", s.prefix, name, val)
msg := fmt.Sprintf("rate %s_%s + %v", s.prefix, name, val)
log.WithFields(fields).Infoln(msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider removing the logrus dependency?

ctx, keyedLogger := logging.InjectLoggerValues(ctx, "origin", "reconcileLeader", "type", key.sourceGK.String(), "key", key.ObjectSourceKey())
startTime := time.Now()

keyedLogger.V(3).Info("Starting reconcileLeader")
defer func() {
c.metrics.Duration(fmt.Sprintf("follower-controller-%s.latency", key.sourceGK.String()), startTime)
c.metrics.Duration(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add these KV to all controller reconcile metrics?

flags.BoolVar(&o.PrometheusMetrics, "export-prometheus", true, "Whether to expose metrics through a prometheus endpoint")
flags.StringVar(&o.PrometheusAddr, "prometheus-addr", "", "prometheus collector address")
flags.Uint16Var(&o.PrometheusPort, "prometheus-port", 9090, "prometheus collector port")
flags.StringToStringVar(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to pass quantiles as parameters to the controller? Kind of rare.

@@ -123,6 +128,16 @@ func (o *Options) AddFlags(flags *pflag.FlagSet, allControllers []string, disabl
flags.BoolVar(&o.EnablePodPruning, "enable-pod-pruning", false, "Enable pod pruning for pod informer. "+
"Enabling this can reduce memory usage of the pod informer, but will disable pod propagation.")
o.addKlogFlags(flags)

flags.BoolVar(&o.PrometheusMetrics, "export-prometheus", true, "Whether to expose metrics through a prometheus endpoint")
flags.StringVar(&o.PrometheusAddr, "prometheus-addr", "", "prometheus collector address")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flags.StringVar(&o.PrometheusAddr, "prometheus-addr", "", "prometheus collector address")
flags.StringVar(&o.PrometheusAddr, "prometheus-addr", "", "Prometheus collector address")

Capitalize the first letter of the description.

@mrlihanbo mrlihanbo merged commit 7b3fe83 into kubewharf:refactor/unified-federated-type Aug 7, 2023
5 checks passed
miraclejzd pushed a commit to miraclejzd/kubeadmiral that referenced this pull request Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants