Move trace and logs UI to Operator Console (#375)
Co-authored-by: Daniel Valdivia <hola@danielvaldivia.com>
This commit is contained in:
@@ -21,6 +21,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -93,3 +95,25 @@ func getLogTime(lt string) string {
|
||||
}
|
||||
return tm.Format(logTimeFormat)
|
||||
}
|
||||
|
||||
// getConsoleLogOptionsFromReq return tenant name from url
|
||||
// path come as : `/console/<namespace>/<tenantName>`
|
||||
func getConsoleLogOptionsFromReq(req *http.Request) (namespace, tenant string) {
|
||||
re := regexp.MustCompile(`(/console/)(.*?)/(.*?)(\?.*?$|$)`)
|
||||
matches := re.FindAllSubmatch([]byte(req.URL.Path), -1)
|
||||
// len matches is always 4
|
||||
namespace = strings.TrimSpace(string(matches[0][2]))
|
||||
tenant = strings.TrimSpace(string(matches[0][3]))
|
||||
return namespace, tenant
|
||||
}
|
||||
|
||||
// getTraceOptionsFromReq return tenant name from url
|
||||
// path come as : `/trace/<namespace>/<tenantName>`
|
||||
func getTraceOptionsFromReq(req *http.Request) (namespace, tenant string) {
|
||||
re := regexp.MustCompile(`(/trace/)(.*?)/(.*?)(\?.*?$|$)`)
|
||||
matches := re.FindAllSubmatch([]byte(req.URL.Path), -1)
|
||||
// len matches is always 4
|
||||
namespace = strings.TrimSpace(string(matches[0][2]))
|
||||
tenant = strings.TrimSpace(string(matches[0][3]))
|
||||
return namespace, tenant
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user