Skip to content

Commit

Permalink
[DOP-22268] - move spark logs to json format
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-lixakov committed Dec 16, 2024
1 parent 3a325f9 commit 14fd433
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion syncmaster/settings/log/json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ filters:
(): asgi_correlation_id.CorrelationIdFilter
uuid_length: 32
default_value: '-'
celery_tracing:
(): asgi_correlation_id.CeleryTracingIdsFilter
uuid_length: 32

formatters:
json:
Expand All @@ -26,7 +29,7 @@ handlers:
celery:
class: logging.StreamHandler
formatter: json
filters: [correlation_id]
filters: [correlation_id, celery_tracing]
stream: ext://sys.stdout

loggers:
Expand Down
9 changes: 6 additions & 3 deletions syncmaster/worker/transfer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SPDX-FileCopyrightText: 2023-2024 MTS PJSC
# SPDX-License-Identifier: Apache-2.0
import logging
from datetime import datetime, timezone

import onetl
from asgi_correlation_id import correlation_id
from asgi_correlation_id.extensions.celery import (
load_celery_current_and_parent_ids,
load_correlation_ids,
)
from celery import Celery
from celery.signals import after_setup_logger, before_task_publish, task_prerun
from celery.utils.log import get_task_logger
Expand All @@ -20,14 +22,15 @@
from syncmaster.worker.settings import WorkerAppSettings

logger = get_task_logger(__name__)
load_correlation_ids()
load_celery_current_and_parent_ids()

WORKER_SETTINGS = WorkerAppSettings()
CORRELATION_CELERY_HEADER_ID = WORKER_SETTINGS.worker.CORRELATION_CELERY_HEADER_ID


@celery.task(name="run_transfer_task", bind=True, track_started=True)
def run_transfer_task(self: Celery, run_id: int) -> None:
onetl.log.setup_logging(level=logging.INFO)
with Session(self.engine) as session:
run_transfer(
session=session,
Expand Down

0 comments on commit 14fd433

Please sign in to comment.