Repository navigation
Conversation
cronitor/ingest.py builds Sentry-format envelopes and sends them to
{ingest_url}/api/envelope from one daemon thread with a bounded queue.
Events go out one envelope each; log records batch to 100 or 5 seconds.
Bodies are gzipped, sends time out after 5 seconds with one retry, a 429
pauses sending for Retry-After (capped at 60 seconds), and failures are
logged, never raised. The worker starts lazily, restarts after fork, and
queued items are flushed at exit with a 2 second cap.
cronitor.ingest_url (env CRONITOR_INGEST_URL, default https://cronitor.link)
now also sets the ping URL base, so a dev stack can receive everything.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
cronitor/capture.py builds exception and message events and structured
log records. Exceptions follow __cause__ then __context__, oldest first,
with frames oldest first, five lines of source context from linecache,
and in_app false for site-packages, dist-packages and the stdlib. Local
variables are never sent. Values, messages and log bodies are truncated
to 4000/4000/8000 characters and tags and attributes to 50 entries.
cronitor.logger mirrors sentry_sdk.logger: the body is formatted with
str.format when attributes and braces are present, and the template and
parameters are recorded as sentry.message.* attributes. It replaces the
stdlib logger that was exported under that name; its configuration
methods still delegate to logging.getLogger('cronitor').
Monitor.capture_exception and Monitor.capture_message bind the monitor
key, environment and API key. New settings: cronitor.release (env
CRONITOR_RELEASE) and cronitor.capture_exceptions.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
The decorator binds the monitor key, series and environment in a context variable while the function runs, so capture_exception, capture_message and cronitor.logger calls inside it are tagged with cronitor.monitor and cronitor.series. When the function raises, the decorator sends the fail ping as before and then an exception event bound to the same series, with mechanism cronitor.job and handled false. Set cronitor.capture_exceptions = False to send only the ping. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
LogHandler ships logging records as structured log items through the same batching transport. Levels map DEBUG->debug, INFO->info, WARNING->warn, ERROR->error, CRITICAL->fatal, and anything below DEBUG to trace. Records carry logger.name, code.file.path, code.line.number and code.function.name, the %-style template and its arguments, and the cronitor.monitor/cronitor.series binding inside a job. A record with exc_info gets its formatted traceback in exception.stacktrace; no second event is sent. Records from the transport itself are ignored so a failing send cannot feed itself. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Covers the requests session, gzip body and headers on the wire, a real 429 with Retry-After, and a ping routed through the same ingest_url. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Adds an "Exceptions and Logs" README section: configuration, capture_exception, capture_message, cronitor.logger, LogHandler, flush, the @job behavior, and the Sentry SDK DSN alternative. Documents CRONITOR_INGEST_URL and CRONITOR_RELEASE. 5.0.0 because @cronitor.job now sends an exception event on failure by default and cronitor.logger is now the log shipper. A test keeps the SDK version reported on the wire equal to setup.py. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Envelope payloads are now strict JSON: NaN and Infinity in extra or log attributes become strings, circular extra data is cut instead of losing the event, unencodable dict keys are skipped, and lone surrogates are replaced. A missing API key is logged once per transport instead of on every record, which matters with LogHandler on a busy logger. The test envelope parser now rejects NaN like a strict backend would. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
cronitor.app (or CRONITOR_APP) names the app monitor that exception events and log records belong to. A cronitor.app tag or attribute on a single call overrides it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
The monitor type that owns exceptions and logs is called service. The SDK setting is cronitor.service (CRONITOR_SERVICE) and the tag and log attribute are cronitor.service. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
A telemetry outage used to raise the ping's ConnectionError into the decorated function before it ran. Pings are now best effort and logged. The README points Sentry SDK users at a service monitor's dsn instead of an API key id, and restores apply_config() in two examples. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
A child that inherited the transport reused the parent's keep-alive session, so both processes wrote to the same TLS socket, and a pool lock held by a parent thread at fork time could deadlock the child. When the pid changes the session and the rate limit window are reset along with the queue and the worker thread. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Before 5.0 cronitor.logger was logging.getLogger('cronitor'), so code
like cronitor.logger.info('x %s', 1) now raised TypeError. The logger
takes %-style arguments (falling back to the raw body when they do not
format), and adds warn, critical, exception (an error log carrying the
handled exception's type, message and stack trace) and log(level, ...)
for stdlib level numbers and names. Configuration calls still pass
through to the stdlib logger.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
The server drops event items over 1 MB, and a deep exception chain with source context or a large extra could exceed it. An event over 900 KB now loses every frame's source context, then extra, then all but the last 20 frames of each exception, stopping as soon as it fits, and extra['_trimmed'] records what was dropped. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Attribute keys are cut to 64 characters and values to 400, except the exception stack trace and message and the message template, which keep 8,000 like the body; a record keeps at most 50 attributes. LogHandler now defaults to INFO, so a root logger at DEBUG no longer ships every library's debug lines; LogHandler(level=logging.DEBUG) opts in. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
After a 429 the sender thread slept until the limit lifted, so every item queued behind it waited too and was lost when the 2 second exit flush gave up. Envelopes sent during the limit window are now dropped, counted in Transport.dropped and logged once per window. X-Sentry-Rate-Limits is read before Retry-After, as Sentry's SDKs do. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4Z4DjN96ccpNoVRZuoCxo
…tion-ingestion-8v0m74
aflanagan
left a comment
There was a problem hiding this comment.
Claude Opus 5.5 Medium review
I reviewed git diff origin/master...HEAD at 045f0eb against the frozen Error Tracking contract (cronitorio/cronitor #810–#821). I checked the REST shapes against the errors-api.md docs and cronitor/domain/errors.py in #816, and the errors-monitor validation against #821. Local test run: 116 passed, 7 skipped (the skips are the integration tests that need CRONITOR_TEST_API_KEY).
Contract alignment (verified)
- Ingest: the DSN is parsed as
https://<ingest_key>@host/<project_id>(the default/1is a placeholder). The client POSTs a gzipped envelope to{scheme}://{netloc}{prefix}/api/{project_id}/envelope/and sends bothX-Sentry-Auth: Sentry sentry_key=<ingest_key>, sentry_version=7, ...and the envelope headerdsn.cronitor.api_keyis never used as the ingest key:test_capturesets a REST key and still requires a DSN. - Capture:
capture_exceptionandcapture_message(module-level and onMonitor) takelevel,fingerprint(always sent as a list of strings),extra, andtags. Messages go out as{"formatted": ...}. Exceptions carry the__cause__/__context__chain and frames with 5 lines of source context. No locals are sent. Every capture path is wrapped and returnsNoneon failure. The transport runs on a daemon thread with a bounded queue, handles fork safety, and backs off on 429. - Logger and version:
cronitor.loggeris stilllogging.getLogger('cronitor'), and there is noLogHandler. Version is 4.10.0 in bothsetup.pyand_version.py. - REST:
ErrorApp(create/list/get/update/delete/rotate_key →/api/error-apps[/:key[/rotate-key]]) andErrorGroup(list with every documented filter/update(status, env)/events(env, app, cursor, limit)/event →/api/errors...) use basic authapi_key:. List parsing handles the server's{"data": [...]}envelope. HTTP 4xx/5xx map toAuthenticationError,APIValidationError,ErrorAppNotFound/ErrorGroupNotFound, orAPIError. Only opaque keys are used. @cronitor.job: auto-captures by default (mechanism=cronitor.job,handled=False), andcronitor.capture_exceptionsand the decorator'scapture_exceptions=override it correctly. Run/fail/complete pings go through_safe_ping, so a ping failure no longer raises into the job. The ContextVar binding is always reset infinally.- Errors monitors:
apply_configcounts theerrors:key, andMonitor.putpassestype: errorsthrough unchanged. No numeric DB primary keys appear anywhere.
Issue to fix
- The README
errors:YAML example fails backend validation.README.md(thebilling-error-spikesexample) useswindow: 5 minutes. In #821,parse_spike_windowonly accepts an integer or a string matching^(\d+)\s*m?$after strip/lower, and the API serializes the value back as"5m"."5 minutes"fails that match, so the server raiseswindow: must be whole minutes between 1m and 60m. A user who copies this example intocronitor.yamlgets a validation error fromapply_config(), and the whole config sync fails. Change it towindow: 5m(orwindow: 5). The other fields in that example (trigger: spike,apps: [app_...],threshold,per: fingerprint,notify) match #821.
Non-blocking
ErrorApp.listandErrorGroup.listwithauto_paginate=Truestop whenlen(result) < pageSize. The server clampspageSizeto 200, so passingpageSize=500returns only the first page.Monitor.listbehaves the same way. You could clamppageSizeclient-side or paginate onpage_count.- The REST helpers call
resp.json()without a guard, and network failures surface asrequestsexceptions rather than package exceptions. This matches the existingMonitorcode, but you could wrap a non-JSON 2xx body (for example a proxy error page) inAPIError. cronitor.ingest_urlonly changes the ping host; the envelope host comes from the DSN. The README states this correctly, but the name suggests it also controls error ingest. Consider a short note in the docstring or the env-var docs.ErrorGroup.event()raisesErrorGroupNotFoundfor a missing event. That's acceptable because both share the 404, but the exception name may surprise users.
I found no comments that narrate old behavior.
Verdict: REQUEST CHANGES
Interrogate + Review R1 (Gemini 4 Neon Medium)HEAD: 045f0eb IntentAdds native Cronitor Error Tracking support for
Verification Run
FindingsNO VERIFIED FINDINGS Dropped
Verdict: APPROVE |
The backend accepts window as an integer or a string like 5m, not "5 minutes", so a copied README example would fail apply_config.
|
Follow-up on the Claude Opus 5.5 Medium review at 045f0eb: Fixed in 9d073b6:
Skipped, with reasons:
|
aflanagan
left a comment
There was a problem hiding this comment.
Claude Opus 5.5 Medium (delta review)
Range reviewed: 045f0eb..9d073b6 (README.md, cronitor/init.py; 3 lines changed)
Previous blocking finding: fixed
- The README
errors:YAML example now sayswindow: 5m(README.md:309) instead ofwindow: 5 minutes.5mmatches the backend'sparse_spike_windowpattern (^(\d+)\s*m?$) and is the same form the backend writes back out, soapply_configwon't reject it anymore.
Clarifications: done
- The package-config docs now say
cronitor.ingest_urlis the host for telemetry pings only, and that error envelopes use the host incronitor.dsn. That matches how the transport works: envelopes go to the DSN's host and never fall back toingest_url. - There's a short inline comment on
ingest_urlincronitor/__init__.pythat says the same thing. It describes current behavior.
Non-blocking notes I raised before
The PR comment says these were skipped because they work the same way as the existing Monitor helpers (pagination clamp, unwrapped resp.json() and network errors, ErrorGroupNotFound for a missing event). That's a reasonable call for this PR, and I don't need any changes for them.
Verification
uv run --with pyyaml --with requests --with pytest pytest -q: 116 passed, 7 skipped (the skipped ones are the live integration tests) at 9d073b6.
New findings
None. The delta only touches docs and a comment, so runtime behavior is unchanged.
Verdict: APPROVE
Interrogate R2 regression-only (Gemini 4 Neon Medium)HEAD: 9d073b6 Scope Checked
NO VERIFIED FINDINGS Verdict: APPROVE |
Cronitor SDKs now take ingest_key and optional ingest_url, and post to /e. DSN config still works but is no longer the documented path.
|
Posts envelopes to |
|
Interrogate R3 regression-only (final allowed round) (local fallback, Grok 4.7 pending: cloud seats paused) on 3c5ec1b (adversary: Gemini 4 Neon Medium via agy on the mini) IntentSwitch native error capture to post gzipped Sentry envelopes to Prior findings
FindingsNone. Verification run:
Dropped
NO VERIFIED FINDINGS |
aflanagan
left a comment
There was a problem hiding this comment.
Gemini 4 Neon Medium (agy on the mini), review of 3c5ec1b
Verdict: APPROVE
No findings.
Checked git diff 9d073b633..HEAD (README.md, cronitor/__init__.py, cronitor/errors.py, cronitor/ingest.py, cronitor/tests/test_errors.py, cronitor/tests/test_ingest.py). Verified credentials_from_key, parse_dsn, and Transport._resolve_dsn route envelopes to {ingest_url}/e with X-Sentry-Auth sentry_key, keep cronitor.dsn working as a fallback, and add no new environment variables. Ran uv run --with pyyaml --with requests --with pytest pytest -q: 117 passed, 7 skipped.
Summary
Adds native error tracking to
cronitor-python4.10.0. There are no new dependencies.cronitor.ingest_keyto an Error App's ingest key.cronitor.ingest_urlis optional and defaults tohttps://cronitor.link(CRONITOR_INGEST_URL). Events go toPOST {ingest_url}/eas gzipped Sentry envelopes, authenticated by the ingest key inX-Sentry-Auth. A Sentry-style DSN incronitor.dsnis still accepted but no longer documented.cronitor.capture_exception(exc=None, *, monitor=None, series=None, level='error', tags=None, extra=None, fingerprint=None)cronitor.capture_message(message, level='info', ...)Monitor.capture_exceptionandMonitor.capture_message, bound to the monitor and its environment.Each returns the event id, or
Nonewhen nothing was sent.cronitor.release(CRONITOR_RELEASE) and the environment. Local variables are never sent.fingerprintaccepts a string or a list.cronitor.flush(timeout=2.0)also runs at exit. It never raises into application code.@cronitor.jobauto-capture: on by default (cronitor.capture_exceptions). It can be turned off per job withcapture_exceptions=False. It sends afailping, then an unhandled-exception event bound to the same monitor and run series.cronitor.ErrorApp:create,list,data,update,delete, androtate_key, which refreshesingest_key.cronitor.ErrorGroup:listwith filters and pagination,data,update,events, andevent.type=errorsmonitors work incronitor.yaml(errors:),apply_configandMonitor.put.Testing
python3 -m pytest: green on 3.11 to 3.15 in CI.