Feat: add telemetry
This commit is contained in:
8
main.go
8
main.go
@ -6,6 +6,7 @@ import (
|
||||
"gralias/crons"
|
||||
"gralias/handlers"
|
||||
"gralias/repos"
|
||||
"gralias/telemetry"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -56,8 +57,11 @@ func getContentType(path string) string {
|
||||
|
||||
func ListenToRequests(port string) *http.Server {
|
||||
mux := http.NewServeMux()
|
||||
var handler http.Handler = mux
|
||||
handler = handlers.LogRequests(handlers.GetSession(handler))
|
||||
handler = telemetry.OtelMiddleware(handler)
|
||||
server := &http.Server{
|
||||
Handler: handlers.LogRequests(handlers.GetSession(mux)),
|
||||
Handler: handler,
|
||||
Addr: ":" + port,
|
||||
// ReadTimeout: time.Second * 5, // does this timeout conflict with sse connection?
|
||||
WriteTimeout: 0, // sse streaming
|
||||
@ -96,6 +100,8 @@ func ListenToRequests(port string) *http.Server {
|
||||
}
|
||||
|
||||
func main() {
|
||||
shutdown := telemetry.InitTracer()
|
||||
defer shutdown()
|
||||
// Setup graceful shutdown
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
|
||||
|
Reference in New Issue
Block a user