Duansg opened a new pull request, #4231:
URL: https://github.com/apache/hertzbeat/pull/4231

   ## What's changed?
   
   Previously `GreptimeSignalInitializer` only created the `hzb_traces` table 
explicitly at startup, while the `hertzbeat_logs` table relied on GreptimeDB's 
lazy auto-creation: it is only created when the first log entry is ingested 
through the `hertzbeat_otlp_log_v1` pipeline.
   
   On a fresh deployment where no log has been ingested yet, the log query 
endpoints (`/api/logs/list`, `/api/logs/stats/*`) hit a non-existent 
`hertzbeat_logs` table.
   
   This PR pre-creates the table at startup so the log schema is deterministic 
and queryable from the very beginning:
   
   - Add `greptime/tables/hertzbeat_logs.sql`
   - Execute the schema in `GreptimeSignalInitializer#initialize()` after the 
trace schema and before uploading the log pipeline.
   - `CREATE TABLE IF NOT EXISTS` keeps existing deployments (table already 
auto-created by the pipeline) fully unaffected.
   - Extend `GreptimeSignalInitializerTest` to verify the new step in the 
initialization order.
   
   
   ## Checklist
   
   - [x]  I have read the [Contributing 
Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide)
   - [ ]  I have written the necessary doc or comment.
   - [x]  I have added the necessary unit tests and all cases have passed.
   
   ## Add or update API
   
   - [ ] I have added the necessary [e2e 
tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have 
passed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to