Skip to content

Commit

Permalink
lxd: Update CountStartedRequest usage
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Sep 11, 2024
1 parent bd1b081 commit ad6a2ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lxd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func restServer(d *Daemon) *http.Server {
}

mux.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
lxdRequest.CountStartedRequest(r)
metrics.TrackStartedRequest(r)
logger.Info("Sending top level 404", logger.Ctx{"url": r.URL, "method": r.Method, "remote": r.RemoteAddr})
w.Header().Set("Content-Type", "application/json")
_ = response.NotFound(nil).Render(w, r)
Expand Down Expand Up @@ -264,7 +264,7 @@ func metricsServer(d *Daemon) *http.Server {
d.createCmd(mux, "1.0", metricsCmd)

mux.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
lxdRequest.CountStartedRequest(r)
metrics.TrackStartedRequest(r)
logger.Info("Sending top level 404", logger.Ctx{"url": r.URL, "method": r.Method, "remote": r.RemoteAddr})
w.Header().Set("Content-Type", "application/json")
_ = response.NotFound(nil).Render(w, r)
Expand Down
3 changes: 2 additions & 1 deletion lxd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/canonical/lxd/lxd/lifecycle"
"github.com/canonical/lxd/lxd/loki"
"github.com/canonical/lxd/lxd/maas"
"github.com/canonical/lxd/lxd/metrics"
networkZone "github.com/canonical/lxd/lxd/network/zone"
"github.com/canonical/lxd/lxd/node"
"github.com/canonical/lxd/lxd/request"
Expand Down Expand Up @@ -636,7 +637,7 @@ func (d *Daemon) createCmd(restAPI *mux.Router, version string, c APIEndpoint) {
// Only endpoints from the main API (version 1.0) should be counted for the metrics.
// This prevents internal endpoints from being included as well.
if version == "1.0" {
request.CountStartedRequest(r)
metrics.TrackStartedRequest(r)
}

w.Header().Set("Content-Type", "application/json")
Expand Down

0 comments on commit ad6a2ba

Please sign in to comment.