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