1.4 KiB
1.4 KiB
Implement Missing Features (Phase 4 & 5)
I will implement Advanced Metrics for Edge Functions and pgvector Support for the Data API.
1. pgvector Support (data_api)
Goal: Ensure vector columns are returned as native JSON arrays instead of strings in the Data API.
- Modification: Update
rows_to_jsonindata_api/src/handlers.rs. - Logic:
- Check if column type is "VECTOR".
- If yes, parse the string representation (e.g.,
"[1.0,2.0,3.0]") into aserde_json::Value::Array. - This provides seamless integration for clients using embeddings.
2. Advanced Metrics (functions)
Goal: Capture and log detailed execution metrics for Edge Functions.
- Modification: Update
functions/src/runtime.rsandfunctions/src/handlers.rs. - Metrics:
execution_time_ms: Duration of the WASM execution.memory_usage_bytes: Approximate memory usage (if obtainable) or payload size.
- Implementation:
- Use
tracingwith structured fields (e.g.,tracing::info!(target: "function_metrics", duration_ms = 123, ...)). - This allows the existing Logs Viewer (Loki-based) to aggregate and visualize these metrics in the future.
- Use
Execution Steps
- Refactor Data API: Modify
rows_to_jsonto handleVECTORtype. - Instrument Functions: Add timing and logging to
WasmRuntime::execute. - Verify: Ensure compilation and correct logic.