This is an automated email from the ASF dual-hosted git repository.

bobbai00 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 654842507d feat(agent-service): align log-level env var with other 
services (#4575)
654842507d is described below

commit 654842507d29c6a8a1c95c435361914f7569a7e9
Author: Jiadong Bai <[email protected]>
AuthorDate: Fri May 1 01:02:21 2026 -0700

    feat(agent-service): align log-level env var with other services (#4575)
    
    ### What changes were proposed in this PR?
    
    - Rename the agent-service log-level env var from `LOG_LEVEL` to
    `TEXERA_SERVICE_LOG_LEVEL`, matching every other Texera service. Values
    restricted to `ERROR`/`WARN`/`INFO`/`DEBUG` and lowercased for `pino`.
    - Default `LOG_PRETTY` to `false` (`pino-pretty` is a dev-only dep);
    enable via `.env.example` for local dev.
    - Move `/health` under `${API_PREFIX}` as `/api/healthcheck` so it's
    reachable through the same `/api` gateway prefix as other routes.
    
    ### Any related issues, documentation, discussions?
    
    Closes #4574
    
    ### How was this PR tested?
    
    `bun test` in `agent-service/` — existing health-endpoint test updated
    to the new path passes.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Opus 4.7)
    
    ---------
    
    Co-authored-by: Xinyuan Lin <[email protected]>
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
---
 agent-service/.env.example       |  6 ++++++
 agent-service/src/config/env.ts  |  7 +++++--
 agent-service/src/logger.ts      |  2 +-
 agent-service/src/server.test.ts |  4 ++--
 agent-service/src/server.ts      | 15 +++++++++------
 5 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/agent-service/.env.example b/agent-service/.env.example
index de5753e7e6..605f157ca0 100644
--- a/agent-service/.env.example
+++ b/agent-service/.env.example
@@ -2,6 +2,12 @@
 PORT=3001
 API_PREFIX=/api
 
+# ERROR | WARN | INFO | DEBUG
+TEXERA_SERVICE_LOG_LEVEL=INFO
+
+# Human-readable dev logs via pino-pretty.
+LOG_PRETTY=true
+
 # LLM_API_KEY authenticates this service to the gateway — NOT the
 # upstream provider key (OpenAI / Anthropic / etc.), which is
 # configured inside the gateway. "dummy" works when the gateway
diff --git a/agent-service/src/config/env.ts b/agent-service/src/config/env.ts
index b1e9ffc827..16a25b9be7 100644
--- a/agent-service/src/config/env.ts
+++ b/agent-service/src/config/env.ts
@@ -23,8 +23,11 @@ const EnvSchema = z.object({
   PORT: z.coerce.number().default(3001),
   API_PREFIX: z.string().default("/api"),
   LLM_API_KEY: z.string().default("dummy"),
-  LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace", 
"silent"]).default("info"),
-  LOG_PRETTY: z.coerce.boolean().default(true),
+  TEXERA_SERVICE_LOG_LEVEL: z
+    .enum(["ERROR", "WARN", "INFO", "DEBUG"])
+    .transform(v => v.toLowerCase() as "error" | "warn" | "info" | "debug")
+    .default("INFO"),
+  LOG_PRETTY: z.coerce.boolean().default(false),
 
   TEXERA_DASHBOARD_SERVICE_ENDPOINT: 
z.string().url().default("http://localhost:8080";),
   LLM_ENDPOINT: z.string().url().default("http://localhost:9096";),
diff --git a/agent-service/src/logger.ts b/agent-service/src/logger.ts
index 9d06c10e59..5f1537370f 100644
--- a/agent-service/src/logger.ts
+++ b/agent-service/src/logger.ts
@@ -21,7 +21,7 @@ import pino, { type Logger } from "pino";
 import { env } from "./config/env";
 
 const rootLogger: Logger = pino({
-  level: env.LOG_LEVEL,
+  level: env.TEXERA_SERVICE_LOG_LEVEL,
   base: undefined,
   ...(env.LOG_PRETTY
     ? {
diff --git a/agent-service/src/server.test.ts b/agent-service/src/server.test.ts
index d31352c681..0f618e599c 100644
--- a/agent-service/src/server.test.ts
+++ b/agent-service/src/server.test.ts
@@ -64,9 +64,9 @@ beforeEach(() => {
   _resetAgentStoreForTests();
 });
 
-describe("GET /health", () => {
+describe(`GET ${API}/healthcheck`, () => {
   test("returns 200 with status ok", async () => {
-    const res = await getJson("/health");
+    const res = await getJson(`${API}/healthcheck`);
     expect(res.status).toBe(200);
     const body = await readJson<{ status: string; timestamp: string }>(res);
     expect(body.status).toBe("ok");
diff --git a/agent-service/src/server.ts b/agent-service/src/server.ts
index d515931cc1..a31f9ede11 100644
--- a/agent-service/src/server.ts
+++ b/agent-service/src/server.ts
@@ -477,11 +477,14 @@ function broadcastToAgent(agentId: string, message: 
WsOutgoingMessage): void {
 export function buildApp() {
   return new Elysia()
     .use(cors())
-    .get("/health", () => ({
-      status: "ok",
-      timestamp: new Date().toISOString(),
-    }))
-    .group(env.API_PREFIX, app => app.use(agentsRouter))
+    .group(env.API_PREFIX, app =>
+      app
+        .get("/healthcheck", () => ({
+          status: "ok",
+          timestamp: new Date().toISOString(),
+        }))
+        .use(agentsRouter)
+    )
     .ws(`${env.API_PREFIX}/agents/:id/react`, {
       open(ws) {
         const agentId = (ws.data as any).params?.id;
@@ -584,7 +587,7 @@ export function buildApp() {
       },
     })
     .onError(({ error, set }) => {
-      // Catch-all for non-router routes such as /health and the websocket 
route.
+      // Catch-all for non-router routes such as /api/healthcheck and the 
websocket route.
       log.error({ err: error }, "request error");
       set.status = 500;
       return { error: error instanceof Error ? error.message : String(error) };

Reply via email to