Skip to content

Commit 045c76a

Browse files
authored
feat(ingest): reporting logging tweaks (#9835)
1 parent 0328f85 commit 045c76a

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

metadata-ingestion/src/datahub/cli/check_cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,7 @@ def sql_lineage(
218218
)
219219

220220
logger.debug("Sql parsing debug info: %s", lineage.debug_info)
221+
if lineage.debug_info.error:
222+
logger.debug("Sql parsing error details", exc_info=lineage.debug_info.error)
221223

222224
click.echo(lineage.json(indent=4))

metadata-ingestion/src/datahub/ingestion/api/source.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import logging
23
from abc import ABCMeta, abstractmethod
34
from collections import defaultdict
45
from dataclasses import dataclass, field
@@ -40,6 +41,8 @@
4041
from datahub.utilities.lossy_collections import LossyDict, LossyList
4142
from datahub.utilities.type_annotations import get_class_from_annotation
4243

44+
logger = logging.getLogger(__name__)
45+
4346

4447
class SourceCapability(Enum):
4548
PLATFORM_INSTANCE = "Platform Instance"
@@ -99,11 +102,19 @@ def report_warning(self, key: str, reason: str) -> None:
99102
warnings.append(reason)
100103
self.warnings[key] = warnings
101104

105+
def warning(self, key: str, reason: str) -> None:
106+
self.report_warning(key, reason)
107+
logger.warning(f"{key} => {reason}", stacklevel=2)
108+
102109
def report_failure(self, key: str, reason: str) -> None:
103110
failures = self.failures.get(key, LossyList())
104111
failures.append(reason)
105112
self.failures[key] = failures
106113

114+
def failure(self, key: str, reason: str) -> None:
115+
self.report_failure(key, reason)
116+
logger.error(f"{key} => {reason}", stacklevel=2)
117+
107118
def __post_init__(self) -> None:
108119
self.start_time = datetime.datetime.now()
109120
self.running_time: datetime.timedelta = datetime.timedelta(seconds=0)

metadata-ingestion/src/datahub/ingestion/source_report/ingestion_stage.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def report_ingestion_stage_start(self, stage: str) -> None:
3030
if self._timer:
3131
elapsed = round(self._timer.elapsed_seconds(), 2)
3232
logger.info(
33-
f"Time spent in stage <{self.ingestion_stage}>: {elapsed} seconds"
33+
f"Time spent in stage <{self.ingestion_stage}>: {elapsed} seconds",
34+
stacklevel=2,
3435
)
3536
if self.ingestion_stage:
3637
self.ingestion_stage_durations[self.ingestion_stage] = elapsed

metadata-ingestion/src/datahub/utilities/logging_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from datahub.utilities.tee_io import TeeIO
2424

2525
BASE_LOGGING_FORMAT = (
26-
"[%(asctime)s] %(levelname)-8s {%(name)s:%(lineno)d} - %(message)s"
26+
"[%(asctime)s] %(levelname)-8s {%(filename)s:%(lineno)d} - %(message)s"
2727
)
2828
DATAHUB_PACKAGES = [
2929
"datahub",

0 commit comments

Comments
 (0)