Skip to content

Commit

Permalink
feat: add sentry integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed May 27, 2024
1 parent 935b3d5 commit 2a083c5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
52 changes: 51 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ipython = "^8.24.0"
sqlalchemy = "^2.0.30"
requests = "^2.31.0"
elasticsearch = "7.14"
sentry-sdk = "^2.3.1"


[build-system]
Expand Down
8 changes: 8 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sentry_sdk

import logging
import time

Expand Down Expand Up @@ -46,6 +48,12 @@ def bulk_process():


def main():
if settings.USE_SENTRY:
sentry_sdk.init(
dsn=settings.SENTRY_DSN,
enable_tracing=True,
)

logging.info("Service running on bulk process single thread mode")
bulk_process()

Expand Down
4 changes: 4 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ES_URL = os.environ.get("ES_URL", "")
ES_FLOWRUN_INDEX_NAME = os.environ.get("ES_FLOWRUN_INDEX_NAME", "flowruns")
FLOW_RUN_BATCH_LIMIT = int(os.environ.get("FLOW_RUN_BATCH_LIMIT", 100))
EMPTY_ORG_SLEEP = float(os.environ.get("EMPTY_ORG_SLEEP", 0.1))
BATCH_PROCESSING_TIME_LIMIT = int(os.environ.get("BATCH_PROCESSING_TIME_LIMIT", 30))
START_RUN_OFFSET = int(os.environ.get("START_RUN_OFFSET", 30))
FLOW_LAST_INDEXED_FIELD = os.environ.get("FLOW_LAST_INDEXED_FIELD", "modified_on")
Expand All @@ -16,3 +17,6 @@

PROCESS_TYPE = os.environ.get("PROCESS_TYPE", "BULK")
CONSUMER_MAIN_DELAY = int(os.environ.get("CONSUMER_MAIN_DELAY", 1000))

USE_SENTRY = bool(int(os.environ.get("USE_SENTRY", "0")))
SENTRY_DSN = os.environ.get("SENTRY_DSN", None)
3 changes: 3 additions & 0 deletions shared/processors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import settings

from typing import Callable
Expand Down Expand Up @@ -30,6 +31,7 @@ def execute(self):
modified_on=last_indexed_at, org_id=org_id
)
if len(from_obj_list) == 0: # if there's no objects on the list
time.sleep(settings.EMPTY_ORG_SLEEP)
continue

transformed_objects = []
Expand All @@ -46,5 +48,6 @@ def execute(self):

# [L]oad the treated object list into the new storage
is_inserted: bool = self.storage_to.bulk_insert(transformed_objects)
time.sleep(settings.EMPTY_ORG_SLEEP)

return is_inserted

0 comments on commit 2a083c5

Please sign in to comment.