Skip to content

Commit

Permalink
feat: change log format to logfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
butschi84 committed Dec 6, 2023
1 parent 5d8c6b5 commit f1dd04a
Show file tree
Hide file tree
Showing 30 changed files with 92 additions and 104 deletions.
11 changes: 6 additions & 5 deletions f2soperator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module butschi84/f2s
go 1.19

require (
github.com/confluentinc/confluent-kafka-go v1.9.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/prometheus/client_golang v1.16.0
Expand All @@ -15,9 +17,7 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/confluentinc/confluent-kafka-go v1.9.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
Expand All @@ -40,11 +40,12 @@ require (
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
Expand Down
19 changes: 8 additions & 11 deletions f2soperator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03D
github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down Expand Up @@ -95,7 +94,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
github.com/google/pprof v0.0.0-20211008130755-947d60d73cc0 h1:zHs+jv3LO743/zFGcByu2KmpbliCU2AhjcGgrdTwSG4=
github.com/google/pprof v0.0.0-20211008130755-947d60d73cc0/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand All @@ -118,7 +116,6 @@ github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuT
github.com/jhump/protoreflect v1.12.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
Expand Down Expand Up @@ -152,13 +149,11 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nrwiersma/avro-benchmarks v0.0.0-20210913175520-21aec48c8f76/go.mod h1:iKyFMidsk/sVYONJRE372sJuX/QTRPacU7imPqqsu7g=
github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk=
github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
Expand Down Expand Up @@ -197,6 +192,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No=
golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand All @@ -216,8 +213,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s=
Expand All @@ -242,14 +239,14 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
3 changes: 2 additions & 1 deletion f2soperator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import (
"butschi84/f2s/state/operatorstate"
"butschi84/f2s/state/queue"
"fmt"
"log/slog"
"sync"
)

var (
F2SConfiguration configuration.F2SConfiguration
logging logger.F2SLogger
logging *slog.Logger
F2SHub hub.F2SHub
)

Expand Down
2 changes: 1 addition & 1 deletion f2soperator/operation/apiserver/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func getUsers() ([]queue.F2SAuthUser, error) {
return []byte(jwtSecret), nil
})
if err != nil {
logging.Error(fmt.Errorf("error decoding token '%s': %s", f2shub.F2SConfiguration.Config.F2S.Auth.Token.Tokens[i].Token, err.Error()))
logging.Error(fmt.Sprintf("error decoding token '%s': %s", f2shub.F2SConfiguration.Config.F2S.Auth.Token.Tokens[i].Token, err.Error()))
continue
}

Expand Down
2 changes: 1 addition & 1 deletion f2soperator/operation/apiserver/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func createFunction(w http.ResponseWriter, r *http.Request) {

// Unmarshal the JSON data into the function struct
if err := json.Unmarshal(body, &function); err != nil {
logging.Error(err)
logging.Error(fmt.Sprintf("%s", err))
http.Error(w, "Failed to parse JSON data", http.StatusBadRequest)
return
}
Expand Down
4 changes: 2 additions & 2 deletions f2soperator/operation/apiserver/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func invokeFunction(w http.ResponseWriter, r *http.Request) {
// get user info
currentUser, getUserErr := getCurrentUser(r)
if getUserErr != nil {
logging.Error(fmt.Errorf("[%s] failed to get user info for this request", request.UID))
logging.Error(fmt.Sprintf("[%s] failed to get user info for this request", request.UID))
}
request.F2SUser = currentUser

Expand All @@ -82,7 +82,7 @@ func invokeFunction(w http.ResponseWriter, r *http.Request) {
logging.Debug(fmt.Sprintf("[%s] reading request body", request.UID))
body, err := io.ReadAll(r.Body)
if err != nil {
logging.Error(fmt.Errorf("[%s] Failed to read request body", request.UID))
logging.Error(fmt.Sprintf("[%s] Failed to read request body", request.UID))
http.Error(w, "Failed to read request body", http.StatusInternalServerError)
return
}
Expand Down
3 changes: 2 additions & 1 deletion f2soperator/operation/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"butschi84/f2s/services/logger"
"butschi84/f2s/state/configuration"
"fmt"
"log/slog"
"net/http"
"regexp"

"github.com/gorilla/mux"
)

var logging logger.F2SLogger
var logging *slog.Logger

var f2shub *hub.F2SHub

Expand Down
2 changes: 1 addition & 1 deletion f2soperator/operation/apiserver/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func getPrometheusMetric(w http.ResponseWriter, r *http.Request) {

result, err := prometheus.ReadPrometheusMetric(f2shub.F2SConfiguration, query)
if err != nil {
logging.Error(fmt.Errorf("could not read prometheus metric: %s", err))
logging.Error(fmt.Sprintf("could not read prometheus metric: %s", err))
json.NewEncoder(w).Encode(Status{Status: fmt.Sprintf("could not read prometheus metric %s", err)})
return
}
Expand Down
10 changes: 5 additions & 5 deletions f2soperator/operation/dispatcher/handlerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func handleRequest(req *queue.F2SRequest, result *chan queue.F2SRequestResult) {
logging.Debug(fmt.Sprintf("[%s] search function target for endpoint: %s", req.UID, req.Path))
functionTarget, err := f2shub.F2SDispatcherHub.GetDispatcherFunctionByEndpoint(req.Path)
if err != nil {
logging.Error(fmt.Errorf("[%s] cannot serve request. function target not found for endpoint %s", req.UID, req.Path))
logging.Error(err)
logging.Error(fmt.Sprintf("[%s] cannot serve request. function target not found for endpoint %s", req.UID, req.Path))
logging.Error(fmt.Sprintf("%s", err))
}
logging.Debug(fmt.Sprintf("[%s] function target is: %s", req.UID, functionTarget.Function.Name))

Expand Down Expand Up @@ -110,7 +110,7 @@ func handleRequest(req *queue.F2SRequest, result *chan queue.F2SRequestResult) {
if len(functionTarget.ServingPods) == 0 {
err := waitForTargetPod(functionTarget)
if err != nil {
logging.Error(fmt.Errorf("[%s] aborting function '%s'. scale from 0 failed: %s", req.UID, functionTarget.Function.Name, err.Error()))
logging.Error(fmt.Sprintf("[%s] aborting function '%s'. scale from 0 failed: %s", req.UID, functionTarget.Function.Name, err.Error()))
// send result to channel
requestResult.Details = fmt.Sprintf("[%s] aborting function '%s'. scale from 0 failed: %s", req.UID, functionTarget.Function.Name, err.Error())
requestResult.Success = false
Expand All @@ -122,7 +122,7 @@ func handleRequest(req *queue.F2SRequest, result *chan queue.F2SRequestResult) {
// get the pod that will actually serve the request
pod, err := functionTarget.ServeRequest(req)
if err != nil {
logging.Error(fmt.Errorf("[%s] cannot serve request because cannot determine which pod should serve the request: %s", req.UID, err.Error()))
logging.Error(fmt.Sprintf("[%s] cannot serve request because cannot determine which pod should serve the request: %s", req.UID, err.Error()))
requestResult.Details = fmt.Sprintf("[%s] aborting function '%s' invocation because target cannot serve request: %s", req.UID, functionTarget.Function.Name, err.Error())
requestResult.Success = false
*result <- requestResult
Expand Down Expand Up @@ -166,7 +166,7 @@ func handleRequest(req *queue.F2SRequest, result *chan queue.F2SRequestResult) {
}

if requestErr != nil {
logging.Error(err)
logging.Error(fmt.Sprintf("%s", err))
// send result to channel
requestResult.Details = fmt.Sprintf("[%s] error on function http invocation: %s", req.UID, requestErr.Error())
requestResult.Success = false
Expand Down
22 changes: 11 additions & 11 deletions f2soperator/operation/dispatcher/httpget.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func httpGet(url string, result *queue.F2SRequestResult) error {
response, err := client.Get(url)
if err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
logging.Error(fmt.Errorf("[%s] http_timeout: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] http_timeout: %s", result.Request.UID, err))
return fmt.Errorf("http_timeout: %s", err)
} else {
logging.Error(fmt.Errorf("[%s] error during httpGet function Call: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] error during httpGet function Call: %s", result.Request.UID, err))
return err
}

Expand Down Expand Up @@ -64,10 +64,10 @@ func httpPost(url, data string, result *queue.F2SRequestResult) error {
response, err := client.Post(url, contentType, body)
if err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
logging.Error(fmt.Errorf("http_timeout: %s", err))
logging.Error(fmt.Sprintf("http_timeout: %s", err))
return fmt.Errorf("http_timeout: %s", err)
} else {
logging.Error(fmt.Errorf("[%s] error during httpPost function Call: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] error during httpPost function Call: %s", result.Request.UID, err))
return err
}
}
Expand All @@ -93,7 +93,7 @@ func httpPut(url, data string, result *queue.F2SRequestResult) error {
// Create a PUT request using http.NewRequest
req, err := http.NewRequest("PUT", url, body)
if err != nil {
logging.Error(fmt.Errorf("[%s] error creating PUT request: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] error creating PUT request: %s", result.Request.UID, err))
return err
}

Expand All @@ -109,10 +109,10 @@ func httpPut(url, data string, result *queue.F2SRequestResult) error {
response, err := client.Do(req)
if err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
logging.Error(fmt.Errorf("[%s] http_timeout: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] http_timeout: %s", result.Request.UID, err))
return fmt.Errorf("http_timeout: %s", err)
} else {
logging.Error(fmt.Errorf("[%s] error during httpPut function Call: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] error during httpPut function Call: %s", result.Request.UID, err))
return err
}
}
Expand All @@ -135,18 +135,18 @@ func httpDelete(url string, result *queue.F2SRequestResult) error {
// Create a DELETE request using http.NewRequest
req, err := http.NewRequest("DELETE", url, nil)
if err != nil {
logging.Error(fmt.Errorf("[%s] error creating DELETE request: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] error creating DELETE request: %s", result.Request.UID, err))
return err
}

// Send the request using the client
response, err := client.Do(req)
if err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
logging.Error(fmt.Errorf("[%s] http_timeout: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] http_timeout: %s", result.Request.UID, err))
return fmt.Errorf("http_timeout: %s", err)
} else {
logging.Error(fmt.Errorf("[%s] error during httpDelete function Call: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] error during httpDelete function Call: %s", result.Request.UID, err))
return err
}
}
Expand All @@ -165,7 +165,7 @@ func fetchResponse(response *http.Response, result *queue.F2SRequestResult) (err
// Read response body
responseBody, err := io.ReadAll(response.Body)
if err != nil {
logging.Error(fmt.Errorf("[%s] [fetchResponse] error when reading httpPost function call result body: %s", result.Request.UID, err))
logging.Error(fmt.Sprintf("[%s] [fetchResponse] error when reading httpPost function call result body: %s", result.Request.UID, err))
return err
}

Expand Down
5 changes: 3 additions & 2 deletions f2soperator/operation/dispatcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"butschi84/f2s/hub"
"butschi84/f2s/services/logger"
"fmt"
"log/slog"
"time"
)

var logging logger.F2SLogger
var logging *slog.Logger
var f2shub *hub.F2SHub

func Initialize(h *hub.F2SHub) {
Expand Down Expand Up @@ -44,7 +45,7 @@ func GetCurrentDispatcherData() string {

// get function target
target, err := f2shub.F2SDispatcherHub.GetDispatcherFunctionByName(function.Name)
logging.Error(err)
logging.Error(fmt.Sprintf("%s", err))

output += fmt.Sprintf("Endpoints: %d", len(target.ServingPods))
for _, endpoint := range target.ServingPods {
Expand Down
2 changes: 1 addition & 1 deletion f2soperator/operation/kafka/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func invokeFunction(functionUid string, requestBody string) (result string, err
// get this function from config
f2sfunction, errGetFunction := f2shub.F2SConfiguration.GetFunctionByUID(functionUid)
if errGetFunction != nil {
logging.Error(fmt.Errorf("error getting function %s from running config. abort function invocation", functionUid))
logging.Error(fmt.Sprintf("error getting function %s from running config. abort function invocation", functionUid))
return
}

Expand Down
3 changes: 2 additions & 1 deletion f2soperator/operation/kafka/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"butschi84/f2s/hub"
"butschi84/f2s/services/logger"
"fmt"
"log/slog"
"time"
)

var logging logger.F2SLogger
var logging *slog.Logger
var f2shub *hub.F2SHub

func init() {
Expand Down
2 changes: 1 addition & 1 deletion f2soperator/operation/metrics/eventhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func handleEvent(event eventmanager.Event) {
result := event.Data.(queue.F2SRequestResult)
functionTarget, err := f2shub.F2SDispatcherHub.GetDispatcherFunctionByEndpoint(result.Request.Path)
if err != nil {
logging.Error(fmt.Errorf("[%s] cannot calculate metrics for request because: %s", result.Request.UID, err.Error()))
logging.Error(fmt.Sprintf("[%s] cannot calculate metrics for request because: %s", result.Request.UID, err.Error()))
}

if result.Success {
Expand Down
3 changes: 2 additions & 1 deletion f2soperator/operation/metrics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package metrics
import (
"butschi84/f2s/hub"
"butschi84/f2s/services/logger"
"log/slog"
"net/http"

"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

var logging logger.F2SLogger
var logging *slog.Logger

// pointer to F2SConfiguration
var f2shub hub.F2SHub
Expand Down
Loading

0 comments on commit f1dd04a

Please sign in to comment.