Skip to content

Commit

Permalink
feat(dispatch-aws-plugin): better logging (#5594)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvilanova authored Dec 10, 2024
1 parent 0b0cdc8 commit 5dfb177
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/dispatch/plugins/dispatch_aws/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def consume(self, db_session: Session, project: Project) -> None:
)
except ValidationError as e:
log.warning(
f"Received a signal instance that does not conform to the `SignalInstanceCreate` structure. Skipping creation: {e}"
f"Received a signal instance that does not conform to the SignalInstanceCreate pydantic model. Skipping creation: {e}"
)
continue

Expand All @@ -104,7 +104,7 @@ def consume(self, db_session: Session, project: Project) -> None:
db_session=db_session, signal_instance_id=signal_instance_in.raw["id"]
):
log.info(
f"Received a signal instance that already exists in the database. Skipping creation: {signal_instance_in.raw['id']}"
f"Received a signal that already exists in the database. Skipping signal instance creation: {signal_instance_in.raw['id']}"
)
continue

Expand All @@ -117,15 +117,17 @@ def consume(self, db_session: Session, project: Project) -> None:
except IntegrityError as e:
if isinstance(e.orig, UniqueViolation):
log.info(
f"Received a signal instance that already exists in the database. Skipping creation: {e}"
f"Received a signal that already exists in the database. Skipping signal instance creation: {e}"
)
else:
log.exception(
f"Encountered an Integrity error when trying to create a signal instance: {e}"
f"Encountered an integrity error when trying to create a signal instance: {e}"
)
continue
except Exception as e:
log.exception(f"Unable to create signal instance: {e}")
log.exception(
f"Unable to create signal instance. Signal name/variant: {signal_instance_in.raw['name'] if signal_instance_in.raw and signal_instance_in.raw['name'] else signal_instance_in.raw['variant']}. Error: {e}"
)
db_session.rollback()
continue
else:
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/signal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def create_instance(
signal_instance.id = signal_instance_in.raw["id"]

if signal_instance.id and not is_valid_uuid(signal_instance.id):
msg = f"Invalid signal id format. Expecting UUIDv4 format. Signal id: {signal_instance.id}. Signal name/variant: {signal_instance.signal.name if signal_instance.signal and signal_instance.signal.name else signal_instance.signal.variant}"
msg = f"Invalid signal id format. Expecting UUIDv4 format. Signal id: {signal_instance.id}. Signal name/variant: {signal_instance.signal.raw.name if signal_instance.signal and signal_instance.signal.raw and signal_instance.signal.raw.name else signal_instance.signal.raw.variant}"
log.warn(msg)
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
Expand Down

0 comments on commit 5dfb177

Please sign in to comment.