mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-09 02:09:47 -06:00
* introduce tenant workflow completed metric * expose tenant prom metrics via handler * fix workflow and worker id in metrics * correctly add workflow metrics from workflow controller * use olap DB to gather information for workflow completion * fix prom metrics endpoint for tenant * workflow name from external id * simplify tenant registry based metrics * add docs for prometheus metrics * fix docs lint * run prettier fix * WIP metrics work * use federate prom server URL to proxy metrics * implement workflow duration histogram metric * separate prom stack docker compose * fix duration metrics calls * move scheduler metrics to prom tenant specific file * update docs for prom metrics * fix lint * use proper indices to query for durations * reorg tenant metrics * fix lint for doc * update docs with promql examples and casing around prom metrics enabled * update prom server url * fix lint * enabled prom metrics for v1 only from controller
40 lines
977 B
Go
40 lines
977 B
Go
package staticfileserver
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/go-chi/chi"
|
|
"github.com/go-chi/chi/middleware"
|
|
)
|
|
|
|
func NewStaticFileServer(staticFilePath string) *chi.Mux {
|
|
r := chi.NewRouter()
|
|
|
|
fs := http.FileServer(http.Dir(staticFilePath))
|
|
|
|
r.Use(middleware.Logger)
|
|
|
|
r.Get("/*", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("X-Frame-Options", "DENY")
|
|
|
|
if _, err := os.Stat(staticFilePath + r.RequestURI); os.IsNotExist(err) {
|
|
w.Header().Set("Cache-Control", "no-cache")
|
|
|
|
http.StripPrefix(r.URL.Path, fs).ServeHTTP(w, r)
|
|
} else {
|
|
// Set static files involving html, js, or empty cache to "no-cache", which means they must be validated
|
|
// for changes before the browser uses the cache
|
|
if base := path.Base(r.URL.Path); strings.Contains(base, "html") || strings.Contains(base, "js") || base == "." || base == "/" {
|
|
w.Header().Set("Cache-Control", "no-cache")
|
|
}
|
|
|
|
fs.ServeHTTP(w, r)
|
|
}
|
|
})
|
|
|
|
return r
|
|
}
|