rollbar めちゃくちゃ便利です。安いし。
rollbar.com
main.go rollbar.SetToken("") rollbar.SetEnvironment(os.Getenv("SERVER_ENV")) rollbar.SetCodeVersion("v2") rollbar.SetServerHost(hostName) rollbar.SetServerRoot("github.com/rluisr/easyuploader_api")
error を返すときは
handler.go errorWithResponseInternalServer(c, "PreSigned", "failed to isPremiumJWT", "error", err) return
error.go func ErrorLogger(c *gin.Context, funcName, msg string, err error, level string) { rollbar.ErrorWithExtrasAndContext(c.Request.Context(), level, err, map[string]interface{}{"func_name": funcName, "client_ip": c.ClientIP(), "user_agent": c.Request.UserAgent()}) } func errorWithResponseInternalServer(c *gin.Context, funcName, msg, resMsg string, err error) { ErrorLogger(c, funcName, msg, err, rollbar.CRIT) c.JSON(http.StatusInternalServerError, resMsg) }
Traceback
interface で投げた内容は Occurrences で確認できる