|  | 
| 4 | 4 | 
 | 
| 5 | 5 | ### Various fixes & improvements | 
| 6 | 6 | 
 | 
| 7 |  | -- Add support for Sentry Crons to Celery Beat (#1935) by @antonpirker | 
| 8 |  | -- Add decorator for Sentry tracing (#1089) by @ynouri | 
| 9 |  | -- Added top level API to get current span (#1954) by @antonpirker | 
| 10 |  | -- feat(profiling): Add profiler options to init (#1947) by @Zylphrex | 
| 11 |  | -- Start a real http server instead of mocking libs (#1938) by @antonpirker | 
| 12 |  | -- feat(profiling): Set active thread id for quart (#1830) by @Zylphrex | 
| 13 |  | -- 🎨 Fix type annotation for ignore_errors in sentry_sdk.init() (#1928) by @tiangolo | 
| 14 |  | -- Update get_json function call for werkzeug 2.1.0+ (#1939) by @michielderoos | 
| 15 |  | -- fix: Rename MYPY to TYPE_CHECKING (#1934) by @untitaker | 
| 16 |  | -- Rename 'with_locals'  to 'include_local_variables' (#1924) by @antonpirker | 
| 17 |  | -- Returning the tasks result. (#1931) by @antonpirker | 
|  | 7 | +- **New:** Monitor Celery Beat tasks with Sentry [Cron Monitoring](https://docs.sentry.io/product/crons/). | 
|  | 8 | + | 
|  | 9 | +  With this feature you can make sure that your Celery beat tasks run at the right time and see if they where successful or not. | 
|  | 10 | + | 
|  | 11 | +  > **Warning** | 
|  | 12 | +  > Cron Monitoring is currently in beta. Beta features are still in-progress and may have bugs. We recognize the irony. | 
|  | 13 | +  > If you have any questions or feedback, please email us at crons-feedback@sentry.io, reach out via Discord (#cronjobs), or open an issue. | 
|  | 14 | +
 | 
|  | 15 | +  Usage: | 
|  | 16 | + | 
|  | 17 | +  ```python | 
|  | 18 | +  # File: tasks.py | 
|  | 19 | + | 
|  | 20 | +  from celery import Celery, signals | 
|  | 21 | +  from celery.schedules import crontab | 
|  | 22 | + | 
|  | 23 | +  import sentry_sdk | 
|  | 24 | +  from sentry_sdk.crons import monitor | 
|  | 25 | +  from sentry_sdk.integrations.celery import CeleryIntegration | 
|  | 26 | + | 
|  | 27 | + | 
|  | 28 | +  # 1. Setup your Celery beat configuration | 
|  | 29 | + | 
|  | 30 | +  app = Celery('mytasks', broker='redis://localhost:6379/0') | 
|  | 31 | +  app.conf.beat_schedule = { | 
|  | 32 | +      'set-in-beat-schedule': { | 
|  | 33 | +          'task': 'tasks.tell_the_world', | 
|  | 34 | +          'schedule': crontab(hour='10', minute='15'), | 
|  | 35 | +          'args': ("in beat_schedule set", ), | 
|  | 36 | +      }, | 
|  | 37 | +  } | 
|  | 38 | + | 
|  | 39 | + | 
|  | 40 | +  # 2. Initialize Sentry either in `celeryd_init` or `beat_init` signal. | 
|  | 41 | + | 
|  | 42 | +  #@signals.celeryd_init.connect | 
|  | 43 | +  @signals.beat_init.connect | 
|  | 44 | +  def init_sentry(**kwargs): | 
|  | 45 | +      sentry_sdk.init( | 
|  | 46 | +          dsn='...', | 
|  | 47 | +          integrations=[CeleryIntegration()], | 
|  | 48 | +          environment="local.dev.grace", | 
|  | 49 | +          release="v1.0.7-a1", | 
|  | 50 | +      ) | 
|  | 51 | + | 
|  | 52 | + | 
|  | 53 | +  # 3. Link your Celery task to a Sentry Cron Monitor | 
|  | 54 | + | 
|  | 55 | +  @app.task | 
|  | 56 | +  @monitor(monitor_slug='3b861d62-ff82-4aa0-9cd6-b2b6403bd0cf') | 
|  | 57 | +  def tell_the_world(msg): | 
|  | 58 | +      print(msg) | 
|  | 59 | +  ``` | 
|  | 60 | + | 
|  | 61 | +- **New:** Add decorator for Sentry tracing (#1089) by @ynouri | 
|  | 62 | + | 
|  | 63 | +  This allows you to use a decorator to setup custom performance instrumentation. | 
|  | 64 | + | 
|  | 65 | +  To learn more see [Custom Instrumentation](https://docs.sentry.io/platforms/python/performance/instrumentation/custom-instrumentation/). | 
|  | 66 | + | 
|  | 67 | +  Usage: Just add the new decorator to your function, and a span will be created for it: | 
|  | 68 | + | 
|  | 69 | +  ```python | 
|  | 70 | +  import sentry_sdk | 
|  | 71 | + | 
|  | 72 | +  @sentry_sdk.trace | 
|  | 73 | +  def my_complex_function(): | 
|  | 74 | +    # do stuff | 
|  | 75 | +    ... | 
|  | 76 | +  ``` | 
|  | 77 | + | 
| 18 | 78 | - Make Django signals tracing optional (#1929) by @antonpirker | 
| 19 | 79 | 
 | 
|  | 80 | +  See the [Django Guide](https://docs.sentry.io/platforms/python/guides/django) to learn more. | 
|  | 81 | + | 
|  | 82 | +- Deprecated `with_locals` in favor of `include_local_variables` (#1924) by @antonpirker | 
|  | 83 | +- Added top level API to get current span (#1954) by @antonpirker | 
|  | 84 | +- Profiling: Add profiler options to init (#1947) by @Zylphrex | 
|  | 85 | +- Profiling: Set active thread id for quart (#1830) by @Zylphrex | 
|  | 86 | +- Fix: Update `get_json` function call for werkzeug 2.1.0+ (#1939) by @michielderoos | 
|  | 87 | +- Fix: Returning the tasks result. (#1931) by @antonpirker | 
|  | 88 | +- Fix: Rename MYPY to TYPE_CHECKING (#1934) by @untitaker | 
|  | 89 | +- Fix: Fix type annotation for ignore_errors in sentry_sdk.init() (#1928) by @tiangolo | 
|  | 90 | +- Tests: Start a real http server instead of mocking libs (#1938) by @antonpirker | 
|  | 91 | + | 
| 20 | 92 | ## 1.16.0 | 
| 21 | 93 | 
 | 
| 22 | 94 | ### Various fixes & improvements | 
|  | 
0 commit comments