feat: add metric plugin (#361)

This commit is contained in:
boojack
2022-10-29 11:15:39 +08:00
committed by GitHub
parent 30daea0c4f
commit 95376f78f6
13 changed files with 157 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/usememos/memos/api"
"github.com/usememos/memos/common"
metric "github.com/usememos/memos/plugin/metrics"
"github.com/labstack/echo/v4"
)
@@ -58,6 +59,9 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create resource").SetInternal(err)
}
s.Collector.Collect(ctx, &metric.Metric{
Name: "resource created",
})
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(resource)); err != nil {