From 3bf406ebc3b97cbc805930ad90cce78f82595090 Mon Sep 17 00:00:00 2001 From: abdollahis2 Date: Tue, 1 Oct 2024 15:17:59 -0400 Subject: [PATCH] max pk req addition & otel optimzation --- tr_sys/tr_ars/utils.py | 4 +++- tr_sys/tr_sys/celery.py | 3 +++ tr_sys/tr_sys/otel_config.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tr_sys/tr_ars/utils.py b/tr_sys/tr_ars/utils.py index f8b2f341..6c35b160 100644 --- a/tr_sys/tr_ars/utils.py +++ b/tr_sys/tr_ars/utils.py @@ -977,7 +977,9 @@ def scrub_null_attributes(data): def appraise(mesg, data, agent_name,retry_counter=0): headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} - json_data = json.dumps(data) + CopyForMax = copy.deepcopy(data) + CopyForMax['pk']=str(mesg.id) + json_data = json.dumps(CopyForMax) logging.info('sending data for agent: %s to APPRAISER URL: %s' % (agent_name, APPRAISER_URL)) with tracer.start_as_current_span("get_appraisal") as span: try: diff --git a/tr_sys/tr_sys/celery.py b/tr_sys/tr_sys/celery.py index 019bff4e..ddb665a3 100644 --- a/tr_sys/tr_sys/celery.py +++ b/tr_sys/tr_sys/celery.py @@ -22,6 +22,9 @@ # should have a `CELERY_` prefix. app.config_from_object('django.conf:settings', namespace='CELERY') +# Configure broker retry on startup +app.conf.broker_connection_retry_on_startup = True + # Load task modules from all registered Django app configs. app.autodiscover_tasks() diff --git a/tr_sys/tr_sys/otel_config.py b/tr_sys/tr_sys/otel_config.py index f83974b0..3c23f74e 100644 --- a/tr_sys/tr_sys/otel_config.py +++ b/tr_sys/tr_sys/otel_config.py @@ -3,7 +3,7 @@ from opentelemetry import trace from opentelemetry.sdk.resources import SERVICE_NAME as telemetery_service_name_key, Resource from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter +from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter, SimpleSpanProcessor from opentelemetry.instrumentation.django import DjangoInstrumentor from opentelemetry.exporter.jaeger.thrift import JaegerExporter from opentelemetry.instrumentation.celery import CeleryInstrumentor @@ -32,7 +32,7 @@ def configure_opentelemetry(): agent_port=jaeger_port, ) - span_processor = BatchSpanProcessor(jaeger_exporter) + span_processor = SimpleSpanProcessor(jaeger_exporter) tracer_provider.add_span_processor(span_processor) # Optional: Console exporter for debugging