# 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_json` in `data_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 a `serde_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.rs` and `functions/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 `tracing` with 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. ## Execution Steps 1. **Refactor Data API**: Modify `rows_to_json` to handle `VECTOR` type. 2. **Instrument Functions**: Add timing and logging to `WasmRuntime::execute`. 3. **Verify**: Ensure compilation and correct logic.