Skip to content

Conversation

@raelga
Copy link

@raelga raelga commented Jun 16, 2025

This pull request introduces several updates to modernize the codebase, including upgrading dependencies, switching to a newer logging library, and following Prometheus metric naming conventions. The changes enhance compatibility, improve readability, and align with current best practices.

Dependency Updates:

  • Updated the Go version in Dockerfile to 1.24.4 and in go.mod to 1.24. This ensures compatibility with the latest language features and optimizations.
  • Upgraded Prometheus and other dependencies in go.mod to newer versions, improving stability and adding support for modern features.

Logging Library Migration:

  • Replaced go-kit/log with slog for logging in collect.go and main.go. This simplifies log handling and improves the structure of log messages.

Metric Naming Improvements:

Code Refactoring:

  • Replaced promlog with promslog in main.go to align with updated Prometheus libraries. Adjusted related flag and logger initialization accordingly.

These changes collectively enhance the maintainability, readability, and compliance of the codebase with modern standards. It will introduce breaking changes, as all the metrics will be renamed. The current names, raise errors in modern prometheus installations:

ts=2025-06-16T21:00:34.529958436Z caller=rule.go:945 level=warn component=rules warnings="PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: \"sendgrid_requests\"" query="increase(sendgrid_requests{namespace=\"prometheus-exporter\"}[1h]) > 30000"
ts=2025-06-16T21:00:34.532503147Z caller=rule.go:945 level=warn component=rules warnings="PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: \"sendgrid_bounce_drops\"" 

...
ts=2025-06-16T21:04:04.535100232Z caller=rule.go:945 level=warn component=rules warnings="PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: \"sendgrid_bounce_drops\"" query="increase(sendgrid_bounce_drops{namespace=\"prometheus-exporter\"}[1h]) > 6000"

raelga added 2 commits June 16, 2025 22:54
Signed-off-by: Rael Garcia <rael@redhat.com>
Signed-off-by: Rael Garcia <rael@redhat.com>
@raelga
Copy link
Author

raelga commented Jun 16, 2025

cc @cw-sakamoto

Signed-off-by: Rael Garcia <rael@redhat.com>

blocks: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "blocks"),
prometheus.BuildFQName(namespace, "", "blocks_total"),

Choose a reason for hiding this comment

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

we rename the values to total here because they are counters, but further down we still treat them as gauge_values and not as counters, are you sure they are counters?

From me scanning the source code they are not actually total counters but daily counters, because we only request the statistics for a single day.

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.

2 participants