add log for apm

This commit is contained in:
namhq1989 2023-02-25 12:41:31 +07:00
parent 75e000f385
commit 5a5cba6254
1 changed files with 3 additions and 2 deletions

View File

@ -33,14 +33,15 @@ func Connect(uri, password string) (*Server, error) {
} }
// add apm // add apm
if os.Getenv("ELASTIC_APM_SERVER_URL") != "" { useElasticAPM := os.Getenv("ELASTIC_APM_SERVER_URL") != ""
if useElasticAPM {
rdb.AddHook(apmgoredis.NewHook()) rdb.AddHook(apmgoredis.NewHook())
} }
// assign data // assign data
r = &Server{rdb: rdb} r = &Server{rdb: rdb}
fmt.Printf("⚡️[redis]: connected to %s \n", uri) fmt.Printf("⚡️[redis]: connected to %s, use elastic apm: %t \n", uri, useElasticAPM)
return r, nil return r, nil
} }