You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add Go main.go with Prometheus exporter-toolkit (#48)
* feat: add Go main.go with oslo.db connection string support
This commit adds a complete Go-based main entry point for the OpenStack
Database Exporter that integrates all existing collectors and supports
oslo.db-style MySQL connection strings.
Key changes:
- Add cmd/openstack-database-exporter/main.go as the main entry point
- Add internal/dsn package for parsing oslo.db connection strings
(mysql://, mysql+pymysql://, mysql+mysqldb://, etc.)
- Register all collectors based on environment variables:
- CINDER_DATABASE_URL
- GLANCE_DATABASE_URL
- KEYSTONE_DATABASE_URL
- MAGNUM_DATABASE_URL
- MANILA_DATABASE_URL
- NEUTRON_DATABASE_URL
- OCTAVIA_DATABASE_URL
- PLACEMENT_DATABASE_URL
- Fix magnum collector Collect() methods to match Prometheus interface
- Add github.com/go-sql-driver/mysql dependency
The exporter runs on port 9180 by default (configurable via EXPORTER_PORT)
and exposes metrics at /metrics endpoint.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Mohammed Naser <[email protected]>
* refactor: use prometheus exporter-toolkit for HTTP server
Replace custom HTTP server implementation with the standard
prometheus/exporter-toolkit pattern, which provides:
- TLS support via --web.config.file flag
- Standard logging via promslog
- Landing page with exporter info
- Command-line flags via kingpin (with env var support)
- Graceful shutdown handling
Database URLs can now be configured via both CLI flags and
environment variables:
--cinder.database-url / CINDER_DATABASE_URL
--glance.database-url / GLANCE_DATABASE_URL
--keystone.database-url / KEYSTONE_DATABASE_URL
--magnum.database-url / MAGNUM_DATABASE_URL
--manila.database-url / MANILA_DATABASE_URL
--neutron.database-url / NEUTRON_DATABASE_URL
--octavia.database-url / OCTAVIA_DATABASE_URL
--placement.database-url / PLACEMENT_DATABASE_URL
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Mohammed Naser <[email protected]>
* chore: add Go binary to .gitignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Mohammed Naser <[email protected]>
* refactor: add RegisterCollectors function to each service package
Move collector registration logic into each service package,
encapsulating the knowledge of which collectors exist within
each package. This simplifies main.go and makes it easier to
add new collectors without modifying the main entry point.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Mohammed Naser <[email protected]>
* refactor: centralize collector registration and database connection handling
- Add collector.NewRegistry() for centralized registry creation
- Move DSN parsing to internal/db/dsn.go with Connect() in db.go
- Each service package now handles its own database connection
- Add Namespace constant to each service package to avoid import cycles
- Move StatusToValue utility to internal/util/ to break import cycle
- Log info message when collector not loaded due to missing database URL
- Simplify main.go to use single collector.Config struct
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Mohammed Naser <[email protected]>
* refactor: remove error return from RegisterCollectors
Since errors are logged internally and we continue regardless,
the error return was misleading. Now the functions simply log
and return early on failure, which is more honest about the behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Mohammed Naser <[email protected]>
---------
Signed-off-by: Mohammed Naser <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
0 commit comments