Skip to content

Commit 5e4cc41

Browse files
committed
code review feedback
1 parent c776b42 commit 5e4cc41

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,24 @@ class StructuredLogLevel(Enum):
8181
ERROR = logging.ERROR
8282

8383

84-
class StructuredLogType(Enum):
84+
class StructuredLogCategory(Enum):
8585
"""
8686
This is used to categorise the errors mainly based on the biggest impact area
8787
This is to be used to help in self-serve understand the impact of any log entry
8888
More enums to be added as logs are updated to be self-serve
8989
"""
9090

9191
LINEAGE = "LINEAGE"
92+
USAGE = "USAGE"
93+
PROFILING = "PROFILING"
9294

9395

9496
@dataclass
9597
class StructuredLogEntry(Report):
9698
title: Optional[str]
9799
message: str
98100
context: LossyList[str]
99-
log_type: Optional[StructuredLogType] = None
101+
log_category: Optional[StructuredLogCategory] = None
100102

101103

102104
@dataclass
@@ -119,7 +121,7 @@ def report_log(
119121
exc: Optional[BaseException] = None,
120122
log: bool = False,
121123
stacklevel: int = 1,
122-
log_type: Optional[StructuredLogType] = None,
124+
log_category: Optional[StructuredLogCategory] = None,
123125
) -> None:
124126
"""
125127
Report a user-facing log for the ingestion run.
@@ -130,7 +132,7 @@ def report_log(
130132
title: The category / heading to present on for this message in the UI.
131133
context: Additional context (e.g. where, how) for the log entry.
132134
exc: The exception associated with the event. We'll show the stack trace when in debug mode.
133-
log_type: The type of the log entry. This is used to categorise the log entry.
135+
log_category: The type of the log entry. This is used to categorise the log entry.
134136
log: Whether to log the entry to the console.
135137
stacklevel: The stack level to use for the log entry.
136138
"""
@@ -175,7 +177,7 @@ def report_log(
175177
title=title,
176178
message=message,
177179
context=context_list,
178-
log_type=log_type,
180+
log_category=log_category,
179181
)
180182
else:
181183
if context is not None:
@@ -235,7 +237,7 @@ def report_warning(
235237
context: Optional[str] = None,
236238
title: Optional[LiteralString] = None,
237239
exc: Optional[BaseException] = None,
238-
log_type: Optional[StructuredLogType] = None,
240+
log_category: Optional[StructuredLogCategory] = None,
239241
) -> None:
240242
"""
241243
See docs of StructuredLogs.report_log for details of args
@@ -247,7 +249,7 @@ def report_warning(
247249
context,
248250
exc,
249251
log=False,
250-
log_type=log_type,
252+
log_category=log_category,
251253
)
252254

253255
def warning(
@@ -257,7 +259,7 @@ def warning(
257259
title: Optional[LiteralString] = None,
258260
exc: Optional[BaseException] = None,
259261
log: bool = True,
260-
log_type: Optional[StructuredLogType] = None,
262+
log_category: Optional[StructuredLogCategory] = None,
261263
) -> None:
262264
"""
263265
See docs of StructuredLogs.report_log for details of args
@@ -269,7 +271,7 @@ def warning(
269271
context,
270272
exc,
271273
log=log,
272-
log_type=log_type,
274+
log_category=log_category,
273275
)
274276

275277
def report_failure(
@@ -279,7 +281,7 @@ def report_failure(
279281
title: Optional[LiteralString] = None,
280282
exc: Optional[BaseException] = None,
281283
log: bool = True,
282-
log_type: Optional[StructuredLogType] = None,
284+
log_category: Optional[StructuredLogCategory] = None,
283285
) -> None:
284286
"""
285287
See docs of StructuredLogs.report_log for details of args
@@ -291,7 +293,7 @@ def report_failure(
291293
context,
292294
exc,
293295
log=log,
294-
log_type=log_type,
296+
log_category=log_category,
295297
)
296298

297299
def failure(
@@ -301,7 +303,7 @@ def failure(
301303
title: Optional[LiteralString] = None,
302304
exc: Optional[BaseException] = None,
303305
log: bool = True,
304-
log_type: Optional[StructuredLogType] = None,
306+
log_category: Optional[StructuredLogCategory] = None,
305307
) -> None:
306308
"""
307309
See docs of StructuredLogs.report_log for details of args
@@ -313,7 +315,7 @@ def failure(
313315
context,
314316
exc,
315317
log=log,
316-
log_type=log_type,
318+
log_category=log_category,
317319
)
318320

319321
def info(
@@ -323,7 +325,7 @@ def info(
323325
title: Optional[LiteralString] = None,
324326
exc: Optional[BaseException] = None,
325327
log: bool = True,
326-
log_type: Optional[StructuredLogType] = None,
328+
log_category: Optional[StructuredLogCategory] = None,
327329
) -> None:
328330
"""
329331
See docs of StructuredLogs.report_log for details of args
@@ -335,7 +337,7 @@ def info(
335337
context,
336338
exc,
337339
log=log,
338-
log_type=log_type,
340+
log_category=log_category,
339341
)
340342

341343
@contextlib.contextmanager
@@ -345,7 +347,7 @@ def report_exc(
345347
title: Optional[LiteralString] = None,
346348
context: Optional[str] = None,
347349
level: StructuredLogLevel = StructuredLogLevel.ERROR,
348-
log_type: Optional[StructuredLogType] = None,
350+
log_category: Optional[StructuredLogCategory] = None,
349351
) -> Iterator[None]:
350352
# Convenience method that helps avoid boilerplate try/except blocks.
351353
# TODO: I'm not super happy with the naming here - it's not obvious that this
@@ -359,7 +361,7 @@ def report_exc(
359361
title=title,
360362
context=context,
361363
exc=exc,
362-
log_type=log_type,
364+
log_category=log_category,
363365
)
364366

365367
def __post_init__(self) -> None:

metadata-ingestion/src/datahub/ingestion/source/mock_data/datahub_mock_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
platform_name,
1414
support_status,
1515
)
16-
from datahub.ingestion.api.source import Source, SourceReport, StructuredLogType
16+
from datahub.ingestion.api.source import Source, SourceReport, StructuredLogCategory
1717
from datahub.ingestion.api.workunit import MetadataWorkUnit
1818
from datahub.ingestion.source.common.subtypes import DatasetSubTypes
1919
from datahub.ingestion.source.mock_data.datahub_mock_data_report import (
@@ -178,7 +178,7 @@ def get_workunits(self) -> Iterable[MetadataWorkUnit]:
178178
message="This is test warning",
179179
title="Test Warning",
180180
context=f"This is test warning {i}",
181-
log_type=StructuredLogType.LINEAGE,
181+
log_category=StructuredLogCategory.LINEAGE,
182182
)
183183

184184
# We don't want any implicit aspects to be produced

0 commit comments

Comments
 (0)