Skip to content

Commit ac5d348

Browse files
chore: enable diagnostics by default for pinned branch
Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
1 parent 475fca6 commit ac5d348

2 files changed

Lines changed: 7 additions & 40 deletions

File tree

airbyte_cdk/entrypoint.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
VALID_URL_SCHEMES = ["https"]
5454
CLOUD_DEPLOYMENT_MODE = "cloud"
5555
_HAS_LOGGED_FOR_SERIALIZATION_ERROR = False
56-
_DEADLOCK_DIAGNOSTICS_ENV = "AIRBYTE_CDK_DEADLOCK_DIAGNOSTICS"
5756

5857

5958
class _DeadlockDiagnostics:
@@ -534,13 +533,8 @@ def _emit_queued_messages(self, source: Source) -> Iterable[AirbyteMessage]:
534533
def launch(source: Source, args: List[str]) -> None:
535534
source_entrypoint = AirbyteEntrypoint(source)
536535
parsed_args = source_entrypoint.parse_args(args)
537-
diagnostics = (
538-
_DeadlockDiagnostics()
539-
if os.environ.get(_DEADLOCK_DIAGNOSTICS_ENV, "").lower() == "true"
540-
else None
541-
)
542-
if diagnostics:
543-
diagnostics.start()
536+
diagnostics = _DeadlockDiagnostics()
537+
diagnostics.start()
544538

545539
# temporarily removes the PrintBuffer because we're seeing weird print behavior for concurrent syncs
546540
# Refer to: https://github.com/airbytehq/oncall/issues/6235
@@ -550,18 +544,14 @@ def launch(source: Source, args: List[str]) -> None:
550544
# simply printing is creating issues for concurrent CDK as Python uses different two instructions to print: one for the message and
551545
# the other for the break line. Adding `\n` to the message ensure that both are printed at the same time
552546
data = f"{message}\n"
553-
if diagnostics:
554-
diagnostics.mark_print_started()
547+
diagnostics.mark_print_started()
555548
try:
556549
print(data, end="")
557550
finally:
558-
if diagnostics:
559-
diagnostics.mark_print_finished()
560-
if diagnostics:
561-
diagnostics.record_message(data)
551+
diagnostics.mark_print_finished()
552+
diagnostics.record_message(data)
562553
finally:
563-
if diagnostics:
564-
diagnostics.stop()
554+
diagnostics.stop()
565555

566556

567557
def _init_internal_request_filter() -> None:

unit_tests/test_entrypoint.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,9 @@ def test_deadlock_diagnostics_heartbeat_reports_queue_stats():
994994
assert "queue_size=1 queue_full=True" in emitted[0].decode()
995995

996996

997-
def test_launch_starts_deadlock_diagnostics_when_enabled(mocker):
997+
def test_launch_starts_deadlock_diagnostics(mocker):
998998
diagnostics = MagicMock()
999999
mocker.patch.object(entrypoint_module, "_DeadlockDiagnostics", return_value=diagnostics)
1000-
mocker.patch.dict(os.environ, {entrypoint_module._DEADLOCK_DIAGNOSTICS_ENV: "true"})
10011000
mocker.patch.object(AirbyteEntrypoint, "parse_args", return_value=Namespace(command="spec"))
10021001
mocker.patch.object(
10031002
AirbyteEntrypoint,
@@ -1018,25 +1017,3 @@ def test_launch_starts_deadlock_diagnostics_when_enabled(mocker):
10181017
diagnostics.mark_print_finished.assert_called_once_with()
10191018
diagnostics.record_message.assert_called_once()
10201019
diagnostics.stop.assert_called_once_with()
1021-
1022-
1023-
def test_launch_does_not_start_deadlock_diagnostics_by_default(mocker):
1024-
diagnostics = MagicMock()
1025-
mocker.patch.object(entrypoint_module, "_DeadlockDiagnostics", return_value=diagnostics)
1026-
mocker.patch.dict(os.environ, {}, clear=True)
1027-
mocker.patch.object(AirbyteEntrypoint, "parse_args", return_value=Namespace(command="spec"))
1028-
mocker.patch.object(
1029-
AirbyteEntrypoint,
1030-
"run",
1031-
return_value=iter(
1032-
[
1033-
AirbyteMessage(
1034-
type=Type.SPEC, spec=ConnectorSpecification(connectionSpecification={})
1035-
)
1036-
]
1037-
),
1038-
)
1039-
1040-
entrypoint_module.launch(MockSource(), ["spec"])
1041-
1042-
entrypoint_module._DeadlockDiagnostics.assert_not_called()

0 commit comments

Comments
 (0)