Skip to content

Commit

Permalink
Add error logging (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored Oct 20, 2023
1 parent bbe5100 commit 639747d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ We recommend using the provided Docker container.

A pre-build version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/mass):
```bash
docker pull ghga/mass:0.3.4
docker pull ghga/mass:0.3.5
```

Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
```bash
# Execute in the repo's root dir:
docker build -t ghga/mass:0.3.4 .
docker build -t ghga/mass:0.3.5 .
```

For production-ready deployment, we recommend using Kubernetes, however,
for simple use cases, you could execute the service using docker
on a single server:
```bash
# The entrypoint is preconfigured:
docker run -p 8080:8080 ghga/mass:0.3.4 --help
docker run -p 8080:8080 ghga/mass:0.3.5 --help
```

If you prefer not to use containers, you may install the service from source:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mass"
version = "0.3.4"
version = "0.3.5"
description = "Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results."
readme = "README.md"
authors = [
Expand Down
26 changes: 19 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --generate-hashes --output-file=/workspace/requirements-dev.txt /tmp/tmpi5lkji3b/pyproject.toml /workspace/requirements-dev.in
# pip-compile --generate-hashes --output-file=/workspace/requirements-dev.txt /tmp/tmpc8p8_yj9/pyproject.toml /workspace/requirements-dev.in
#
aiokafka==0.8.0 \
--hash=sha256:021e9f0027ca63c6c04daccfdd0e985f7a56d51bd0d43f482f674a58fada52f5 \
Expand Down Expand Up @@ -247,7 +247,9 @@ coverage[toml]==7.3.2 \
--hash=sha256:f94b734214ea6a36fe16e96a70d941af80ff3bfd716c141300d95ebc85339738 \
--hash=sha256:fa28e909776dc69efb6ed975a63691bc8172b64ff357e663a1bb06ff3c9b589a \
--hash=sha256:fe494faa90ce6381770746077243231e0b83ff3f17069d748f645617cefe19d4
# via pytest-cov
# via
# coverage
# pytest-cov
dependency-injector==4.41.0 \
--hash=sha256:02620454ee8101f77a317f3229935ce687480883d72a40858ff4b0c87c935cce \
--hash=sha256:059fbb48333148143e8667a5323d162628dfe27c386bd0ed3deeecfc390338bf \
Expand Down Expand Up @@ -364,7 +366,9 @@ ghga-event-schemas==0.13.5 \
ghga-service-commons[api]==0.7.1 \
--hash=sha256:70a6bc39d3ab8309524dfbcd4c29e5f37de118c41107fb42054834e5dcf8decc \
--hash=sha256:888a789cbea86bcd7433e0b848c137928eea87bd9194de3504a3c25a36ac983c
# via mass (pyproject.toml)
# via
# ghga-service-commons
# mass (pyproject.toml)
gprof2dot==2022.7.29 \
--hash=sha256:45b4d298bd36608fccf9511c3fd88a773f7a1abc04d6cd39445b11ba43133ec5 \
--hash=sha256:f165b3851d3c52ee4915eb1bd6cca571e5759823c2cd0f71a79bda93c2dc85d6
Expand All @@ -378,7 +382,9 @@ h11==0.14.0 \
hexkit[akafka,mongodb]==0.10.2 \
--hash=sha256:1495f2bc6ae7423874bc20367dd28555cd15a74ccf5cb4997e0fb8307757987e \
--hash=sha256:436ea50e706ab616803eb85a9a9f5e7bec727379b750b966650d6e64d4ea5ef0
# via mass (pyproject.toml)
# via
# hexkit
# mass (pyproject.toml)
httpcore==0.16.3 \
--hash=sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb \
--hash=sha256:da1fb708784a938aa084bde4feb8317056c55037247c787bd7e19eb2c2949dc0
Expand Down Expand Up @@ -762,7 +768,9 @@ requests==2.31.0 \
rfc3986[idna2008]==1.5.0 \
--hash=sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835 \
--hash=sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97
# via httpx
# via
# httpx
# rfc3986
rpds-py==0.10.4 \
--hash=sha256:00a88003db3cc953f8656b59fc9af9d0637a1fb93c235814007988f8c153b2f2 \
--hash=sha256:049098dabfe705e9638c55a3321137a821399c50940041a6fcce267a22c70db2 \
Expand Down Expand Up @@ -911,7 +919,9 @@ stringcase==1.2.0 \
# via -r /workspace/requirements-dev-common.in
testcontainers[mongo]==3.7.1 \
--hash=sha256:7f48cef4bf0ccd78f1a4534d4b701a003a3bace851f24eae58a32f9e3f0aeba0
# via -r /workspace/requirements-dev.in
# via
# -r /workspace/requirements-dev.in
# testcontainers
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
Expand Down Expand Up @@ -966,7 +976,9 @@ urllib3==2.0.6 \
uvicorn[standard]==0.20.0 \
--hash=sha256:a4e12017b940247f836bc90b72e725d7dfd0c8ed1c51eb365f5ba30d9f5127d8 \
--hash=sha256:c3ed1598a5668208723f2bb49336f4509424ad198d6ab2615b7783db58d919fd
# via ghga-service-commons
# via
# ghga-service-commons
# uvicorn
uvloop==0.17.0 \
--hash=sha256:0949caf774b9fcefc7c5756bacbbbd3fc4c05a6b7eebc7c7ad6f825b23998d6d \
--hash=sha256:0ddf6baf9cf11a1a22c71487f39f15b2cf78eb5bde7e5b45fbb99e8a9d91b9e1 \
Expand Down
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --constraint=/workspace/requirements-dev.txt --generate-hashes --output-file=/workspace/requirements.txt /tmp/tmpi5lkji3b/pyproject.toml
# pip-compile --constraint=/workspace/requirements-dev.txt --generate-hashes --output-file=/workspace/requirements.txt /tmp/tmpc8p8_yj9/pyproject.toml
#
aiokafka==0.8.0 \
--hash=sha256:021e9f0027ca63c6c04daccfdd0e985f7a56d51bd0d43f482f674a58fada52f5 \
Expand Down Expand Up @@ -185,6 +185,7 @@ ghga-service-commons[api]==0.7.1 \
--hash=sha256:888a789cbea86bcd7433e0b848c137928eea87bd9194de3504a3c25a36ac983c
# via
# -c /workspace/requirements-dev.txt
# ghga-service-commons
# mass (pyproject.toml)
h11==0.14.0 \
--hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \
Expand All @@ -198,6 +199,7 @@ hexkit[akafka,mongodb]==0.10.2 \
--hash=sha256:436ea50e706ab616803eb85a9a9f5e7bec727379b750b966650d6e64d4ea5ef0
# via
# -c /workspace/requirements-dev.txt
# hexkit
# mass (pyproject.toml)
httpcore==0.16.3 \
--hash=sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb \
Expand Down Expand Up @@ -481,6 +483,7 @@ rfc3986[idna2008]==1.5.0 \
# via
# -c /workspace/requirements-dev.txt
# httpx
# rfc3986
rpds-py==0.10.4 \
--hash=sha256:00a88003db3cc953f8656b59fc9af9d0637a1fb93c235814007988f8c153b2f2 \
--hash=sha256:049098dabfe705e9638c55a3321137a821399c50940041a6fcce267a22c70db2 \
Expand Down Expand Up @@ -625,6 +628,7 @@ uvicorn[standard]==0.20.0 \
# via
# -c /workspace/requirements-dev.txt
# ghga-service-commons
# uvicorn
uvloop==0.17.0 \
--hash=sha256:0949caf774b9fcefc7c5756bacbbbd3fc4c05a6b7eebc7c7ad6f825b23998d6d \
--hash=sha256:0ddf6baf9cf11a1a22c71487f39f15b2cf78eb5bde7e5b45fbb99e8a9d91b9e1 \
Expand Down
6 changes: 6 additions & 0 deletions src/mass/adapters/inbound/event_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
)
SCHEMA_VALIDATION_ERROR_LOG_MSG = "Failed to validate event schema for '%s'"

EVENT_RECEIVED_LOG_MESSAGE = "Received event of type '%s'"
UNEXPECTED_EVENT_LOG_MESSAGE = "Received unexpected event of type '%s'"

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -140,7 +143,10 @@ async def _consume_validated(
topic: Ascii, # pylint: disable=unused-argument
) -> None:
"""Consumes an event"""
log.info(EVENT_RECEIVED_LOG_MESSAGE, type)
if type_ == self._config.resource_deletion_event_type:
await self._handle_deletion(payload=payload)
elif type_ == self._config.resource_upsertion_event_type:
await self._handle_upsertion(payload=payload)
else:
log.warning(UNEXPECTED_EVENT_LOG_MESSAGE, type)
11 changes: 8 additions & 3 deletions src/mass/adapters/inbound/fastapi_/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# limitations under the License.
#

"""Contains API endpoints"""
"""API endpoints"""

import logging
from typing import Union

from dependency_injector.wiring import Provide, inject
Expand All @@ -27,6 +29,8 @@
from mass.core import models
from mass.ports.inbound.query_handler import QueryHandlerPort

log = logging.getLogger(__name__)

router = APIRouter()


Expand Down Expand Up @@ -83,10 +87,11 @@ async def search(
except query_handler.ClassNotConfiguredError as err:
raise HTTPException(
status_code=422,
detail="The specified class name is invalid. See "
+ "/rpc/search-options for a list of valid class names.",
detail="The specified class name is invalid."
+ " See /rpc/search-options for a list of valid class names.",
) from err
except (query_handler.SearchError, query_handler.ValidationError) as err:
log.error("Search operation error: %s", err)
raise HTTPException(
status_code=500, detail="An error occurred during search operation"
) from err
Expand Down

0 comments on commit 639747d

Please sign in to comment.