mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 14:28:59 +08:00
changes added for live tail api
This commit is contained in:
parent
8e4fbbe770
commit
b5c8764605
@ -2884,7 +2884,7 @@ func (r *ClickHouseReader) GetLogs(ctx context.Context, params *model.LogsFilter
|
||||
}
|
||||
|
||||
func (r *ClickHouseReader) TailLogs(ctx context.Context, client *model.LogsTailClient) {
|
||||
response := &[]model.GetLogsResponse{}
|
||||
|
||||
fields, apiErr := r.GetLogFields(ctx)
|
||||
if apiErr != nil {
|
||||
client.Error <- apiErr.Err
|
||||
@ -2934,8 +2934,9 @@ func (r *ClickHouseReader) TailLogs(ctx context.Context, client *model.LogsTailC
|
||||
if idStart != nil {
|
||||
tmpQuery += fmt.Sprintf(" and id > '%s'", *idStart)
|
||||
}
|
||||
tmpQuery = fmt.Sprintf("%s order by timestamp asc limit 1000", tmpQuery)
|
||||
tmpQuery = fmt.Sprintf("%s order by timestamp asc, id asc limit 1000", tmpQuery)
|
||||
zap.S().Debug(tmpQuery)
|
||||
response := &[]model.GetLogsResponse{}
|
||||
err := r.db.Select(ctx, response, tmpQuery)
|
||||
if err != nil {
|
||||
zap.S().Debug(err)
|
||||
|
@ -1951,13 +1951,12 @@ func (aH *APIHandler) tailLogs(w http.ResponseWriter, r *http.Request) {
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.Encode(ev)
|
||||
fmt.Fprintf(w, "data: %v\n\n", buf.String())
|
||||
fmt.Printf("data: %v\n", buf.String())
|
||||
flusher.Flush()
|
||||
case <-client.Done:
|
||||
fmt.Println("done!")
|
||||
zap.S().Debug("done!")
|
||||
return
|
||||
case <-client.Error:
|
||||
fmt.Println("error occured!")
|
||||
zap.S().Debug("error occured!")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -166,8 +166,8 @@ func (s *Server) createPublicServer(api *APIHandler) (*http.Server, error) {
|
||||
|
||||
c := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedMethods: []string{"GET", "DELETE", "POST", "PUT"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
AllowedMethods: []string{"GET", "DELETE", "POST", "PUT", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "cache-control"},
|
||||
})
|
||||
|
||||
handler := c.Handler(r)
|
||||
|
Loading…
x
Reference in New Issue
Block a user