Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest/kafka): Better error handling around topic and topic description extraction #8183

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions metadata-ingestion/src/datahub/ingestion/source/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,15 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
for t, t_detail in topics.items():
self.report.report_topic_scanned(t)
if self.source_config.topic_patterns.allowed(t):
yield from self._extract_record(t, t_detail, extra_topic_details.get(t))
try:
yield from self._extract_record(
t, t_detail, extra_topic_details.get(t)
)
except Exception as e:
logger.warning(f"Failed to extract topic {t}", exc_info=True)
self.report.report_warning(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a failure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk about this source at all, so I erred on the side of caution lol. I am happy to swap if you think it should be

"topic", f"Exception while extracting topic {t}: {e}"
)
else:
self.report.report_dropped(t)

Expand Down Expand Up @@ -259,9 +267,9 @@ def _extract_record(
# Point to note:
# In Kafka documentSchema and keySchema both contains "doc" field.
# DataHub Dataset "description" field is mapped to documentSchema's "doc" field.
description = json.loads(schema_metadata.platformSchema.documentSchema).get(
DOC_KEY
)
schema = json.loads(schema_metadata.platformSchema.documentSchema)
if isinstance(schema, dict):
description = schema.get(DOC_KEY)

dataset_properties = DatasetPropertiesClass(
name=topic, customProperties=custom_props, description=description
Expand Down