Skip to content
12 changes: 6 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ var rootCmd = &cobra.Command{
Config = loaded

logging.Init(Config.Logging)
logging.L().Debug("Logging initialized", "level", Config.Logging.Level)
logging.L().Debug("Loaded config", "config", Config)
logging.L().Debug("ElasticPHP-agent Logging initialized", "level", Config.Logging.Level)
logging.L().Debug("ElasticPHP-agent Loaded config", "config", Config)

// phpfpm autodiscover
if Config.PHPFpm.Enabled && Config.PHPFpm.Autodiscover {
Expand All @@ -115,16 +115,16 @@ var rootCmd = &cobra.Command{
break
}

logging.L().Warn("Autodiscover attempt failed", "attempt", i+1, "error", err)
logging.L().Debug("ElasticPHP-agent PHP-FPM autodiscover attempt failed", "attempt", i+1, "error", err)
time.Sleep(time.Duration(Config.PHPFpm.RetryDelay) * time.Second)
}

if err != nil {
logging.L().Error("Autodiscover failed after retries", "error", err)
logging.L().Error("ElasticPHP-agent PHP-FPM Autodiscover failed after retries", "error", err)
} else if len(discovered) == 0 {
logging.L().Error("Autodiscover succeeded but no FPM pools found")
logging.L().Error("ElasticPHP-agent PHP-FPM Autodiscover succeeded but no FPM pools found")
} else {
logging.L().Debug("Discovered FPM Processes", "pools", discovered)
logging.L().Debug("ElasticPHP-agent Discovered PHP-FPM Processes", "pools", discovered)
for _, d := range discovered {
Config.PHPFpm.Pools = append(Config.PHPFpm.Pools, config.FPMPoolConfig{
Socket: d.Socket,
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var serveCmd = &cobra.Command{
Use: "serve",
Short: "Start agent HTTP server with metrics and control endpoints",
Run: func(cmd *cobra.Command, args []string) {
logging.L().Info("Starting elasticphp-agent")
logging.L().Info("ElasticPHP-agent Starting")
serve.StartPrometheusServer(Config)
},
}
Expand Down
13 changes: 12 additions & 1 deletion internal/laravel/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
Expand Down Expand Up @@ -110,9 +111,19 @@ func GetAppInfo(site config.LaravelConfig, phpBinary string) (*AppInfo, error) {
return info, nil
}

logging.L().Debug("Uncached app info. Calling artisan about", "path", site.Path)
logging.L().Debug("ElasticPHP-agent Uncached app info. Calling artisan about", "path", site.Path)

cmd := exec.Command(phpBinary, "-d", "error_reporting=E_ALL & ~E_DEPRECATED", "artisan", "about", "--json")

// disable monitoring on scraping to prevent exhausting monitoring tools
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "NIGHTWATCH_ENABLED=false")
cmd.Env = append(cmd.Env, "TELESCOPE_ENABLED=false")
cmd.Env = append(cmd.Env, "NEW_RELIC_ENABLED=false")
cmd.Env = append(cmd.Env, "BUGSNAG_API_KEY=null")
cmd.Env = append(cmd.Env, "SENTRY_LARAVEL_DSN=null")
cmd.Env = append(cmd.Env, "ROLLBAR_TOKEN=null")

cmd.Dir = cacheKey

var out bytes.Buffer
Expand Down
10 changes: 5 additions & 5 deletions internal/phpfpm/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func DiscoverFPMProcesses() ([]DiscoveredFPM, error) {

exe, err := p.Exe()
if err != nil {
logging.L().Debug("Cannot determine binary path", "pid", p.Pid, "error", err)
logging.L().Debug("ElasticPHP-agent Cannot determine binary path", "pid", p.Pid, "error", err)
continue
}

parsed, err := ParseFPMConfig(exe, config)
if err != nil {
logging.L().Error("Failed to parse FPM config", "config", config, "error", err)
logging.L().Error("ElasticPHP-agent ElasticPHP-agent Failed to parse FPM config", "config", config, "error", err)
continue
}

Expand All @@ -77,7 +77,7 @@ func DiscoverFPMProcesses() ([]DiscoveredFPM, error) {
status = parsed.Global["pm.status_path"]
}
if status == "" {
logging.L().Debug("Skipping pool with no status path", "pool", poolName, "config", config)
logging.L().Debug("ElasticPHP-agent Skipping pool with no status path", "pool", poolName, "config", config)
continue
}

Expand All @@ -92,7 +92,7 @@ func DiscoverFPMProcesses() ([]DiscoveredFPM, error) {
CliBinary: cliBinary,
})

logging.L().Debug("Discovered php-fpm pool",
logging.L().Debug("ElasticPHP-agent Discovered php-fpm pool",
"config", config,
"pool", poolName,
"socket", socket,
Expand Down Expand Up @@ -125,7 +125,7 @@ func parseSocket(socket string) string {
resolved = candidate
break
} else {
logging.L().Warn("Failed to connect to socket", "socket", candidate, "error", err)
logging.L().Warn("ElasticPHP-agent Failed to connect to PHP-FPM socket", "socket", candidate, "error", err)
}
}
if resolved != "" {
Expand Down
16 changes: 8 additions & 8 deletions internal/phpfpm/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ func GetMetrics(ctx context.Context, cfg *config.Config) (map[string]*Result, er

scheme, address, path, err := ParseAddress(poolCfg.StatusSocket, poolCfg.StatusPath)
if err != nil {
logging.L().Error("invalid FPM socket address: %v", slog.Any("err", err))
logging.L().Error("ElasticPHP-agent Invalid FPM socket address: %v", slog.Any("err", err))
continue
}

dialCtx, cancel := context.WithTimeout(ctx, 3*time.Second)
logging.L().Debug("Dialing FastCGI", "scheme", scheme, "address", address, "status_path", path)
logging.L().Debug("ElasticPHP-agent Dialing FastCGI", "scheme", scheme, "address", address, "status_path", path)
client, err := fcgx.DialContext(dialCtx, scheme, address)
cancel()
if err != nil {
logging.L().Debug("failed to dial FastCGI", "error", err)
logging.L().Debug("ElasticPHP-agent failed to dial FastCGI", "error", err)
continue
}
defer client.Close()
Expand All @@ -94,11 +94,11 @@ func GetMetrics(ctx context.Context, cfg *config.Config) (map[string]*Result, er
"REMOTE_ADDR": "127.0.0.1",
"QUERY_STRING": "json&full",
}
logging.L().Debug("Sending FCGI request", "env", env)
logging.L().Debug("ElasticPHP-agent Sending FCGI request", "env", env)

resp, err := client.Get(ctx, env)
if err != nil {
logging.L().Debug("fcgi GET failed", "error", err)
logging.L().Debug("ElasticPHP-agent fcgi GET failed", "error", err)
continue
}
defer resp.Body.Close()
Expand All @@ -107,7 +107,7 @@ func GetMetrics(ctx context.Context, cfg *config.Config) (map[string]*Result, er
err = fcgx.ReadJSON(resp, &pool)

if err != nil {
logging.L().Error("failed to parse FPM JSON: %v", slog.Any("err", err))
logging.L().Error("ElasticPHP-agent failed to parse FPM JSON: %v", slog.Any("err", err))
continue
}

Expand Down Expand Up @@ -147,14 +147,14 @@ func GetMetrics(ctx context.Context, cfg *config.Config) (map[string]*Result, er
if err == nil && phpStatus != nil {
pool.PhpInfo = *phpStatus
} else {
logging.L().Debug("failed to get PHP info", "error", err)
logging.L().Debug("ElasticPHP-agent failed to get PHP info", "error", err)
}

opcacheStatus, err := GetOpcacheStatus(ctx, poolCfg)
if err == nil && opcacheStatus != nil {
pool.OpcacheStatus = *opcacheStatus
} else {
logging.L().Debug("failed to get Opcache info", "error", err)
logging.L().Debug("ElasticPHP-agent failed to get Opcache info", "error", err)
}

result.Pools[pool.Name] = pool
Expand Down
4 changes: 2 additions & 2 deletions internal/serve/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ func StartPrometheusServer(cfg *config.Config) {
Handler: mux,
}

logging.L().Debug("Prometheus metrics server listening", slog.Any("addr", cfg.Monitor.ListenAddr))
logging.L().Debug("ElasticPHP-agent Prometheus metrics server listening", slog.Any("addr", cfg.Monitor.ListenAddr))
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
logging.L().Error("Failed to start Prometheus server", slog.Any("err", err))
logging.L().Error("ElasticPHP-agent Failed to start Prometheus server", slog.Any("err", err))
}
}
Loading