aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddy.go
diff options
context:
space:
mode:
authorMohammed Al Sahaf <[email protected]>2024-10-02 17:23:26 +0300
committerGitHub <[email protected]>2024-10-02 08:23:26 -0600
commit41f5dd56e1b93ec815daa98dd1f1caa7f2087312 (patch)
tree4802459d6c89d6cbaf064d02b445130fa361b12d /caddy.go
parent16724842d9b9096b800326d0b7667a4361552552 (diff)
downloadcaddy-41f5dd56e1b93ec815daa98dd1f1caa7f2087312.tar.gz
caddy-41f5dd56e1b93ec815daa98dd1f1caa7f2087312.zip
metrics: scope metrics to active config, add optional per-host metrics (#6531)v2.9.0-beta.1
* Add per host config * Pass host label when option is enabled * Test per host enabled * metrics: scope metrics per loaded config * doc and linter Signed-off-by: Mohammed Al Sahaf <[email protected]> * inject the custom registry into the admin handler Co-Authored-By: Dave Henderson <[email protected]> * remove `TODO` comment * fixes Signed-off-by: Mohammed Al Sahaf <[email protected]> * refactor to delay metrics admin handler provision Signed-off-by: Mohammed Al Sahaf <[email protected]> --------- Signed-off-by: Mohammed Al Sahaf <[email protected]> Co-authored-by: Hussam Almarzooq <[email protected]> Co-authored-by: Dave Henderson <[email protected]>
Diffstat (limited to 'caddy.go')
-rw-r--r--caddy.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/caddy.go b/caddy.go
index 7dd989c9e..b3e8889fa 100644
--- a/caddy.go
+++ b/caddy.go
@@ -399,6 +399,7 @@ func unsyncedDecodeAndRun(cfgJSON []byte, allowPersist bool) error {
func run(newCfg *Config, start bool) (Context, error) {
ctx, err := provisionContext(newCfg, start)
if err != nil {
+ globalMetrics.configSuccess.Set(0)
return ctx, err
}
@@ -410,6 +411,7 @@ func run(newCfg *Config, start bool) (Context, error) {
// some of the other apps at runtime
err = ctx.cfg.Admin.provisionAdminRouters(ctx)
if err != nil {
+ globalMetrics.configSuccess.Set(0)
return ctx, err
}
@@ -435,9 +437,11 @@ func run(newCfg *Config, start bool) (Context, error) {
return nil
}()
if err != nil {
+ globalMetrics.configSuccess.Set(0)
return ctx, err
}
-
+ globalMetrics.configSuccess.Set(1)
+ globalMetrics.configSuccessTime.SetToCurrentTime()
// now that the user's config is running, finish setting up anything else,
// such as remote admin endpoint, config loader, etc.
return ctx, finishSettingUp(ctx, ctx.cfg)
@@ -471,6 +475,7 @@ func provisionContext(newCfg *Config, replaceAdminServer bool) (Context, error)
ctx, cancel := NewContext(Context{Context: context.Background(), cfg: newCfg})
defer func() {
if err != nil {
+ globalMetrics.configSuccess.Set(0)
// if there were any errors during startup,
// we should cancel the new context we created
// since the associated config won't be used;
@@ -497,7 +502,7 @@ func provisionContext(newCfg *Config, replaceAdminServer bool) (Context, error)
// start the admin endpoint (and stop any prior one)
if replaceAdminServer {
- err = replaceLocalAdminServer(newCfg)
+ err = replaceLocalAdminServer(newCfg, ctx)
if err != nil {
return ctx, fmt.Errorf("starting caddy administration endpoint: %v", err)
}