Skip to content

Commit

Permalink
Add metrics
Browse files Browse the repository at this point in the history
resolve #9
  • Loading branch information
halabooda committed Feb 23, 2025
1 parent 8652037 commit b53182e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/handler/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package handler

import (
"context"
"fmt"
"github.com/codiewio/codenire/internal/client"

Check failure on line 10 in internal/handler/server.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (goimports)
"io"
"net/http"
"time"
Expand Down Expand Up @@ -79,12 +81,21 @@ func NewServer(config *Config) (*http.Server, error) {
})

router.Get("/metrics", func(w http.ResponseWriter, r *http.Request) {
resp, err := http.Get(handler.Config.BackendURL + "/metrics")
req, err := http.NewRequestWithContext(

Check failure on line 84 in internal/handler/server.go

View workflow job for this annotation

GitHub Actions / lint

ineffectual assignment to err (ineffassign)
context.Background(),
http.MethodGet,
handler.Config.BackendURL+"/metrics",
nil,
)

resp, err := client.SandboxBackendClient().Do(req)
if err != nil {
http.Error(w, "Failed to fetch metrics from other service", http.StatusInternalServerError)
return
}
defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
_, err = io.Copy(w, resp.Body)
Expand Down

0 comments on commit b53182e

Please sign in to comment.