Skip to content

Commit

Permalink
feat sentry cron (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
polomarcus authored Feb 23, 2024
1 parent 2f8241b commit de8e670
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions quotaclimat/data_ingestion/ingest_db/ingest_sitemap_in_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
from postgres.schemas.models import create_tables, connect_to_db, get_last_month_sitemap_id
from quotaclimat.utils.healthcheck_config import run_health_check_server
from quotaclimat.utils.logger import CustomFormatter
import sentry_sdk
from sentry_sdk.crons import monitor

# read SENTRY_DSN from env
sentry_sdk.init(
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=0.7,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=0.7,
)
import asyncio

from quotaclimat.data_ingestion.scrap_sitemap import \
Expand Down Expand Up @@ -38,6 +50,8 @@ async def batch_sitemap(exit_event):
exit_event.set()
return

#https://docs.sentry.io/platforms/python/crons/
@monitor(monitor_slug='sitemap')
async def main():
event_finish = asyncio.Event()
# Start the health check server in the background
Expand Down
5 changes: 4 additions & 1 deletion quotaclimat/data_processing/mediatree/api_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from typing import List, Optional
from tenacity import *
import sentry_sdk
from sentry_sdk.crons import monitor

# read SENTRY_DSN from env
sentry_sdk.init(
Expand Down Expand Up @@ -241,7 +242,9 @@ def log_dataframe_size(df, channel):
logging.warning(f"High Dataframe size : {bytes_size / (1000 * 1000)}")
if(len(df) == 1000):
logging.error("We might lose data - df size is 1000 out of 1000 - we should divide this querry")


#https://docs.sentry.io/platforms/python/crons/
@monitor(monitor_slug='mediatree')
async def main():
logger.info("Start api mediatree import")
create_tables()
Expand Down

1 comment on commit de8e670

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage

Coverage Report
FileStmtsMissCoverMissing
postgres
   insert_data.py46785%38–40, 59–61, 66
   insert_existing_data_example.py20385%25–27
postgres/schemas
   models.py711579%74–81, 91–92, 101–111
quotaclimat/data_analytics
   analytics_signataire_charte.py29290%1–67
   bilan.py1081080%2–372
   data_coverage.py34340%1–94
   exploration.py1251250%1–440
   sitemap_analytics.py1181180%1–343
quotaclimat/data_ingestion
   categorization_program_type.py110%1
   config_youtube.py110%1
   scaleway_db_backups.py34340%1–74
   scrap_chartejournalismeecologie_signataires.py50500%1–169
   scrap_sitemap.py1341787%27–28, 33–34, 66–71, 95–97, 138–140, 202, 223–228
   scrap_tv_program.py62620%1–149
   scrap_youtube.py1141140%1–238
quotaclimat/data_ingestion/ingest_db
   ingest_sitemap_in_db.py584031%30–51, 56–75, 79–90
quotaclimat/data_ingestion/scrap_html
   scrap_description_article.py36392%19–20, 32
quotaclimat/data_processing/mediatree
   api_import.py18310642%45–49, 54–57, 61–64, 70, 73–98, 104–119, 124–126, 151–158, 162–165, 169–175, 186–197, 200–204, 210, 235–236, 242, 244, 249–275, 279–290
   config.py15287%7, 16
   detect_keywords.py88693%101–108
   utils.py642167%27–51, 54, 73–74
quotaclimat/data_processing/sitemap
   sitemap_processing.py412734%15–19, 23–25, 29–47, 51–58, 66–96, 101–103
quotaclimat/utils
   channels.py660%1–95
   climate_keywords.py220%3–35
   healthcheck_config.py291452%22–24, 27–38
   logger.py14379%22–24
   plotly_theme.py17170%1–56
TOTAL154496538% 

Tests Skipped Failures Errors Time
39 0 💤 0 ❌ 0 🔥 10.584s ⏱️

Please sign in to comment.