From 4ceca1a2b8dad40af0a59f894289934a0eb14432 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:29:15 +0000 Subject: [PATCH 1/3] Initial plan From 0be566b10ea3324dcffbd66b0ace75afddf2af3d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:54:08 +0000 Subject: [PATCH 2/3] Fix failing tests: upgrade honcho, modernize structlog and elasticsearch APIs Co-authored-by: fr4nc1sc0-r4m0n <215478872+fr4nc1sc0-r4m0n@users.noreply.github.com> --- opbeans/__init__.py | 1 - opbeans/settings.py | 11 +++-------- opbeans/tasks.py | 7 +++---- requirements.txt | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/opbeans/__init__.py b/opbeans/__init__.py index a450832..cf2e85f 100644 --- a/opbeans/__init__.py +++ b/opbeans/__init__.py @@ -1,2 +1 @@ from .celery import app as celery_app -default_app_config = 'opbeans.apps.OpbeansAppConfig' diff --git a/opbeans/settings.py b/opbeans/settings.py index ffd4f7c..47a16b0 100644 --- a/opbeans/settings.py +++ b/opbeans/settings.py @@ -110,8 +110,6 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True @@ -183,10 +181,6 @@ 'class': 'logging.StreamHandler', 'formatter': "json" if "ENABLE_JSON_LOGGING" in os.environ else "console", }, - 'elasticapm': { - 'class': 'elasticapm.contrib.django.handlers.LoggingHandler', - 'level': 'WARNING', - }, }, 'loggers': { 'django': { @@ -194,7 +188,7 @@ 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, 'opbeans': { - 'handlers': ['console', 'elasticapm'], + 'handlers': ['console'], 'level': 'INFO', }, 'elasticapm': { @@ -205,6 +199,7 @@ } structlog_processors=[ + structlog.contextvars.merge_contextvars, structlog.stdlib.filter_by_level, structlog.processors.TimeStamper(fmt="iso", key="@timestamp"), structlog.stdlib.add_logger_name, @@ -227,7 +222,7 @@ structlog.configure( processors=structlog_processors, - context_class=structlog.threadlocal.wrap_dict(dict), + context_class=dict, logger_factory=structlog.stdlib.LoggerFactory(), wrapper_class=structlog.stdlib.BoundLogger, cache_logger_on_first_use=True, diff --git a/opbeans/tasks.py b/opbeans/tasks.py index 90fb906..762eb65 100644 --- a/opbeans/tasks.py +++ b/opbeans/tasks.py @@ -4,7 +4,7 @@ from django.db import models as m import elasticapm -from elasticsearch import TransportError +from elasticsearch import NotFoundError from elasticsearch.helpers import bulk from elasticsearch_dsl import Search from elasticsearch_dsl.connections import connections @@ -36,9 +36,8 @@ def sync_orders(): try: r = Search(index='py-orders').sort('-_id')[0].execute() highest_id = int(r.hits[0].meta.id) - except TransportError as e: - if e.status_code == 404: - highest_id = 0 + except NotFoundError: + highest_id = 0 order_docs = [] for order in models.Order.objects.filter(id__gt=highest_id).prefetch_related('customer'): order_docs.append(documents.Order(**order.to_search()).to_dict(include_meta=True)) diff --git a/requirements.txt b/requirements.txt index 84e552c..0bafd12 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ elasticsearch==8.17.2 elasticsearch-dsl==8.17.1 elastic-transport==8.17.1 gunicorn==23.0.0 -honcho==1.1.0 +honcho==2.0.0 kombu==5.5.2 psycopg2-binary==2.9.10 pytz From 6636788b1959e4e4af33d9ad1fd63e17605becb8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:57:12 +0000 Subject: [PATCH 3/3] Restore elasticapm LoggingHandler to preserve original logging behavior Co-authored-by: fr4nc1sc0-r4m0n <215478872+fr4nc1sc0-r4m0n@users.noreply.github.com> --- opbeans/settings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opbeans/settings.py b/opbeans/settings.py index 47a16b0..37d8c20 100644 --- a/opbeans/settings.py +++ b/opbeans/settings.py @@ -181,6 +181,10 @@ 'class': 'logging.StreamHandler', 'formatter': "json" if "ENABLE_JSON_LOGGING" in os.environ else "console", }, + 'elasticapm': { + 'class': 'elasticapm.contrib.django.handlers.LoggingHandler', + 'level': 'WARNING', + }, }, 'loggers': { 'django': { @@ -188,7 +192,7 @@ 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, 'opbeans': { - 'handlers': ['console'], + 'handlers': ['console', 'elasticapm'], 'level': 'INFO', }, 'elasticapm': {