diff --git a/init_echo.go b/init_echo.go index 91ec5ed8..42f4d7d1 100644 --- a/init_echo.go +++ b/init_echo.go @@ -19,8 +19,6 @@ import ( "github.com/rs/zerolog" "github.com/ziflex/lecho/v3" "golang.org/x/time/rate" - ddEcho "gopkg.in/DataDog/dd-trace-go.v1/contrib/labstack/echo.v4" - "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) func initEcho(c *service.Config, logger *lecho.Logger) (e *echo.Echo) { @@ -32,12 +30,6 @@ func initEcho(c *service.Config, logger *lecho.Logger) (e *echo.Echo) { e.HTTPErrorHandler = responses.HTTPErrorHandler e.Validator = &lib.CustomValidator{Validator: validator.New()} - //if Datadog is configured, add datadog middleware - if c.DatadogAgentUrl != "" { - tracer.Start(tracer.WithAgentAddr(c.DatadogAgentUrl)) - defer tracer.Stop() - e.Use(ddEcho.Middleware(ddEcho.WithServiceName("lndhub.go"))) - } e.Use(middleware.Recover()) e.Use(middleware.BodyLimit("250K")) // set the default rate limit defining the overal max requests/second diff --git a/main.go b/main.go index 0123035c..bf00b9d3 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,8 @@ import ( "time" "github.com/getAlby/lndhub.go/rabbitmq" + ddEcho "gopkg.in/DataDog/dd-trace-go.v1/contrib/labstack/echo.v4" + "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" "github.com/getAlby/lndhub.go/db" "github.com/getAlby/lndhub.go/db/migrations" @@ -142,6 +144,13 @@ func main() { //init echo server e := initEcho(c, logger) + //if Datadog is configured, add datadog middleware + if c.DatadogAgentUrl != "" { + tracer.Start(tracer.WithAgentAddr(c.DatadogAgentUrl)) + defer tracer.Stop() + e.Use(ddEcho.Middleware(ddEcho.WithServiceName("lndhub.go"))) + } + logMw := createLoggingMiddleware(logger) // strict rate limit for requests for sending payments strictRateLimitMiddleware := createRateLimitMiddleware(c.StrictRateLimit, c.BurstRateLimit)