mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-16 04:12:16 +01:00
chore: minor refactor of the prometheus module
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
gotenberg.MustRegisterModule(Prometheus{})
|
||||
gotenberg.MustRegisterModule(new(Prometheus))
|
||||
}
|
||||
|
||||
// Prometheus is a module which collects metrics and exposes them via an HTTP
|
||||
@@ -32,8 +32,8 @@ type Prometheus struct {
|
||||
registry *prometheus.Registry
|
||||
}
|
||||
|
||||
// Descriptor returns a Prometheus's module descriptor.
|
||||
func (Prometheus) Descriptor() gotenberg.ModuleDescriptor {
|
||||
// Descriptor returns a [Prometheus]'s module descriptor.
|
||||
func (mod *Prometheus) Descriptor() gotenberg.ModuleDescriptor {
|
||||
return gotenberg.ModuleDescriptor{
|
||||
ID: "prometheus",
|
||||
FlagSet: func() *flag.FlagSet {
|
||||
@@ -88,7 +88,7 @@ func (mod *Prometheus) Provision(ctx *gotenberg.Context) error {
|
||||
}
|
||||
|
||||
// Validate validates the module properties.
|
||||
func (mod Prometheus) Validate() error {
|
||||
func (mod *Prometheus) Validate() error {
|
||||
if mod.disableCollect {
|
||||
// Exit early.
|
||||
return nil
|
||||
@@ -120,7 +120,7 @@ func (mod Prometheus) Validate() error {
|
||||
}
|
||||
|
||||
// Start starts the collect.
|
||||
func (mod Prometheus) Start() error {
|
||||
func (mod *Prometheus) Start() error {
|
||||
if mod.disableCollect {
|
||||
// Exit early.
|
||||
return nil
|
||||
@@ -149,7 +149,7 @@ func (mod Prometheus) Start() error {
|
||||
}
|
||||
|
||||
// StartupMessage returns a custom startup message.
|
||||
func (mod Prometheus) StartupMessage() string {
|
||||
func (mod *Prometheus) StartupMessage() string {
|
||||
if mod.disableCollect {
|
||||
return "collect disabled"
|
||||
}
|
||||
@@ -158,12 +158,12 @@ func (mod Prometheus) StartupMessage() string {
|
||||
}
|
||||
|
||||
// Stop does nothing.
|
||||
func (mod Prometheus) Stop(_ context.Context) error {
|
||||
func (mod *Prometheus) Stop(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Routes returns the HTTP route.
|
||||
func (mod Prometheus) Routes() ([]api.Route, error) {
|
||||
func (mod *Prometheus) Routes() ([]api.Route, error) {
|
||||
if mod.disableCollect {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user