Skip to content

Commit

Permalink
Remove sending of task logs in otel traces (#43943)
Browse files Browse the repository at this point in the history
This was sending task logs from the scheduler has two problems:

1. It blocks the scheduling loop reading remote logs -- a huge performance
   foot-gun for anyone that turns this feature on
2. Sending task logs in a span seems too large, and way too verbose to provide
   any use in a span.
  • Loading branch information
ashb authored Nov 13, 2024
1 parent edb3fe0 commit bb234dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
8 changes: 0 additions & 8 deletions airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1283,14 +1283,6 @@ traces:
type: string
example: ~
default: "False"
otel_task_log_event:
description: |
If True, after the task is complete, the full task log messages will be added as the
span events, chunked by 64k size. defaults to False.
version_added: 2.10.0
type: string
example: ~
default: "False"
secrets:
description: ~
options:
Expand Down
25 changes: 0 additions & 25 deletions airflow/jobs/scheduler_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,31 +799,6 @@ def process_executor_events(

with Trace.start_span_from_taskinstance(ti=ti) as span:
cls._set_span_attrs__process_executor_events(span, state, ti)
if conf.has_option("traces", "otel_task_log_event") and conf.getboolean(
"traces", "otel_task_log_event"
):
from airflow.utils.log.log_reader import TaskLogReader

task_log_reader = TaskLogReader()
if task_log_reader.supports_read:
metadata: dict[str, Any] = {}
logs, metadata = task_log_reader.read_log_chunks(ti, ti.try_number, metadata)
if ti.hostname in dict(logs[0]):
message = str(dict(logs[0])[ti.hostname]).replace("\\n", "\n")
while metadata["end_of_log"] is False:
logs, metadata = task_log_reader.read_log_chunks(
ti, ti.try_number - 1, metadata
)
if ti.hostname in dict(logs[0]):
message = message + str(dict(logs[0])[ti.hostname]).replace("\\n", "\n")
if span.is_recording():
span.add_event(
name="task_log",
attributes={
"message": message,
"metadata": str(metadata),
},
)

# There are two scenarios why the same TI with the same try_number is queued
# after executor is finished with it:
Expand Down
5 changes: 5 additions & 0 deletions newsfragments/43943.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Remove the ``traces`` ``otel_task_log_event`` event config option and feature

This was sending the task logs form the scheduler, and would be a huge
scheduling performance hit (blocking the entire all scheduling while it was
fetching logs to attach to the trace)

0 comments on commit bb234dc

Please sign in to comment.