Skip to content

Commit

Permalink
Fixing missing floats
Browse files Browse the repository at this point in the history
  • Loading branch information
madflojo committed Nov 23, 2023
1 parent 02a1ab2 commit 8312882
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (srv *Server) Run() error {
"namespace": r.Namespace,
"operation": r.Operation,
"error": r.Err,
"duration": r.EndTime.Sub(r.StartTime).Milliseconds(),
"duration": r.EndTime.Sub(r.StartTime).Milliseconds(),
}).Debugf("Callback returned result after %d milliseconds", r.EndTime.Sub(r.StartTime).Milliseconds())

// Trace logging of callback results
Expand All @@ -344,16 +344,16 @@ func (srv *Server) Run() error {
"operation": r.Operation,
"input": r.Input,
"error": r.Err,
"duration": r.EndTime.Sub(r.StartTime).Milliseconds(),
"duration": r.EndTime.Sub(r.StartTime).Milliseconds(),
}).Tracef("Callback returned result after %d milliseconds with output - %s", r.EndTime.Sub(r.StartTime).Milliseconds(), r.Output)

// Log Callback failures as warnings
if r.Err != nil {
srv.log.WithFields(logrus.Fields{
"namespace": r.Namespace,
"operation": r.Operation,
"duration": r.EndTime.Sub(r.StartTime).Milliseconds(),
}).Warnf("Callback call resulted in error after %d milliseconds - %s", r.EndTime.Sub(r.StartTime).Millimilliseconds(), r.Err)
"duration": r.EndTime.Sub(r.StartTime).Milliseconds(),
}).Warnf("Callback call resulted in error after %d milliseconds - %s", r.EndTime.Sub(r.StartTime).Milliseconds(), r.Err)

Check warning on line 356 in pkg/app/app.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/app.go#L355-L356

Added lines #L355 - L356 were not covered by tests
}
},
})
Expand Down Expand Up @@ -511,10 +511,10 @@ func (srv *Server) Run() error {
srv.log.Tracef("Executing Scheduled Function %s", fname)
_, err := srv.runWASM(fname, "handler", []byte(""))
if err != nil {
srv.stats.Tasks.WithLabelValues(fname).Observe(time.Since(now).Milliseconds())
srv.stats.Tasks.WithLabelValues(fname).Observe(float64(time.Since(now).Milliseconds()))

Check warning on line 514 in pkg/app/app.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/app.go#L514

Added line #L514 was not covered by tests
return err
}
srv.stats.Tasks.WithLabelValues(fname).Observe(time.Since(now).Milliseconds())
srv.stats.Tasks.WithLabelValues(fname).Observe(float64(time.Since(now).Milliseconds()))

Check warning on line 517 in pkg/app/app.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/app.go#L517

Added line #L517 was not covered by tests
return nil
},
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ func (srv *Server) middleware(n httprouter.Handle) httprouter.Handle {
}).Debugf("Request to PProf Address failed, PProf disabled")
w.WriteHeader(http.StatusForbidden)

srv.stats.Srv.WithLabelValues(r.URL.Path).Observe(time.Since(now).Milliseconds())
srv.stats.Srv.WithLabelValues(r.URL.Path).Observe(float64(time.Since(now).Milliseconds()))
return
}

// Call registered handler
n(w, r, ps)
srv.stats.Srv.WithLabelValues(r.URL.Path).Observe(time.Since(now).Milliseconds())
srv.stats.Srv.WithLabelValues(r.URL.Path).Observe(float64(time.Since(now).Milliseconds()))
srv.log.WithFields(logrus.Fields{
"method": r.Method,
"remote-addr": r.RemoteAddr,
Expand Down Expand Up @@ -138,19 +138,19 @@ func (srv *Server) runWASM(module, handler string, rq []byte) ([]byte, error) {
// Fetch Module and run with payload
m, err := srv.engine.Module(module)
if err != nil {
srv.stats.Wasm.WithLabelValues(fmt.Sprintf("%s:%s", module, handler)).Observe(time.Since(now).Milliseconds())
srv.stats.Wasm.WithLabelValues(fmt.Sprintf("%s:%s", module, handler)).Observe(float64(time.Since(now).Milliseconds()))
return []byte(""), fmt.Errorf("unable to load wasi environment - %s", err)
}

// Execute the WASM Handler
rsp, err := m.Run(handler, rq)
if err != nil {
srv.stats.Wasm.WithLabelValues(fmt.Sprintf("%s:%s", module, handler)).Observe(time.Since(now).Milliseconds())
srv.stats.Wasm.WithLabelValues(fmt.Sprintf("%s:%s", module, handler)).Observe(float64(time.Since(now).Milliseconds()))
return rsp, fmt.Errorf("failed to execute wasm module - %s", err)
}

// Return results
srv.stats.Wasm.WithLabelValues(fmt.Sprintf("%s:%s", module, handler)).Observe(time.Since(now).Milliseconds())
srv.stats.Wasm.WithLabelValues(fmt.Sprintf("%s:%s", module, handler)).Observe(float64(time.Since(now).Milliseconds()))
srv.log.WithFields(logrus.Fields{
"module": module,
"handler": handler,
Expand Down

0 comments on commit 8312882

Please sign in to comment.