π OpenHands: AI-Driven Development
fix: suppress alembic INFO logs before import to prevent Datadog misclassification (#12691)
Graham Neubig5f958ab60d56
diff --git a/enterprise/migrations/env.py b/enterprise/migrations/env.pyindex 73a62157c1..e3915fbf65 100644--- a/enterprise/migrations/env.py+++ b/enterprise/migrations/env.py@@ -1,10 +1,15 @@+import loggingimport osfrom logging.config import fileConfig-from alembic import context-from google.cloud.sql.connector import Connector-from sqlalchemy import create_engine-from storage.base import Base+# Suppress alembic.runtime.plugins INFO logs during import to prevent non-JSON logs in production+# These plugin setup messages would otherwise appear before logging is configured+logging.getLogger('alembic.runtime.plugins').setLevel(logging.WARNING)++from alembic import context # noqa: E402+from google.cloud.sql.connector import Connector # noqa: E402+from sqlalchemy import create_engine # noqa: E402+from storage.base import Base # noqa: E402target_metadata = Base.metadatadiff --git a/openhands/app_server/app_lifespan/alembic/env.py b/openhands/app_server/app_lifespan/alembic/env.pyindex c423c2cb4f..985550d15a 100644--- a/openhands/app_server/app_lifespan/alembic/env.py+++ b/openhands/app_server/app_lifespan/alembic/env.py@@ -1,8 +1,14 @@+import logging+import osimport sysfrom logging.config import fileConfigfrom pathlib import Path-from alembic import context+# Suppress alembic.runtime.plugins INFO logs during import to prevent non-JSON logs in production+# These plugin setup messages would otherwise appear before logging is configured+logging.getLogger('alembic.runtime.plugins').setLevel(logging.WARNING)++from alembic import context # noqa: E402# Add the project root to the Python path so we can import OpenHands modules# From alembic/env.py, we need to go up 5 levels to reach the OpenHands project root@@ -34,14 +40,10 @@ config = context.config# Interpret the config file for Python logging.# This line sets up loggers basically.if config.config_file_name is not None:- import os-if os.path.exists(config.config_file_name):fileConfig(config.config_file_name)else:# Use basic logging configuration if config file doesn't exist- import logging-logging.basicConfig(level=logging.INFO)# add your model's MetaData object here