diff --git a/ekko/ekko.go b/ekko/ekko.go index b067efe..623a0b8 100644 --- a/ekko/ekko.go +++ b/ekko/ekko.go @@ -34,6 +34,8 @@ import ( "fmt" "net" "net/http" + "runtime/debug" + "strings" "time" "github.com/labstack/echo-contrib/echoprometheus" @@ -70,6 +72,7 @@ import ( // - WithGzipConfig(): Custom gzip compression settings func New(name string, options ...func(*Ekko)) (*Ekko, error) { ek := &Ekko{ + name: name, writeTimeout: 60 * time.Second, readHeaderTimeout: 30 * time.Second, } @@ -77,6 +80,20 @@ func New(name string, options ...func(*Ekko)) (*Ekko, error) { for _, o := range options { o(ek) } + + if ek.name == "" { + if bi, ok := debug.ReadBuildInfo(); ok && bi.Main.Path != "" { + if idx := strings.LastIndex(bi.Main.Path, "/"); idx >= 0 { + ek.name = bi.Main.Path[idx+1:] + } else { + ek.name = bi.Main.Path + } + } + if ek.name == "" { + ek.name = "ekko-app" + } + } + return ek, nil }