René's URL Explorer Experiment


Title: Cronjob monitoring isn't very ergonomic if you're not using an automatic integration · Issue #2770 · getsentry/sentry-python · GitHub

Open Graph Title: Cronjob monitoring isn't very ergonomic if you're not using an automatic integration · Issue #2770 · getsentry/sentry-python

X Title: Cronjob monitoring isn't very ergonomic if you're not using an automatic integration · Issue #2770 · getsentry/sentry-python

Description: Problem Statement The sentry.monitor() context manager is incredibly basic and doesn't set up transactions, tags or allow you to configure cronjobs via upsert Solution Brainstorm My current solution is this baseclass which works, but it'...

Open Graph Description: Problem Statement The sentry.monitor() context manager is incredibly basic and doesn't set up transactions, tags or allow you to configure cronjobs via upsert Solution Brainstorm My current solutio...

X Description: Problem Statement The sentry.monitor() context manager is incredibly basic and doesn't set up transactions, tags or allow you to configure cronjobs via upsert Solution Brainstorm My current sol...

Opengraph URL: https://github.com/getsentry/sentry-python/issues/2770

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cronjob monitoring isn't very ergonomic if you're not using an automatic integration","articleBody":"### Problem Statement\n\nThe `sentry.monitor()` context manager is incredibly basic and doesn't set up transactions, tags or allow you to configure cronjobs via upsert\n\n### Solution Brainstorm\n\nMy current solution is this baseclass which works, but it's not great and I'm fairly wary about pulling unexported functions from inner modules.\r\n\r\n```python\r\nfrom __future__ import annotations\r\n\r\nimport os\r\nfrom typing import Optional\r\n\r\nimport sentry_sdk\r\nfrom django.core.management import BaseCommand\r\nfrom sentry_sdk.crons.api import capture_checkin\r\nfrom sentry_sdk.crons.consts import MonitorStatus\r\nfrom sentry_sdk.utils import now as timing_now\r\n\r\n\r\nclass BaseCronJob(BaseCommand):\r\n    def run_cronjob(self):\r\n        raise NotImplementedError(\"You must override the `run_cronjob` method!\")\r\n\r\n    name: Optional[str] = None\r\n\r\n    def __init__(self, *args, **kwargs) -> None:\r\n        name_override = os.environ.get(\"CRONJOB_NAME\")\r\n        if name_override is not None:\r\n            self.name = name_override\r\n        super().__init__(*args, **kwargs)\r\n\r\n    def create_parser(self, prog_name: str, subcommand: str, **kwargs):\r\n        # Cheeky hack for figuring out the cronjob name from the command name\r\n        if self.name is None:\r\n            self.name = subcommand.replace(\"_\", \"-\")\r\n        return super().create_parser(prog_name, subcommand, **kwargs)\r\n\r\n    def handle(self, *args, **options):\r\n        cronjob_schedule = os.getenv(\"CRONJOB_SCHEDULE\")\r\n        cronjob_startup = os.getenv(\"CRONJOB_STARTUP_DEADLINE\")\r\n        monitor_config = None\r\n        if cronjob_schedule is not None:\r\n            monitor_config = {\r\n                \"schedule\": {\r\n                    \"value\": cronjob_schedule,\r\n                    \"type\": \"crontab\",\r\n                },\r\n                \"timezone\": \"Etc/UTC\",\r\n            }\r\n            if cronjob_startup is not None:\r\n                monitor_config[\"checkin_margin\"] = cronjob_startup\r\n\r\n        with sentry_sdk.start_transaction(op=\"task\", name=self.name):\r\n            sentry_sdk.set_tag(\"cronjob\", \"true\")\r\n            sentry_sdk.set_context(\"monitor\", {\"slug\": self.name})\r\n\r\n            self.stdout.write(f\"Starting cronjob {self.name}\", self.style.NOTICE)\r\n\r\n            start_timestamp = timing_now()\r\n            check_in_id = capture_checkin(\r\n                monitor_slug=self.name,\r\n                status=MonitorStatus.IN_PROGRESS,\r\n                monitor_config=monitor_config,\r\n            )\r\n\r\n            try:\r\n                self.run_cronjob()\r\n            except Exception:\r\n                duration_s = timing_now() - start_timestamp\r\n                if check_in_id:\r\n                    capture_checkin(\r\n                        monitor_slug=self.name,\r\n                        check_in_id=check_in_id,\r\n                        status=MonitorStatus.ERROR,\r\n                        duration=duration_s,\r\n                    )\r\n                self.stdout.write(\r\n                    f\"Cronjob {self.name} failed after {duration_s:.2}s\",\r\n                    self.style.ERROR,\r\n                )\r\n                raise\r\n            else:\r\n                duration_s = timing_now() - start_timestamp\r\n                if check_in_id:\r\n                    capture_checkin(\r\n                        monitor_slug=self.name,\r\n                        check_in_id=check_in_id,\r\n                        status=MonitorStatus.OK,\r\n                        duration=duration_s,\r\n                    )\r\n                self.stdout.write(\r\n                    f\"Cronjob {self.name} succeeded after {duration_s:.2}s\",\r\n                    self.style.SUCCESS,\r\n                )\r\n```","author":{"url":"https://github.com/Lexicality","@type":"Person","name":"Lexicality"},"datePublished":"2024-02-27T13:29:14Z","url":"https://github.com/getsentry/sentry-python/issues/2770"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:56ca396c-f88d-0307-875c-42236de2b79d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC2B2:0DB8:40DDCB:5A08B7:6B008DF7
html-safe-nonce2e1fe15f8553d66f89d2238c2159afdcaaf5179fe9b5cb2e85c101252ee4fa36
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkIyOjBEQjg6NDBERENCOjVBMDhCNzo2QjAwOERGNyIsInZpc2l0b3JfaWQiOiI2MDkxNDQ4MTYyMzIzNTY2MDcxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace0dd22a5519aebe474f94dc6bcdb2002d18c05974ba23ee88df4ace9fd4b15cc
hovercard-subject-tagissue:2156601590
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/2770/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4e9fb6e735830fe5bf54628ced602ad529ec68613404ea8a0dba3d796344ba97/getsentry/sentry-python/issues/2770
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4e9fb6e735830fe5bf54628ced602ad529ec68613404ea8a0dba3d796344ba97/getsentry/sentry-python/issues/2770
og:image:altProblem Statement The sentry.monitor() context manager is incredibly basic and doesn't set up transactions, tags or allow you to configure cronjobs via upsert Solution Brainstorm My current solutio...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameLexicality
hostnamegithub.com
expected-hostnamegithub.com
Nonec710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id137814779
octolytics-dimension-repository_nwogetsentry/sentry-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id137814779
octolytics-dimension-repository_network_root_nwogetsentry/sentry-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebe616a2a6ec1c609d6e002896dff5352d5c5f28b
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/issues/2770#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F2770
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F2770
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-python
Reloadhttps://github.com/getsentry/sentry-python/issues/2770
Reloadhttps://github.com/getsentry/sentry-python/issues/2770
Reloadhttps://github.com/getsentry/sentry-python/issues/2770
getsentryhttps://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Codehttps://github.com/getsentry/sentry-python
Issues345 (345)https://github.com/getsentry/sentry-python/issues
Pull requests41 (41)https://github.com/getsentry/sentry-python/pulls
Discussionshttps://github.com/getsentry/sentry-python/discussions
Actionshttps://github.com/getsentry/sentry-python/actions
Security and quality2 (2)https://github.com/getsentry/sentry-python/security
Insightshttps://github.com/getsentry/sentry-python/insights
https://github.com/getsentry/sentry-python
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/2770
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/2770
#2929https://github.com/getsentry/sentry-python/pull/2929
Cronjob monitoring isn't very ergonomic if you're not using an automatic integrationhttps://github.com/getsentry/sentry-python/issues/2770#top
#2929https://github.com/getsentry/sentry-python/pull/2929
Feature: Cronshttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Feature%3A%20Crons%22
https://github.com/Lexicality
Lexicalityhttps://github.com/Lexicality
on Feb 27, 2024https://github.com/getsentry/sentry-python/issues/2770#issue-2156601590
Lexicalityhttps://github.com/Lexicality
enhancementhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Feb 27, 2024https://github.com/getsentry/sentry-python/issues/2770#event-11936448323
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Feb 27, 2024https://github.com/getsentry/sentry-python/issues/2770#event-11936448823
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 27, 2024https://github.com/getsentry/sentry-python/issues/2770#event-14895149669
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 27, 2024https://github.com/getsentry/sentry-python/issues/2770
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-1971137288
@Lexicalityhttps://github.com/Lexicality
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770#event-11966013012
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770
https://github.com/Lexicality
Lexicalityhttps://github.com/Lexicality
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-1971168577
@sentrivanahttps://github.com/sentrivana
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770#event-11966193540
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770
https://github.com/Lexicality
Lexicalityhttps://github.com/Lexicality
on Feb 29, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-1971184423
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Mar 4, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-1976100636
@Lexicalityhttps://github.com/Lexicality
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Mar 4, 2024https://github.com/getsentry/sentry-python/issues/2770#event-11995884864
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Mar 4, 2024https://github.com/getsentry/sentry-python/issues/2770
sentrivanahttps://github.com/sentrivana
Feature: Cronshttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Feature%3A%20Crons%22
on Mar 4, 2024https://github.com/getsentry/sentry-python/issues/2770#event-11995889633
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Apr 2, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-2031662285
#2925https://github.com/getsentry/sentry-python/issues/2925
sentrivanahttps://github.com/sentrivana
completedhttps://github.com/getsentry/sentry-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2929https://github.com/getsentry/sentry-python/pull/2929
on Apr 2, 2024https://github.com/getsentry/sentry-python/issues/2770#event-12324665901
https://github.com/Lexicality
Lexicalityhttps://github.com/Lexicality
on Apr 2, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-2032163023
#2925https://github.com/getsentry/sentry-python/issues/2925
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Apr 2, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-2032269447
@Lexicalityhttps://github.com/Lexicality
https://github.com/Lexicality
Lexicalityhttps://github.com/Lexicality
on Apr 2, 2024https://github.com/getsentry/sentry-python/issues/2770#issuecomment-2032550417
@Lexicalityhttps://github.com/Lexicality
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-python/issues/2770
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/2770
Feature: Cronshttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Feature%3A%20Crons%22
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.