Skip to content

Commit

Permalink
fix(ingest): better warnings and error handling for rest sink (#2800)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Jun 30, 2021
1 parent 4da7672 commit ef75bc6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions metadata-ingestion/src/datahub/emitter/rest_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import shlex
from collections import OrderedDict
from json.decoder import JSONDecodeError
from typing import Any, List, Optional, Union

import requests
Expand Down Expand Up @@ -63,6 +64,10 @@ class DatahubRestEmitter:
_session: requests.Session

def __init__(self, gms_server: str, token: Optional[str] = None):
if ":9002" in gms_server:
logger.warn(
"the rest emitter should connect to GMS (usually port 8080) instead of frontend"
)
self._gms_server = gms_server
self._token = token

Expand Down Expand Up @@ -119,10 +124,16 @@ def _emit_generic(self, url: str, payload: str) -> None:

response.raise_for_status()
except HTTPError as e:
info = response.json()
raise OperationalError(
"Unable to emit metadata to DataHub GMS", info
) from e
try:
info = response.json()
raise OperationalError(
"Unable to emit metadata to DataHub GMS", info
) from e
except JSONDecodeError:
# If we can't parse the JSON, just raise the original error.
raise OperationalError(
"Unable to emit metadata to DataHub GMS", {"message": str(e)}
) from e
except RequestException as e:
raise OperationalError(
"Unable to emit metadata to DataHub GMS", {"message": str(e)}
Expand Down

0 comments on commit ef75bc6

Please sign in to comment.