Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix execution time #33

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Describe your changes

## Issue ticket number and link

## Checklist before requesting a review

- [ ] I have resolved any merge conflicts
- [ ] I have run tests locally and they pass
- [ ] I have linted and auto-formatted the code
- [ ] If there is new or changed functionality, I have added/updated the tests
- [ ] If there is new or changed functionality, I have added/updated the documentation
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ if err != nil {

You will then have a `func(next http.Handler) http.Handler`, `firetailMiddleware`, which you can use to wrap a `http.Handler` just the same as with the middleware from [`net/http/middleware`](https://pkg.go.dev/go.ntrrg.dev/ntgo/net/http/middleware). This should also be suitable for [Chi](https://go-chi.io/#/pages/middleware).

See the [Go reference for the Options struct](https://pkg.go.dev/github.com/FireTail-io/[email protected]/middlewares/http#Options) for documentation regarding the available options. For example, if you are using `us.firetail.app` you will need to set the `LogsApiUrl` to `https://api.logging.us-east-2.prod.firetail.app/logs/bulk`.



## Tests
Expand Down
2 changes: 1 addition & 1 deletion middlewares/http/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func GetMiddleware(options *Options) (func(next http.Handler) http.Handler, erro
chainResponseWriter := httptest.NewRecorder()
startTime := time.Now()
next.ServeHTTP(chainResponseWriter, r)
logEntry.ExecutionTime = float64(time.Since(startTime).Milliseconds())
logEntry.ExecutionTime = float64(time.Since(startTime)) / 1000000.0

// If it has been enabled, and we were able to determine the route and path params, validate the response against the openapi spec
if options.EnableResponseValidation && route != nil && pathParams != nil {
Expand Down
2 changes: 2 additions & 0 deletions middlewares/http/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Options struct {

// LogsApiUrl is the URL of the Firetail logging API endpoint to which logs will be sent by the default batch callback. This value
// should typically be loaded in from an environment variable. If unset, the default value is the Firetail SaaS' bulk logs endpoint
// in the default region (firetail.app). If another region is being used, this option will need to be configured appropriately. For
// example, for us.firetail.app LogsApiUrl should normally be https://api.logging.us-east-2.prod.firetail.app/logs/bulk
LogsApiUrl string

// LogBatchCallback is an optional callback which is provided with a batch of Firetail log entries ready to be sent to Firetail. The
Expand Down
Loading