diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..b2ad03f --- /dev/null +++ b/.github/pull_request_template.md @@ -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 diff --git a/README.md b/README.md index 30ccf94..00edd2e 100644 --- a/README.md +++ b/README.md @@ -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/firetail-go-lib@v0.0.0/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 diff --git a/middlewares/http/middleware.go b/middlewares/http/middleware.go index 6260340..faee073 100644 --- a/middlewares/http/middleware.go +++ b/middlewares/http/middleware.go @@ -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 { diff --git a/middlewares/http/options.go b/middlewares/http/options.go index 0b26396..e183300 100644 --- a/middlewares/http/options.go +++ b/middlewares/http/options.go @@ -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