-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathserver.py
2036 lines (1810 loc) · 71.7 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
These settings act as the default (base) settings for the Sentry-provided web-server
"""
from __future__ import absolute_import
from django.conf.global_settings import * # NOQA
import os
import os.path
import re
import socket
import sys
import tempfile
import sentry
from sentry.utils.types import type_from_value
from datetime import timedelta
from six.moves.urllib.parse import urlparse
def gettext_noop(s):
return s
socket.setdefaulttimeout(5)
def env(key, default="", type=None):
"""
Extract an environment variable for use in configuration
:param key: The environment variable to be extracted.
:param default: The value to be returned if `key` is not found.
:param type: The type of the returned object (defaults to the type of `default`).
:return: The environment variable if it exists, else `default`.
"""
# First check an internal cache, so we can `pop` multiple times
# without actually losing the value.
try:
rv = env._cache[key]
except KeyError:
if "SENTRY_RUNNING_UWSGI" in os.environ:
# We do this so when the process forks off into uwsgi
# we want to actually be popping off values. This is so that
# at runtime, the variables aren't actually available.
fn = os.environ.pop
else:
fn = os.environ.__getitem__
try:
rv = fn(key)
env._cache[key] = rv
except KeyError:
rv = default
if type is None:
type = type_from_value(default)
return type(rv)
env._cache = {}
ENVIRONMENT = os.environ.get("SENTRY_ENVIRONMENT", "production")
IS_DEV = ENVIRONMENT == "development"
DEBUG = IS_DEV
MAINTENANCE = False
ADMINS = ()
# Hosts that are considered in the same network (including VPNs).
INTERNAL_IPS = ()
# List of IP subnets which should not be accessible
SENTRY_DISALLOWED_IPS = ()
# When resolving DNS for external sources (source map fetching, webhooks, etc),
# ensure that domains are fully resolved first to avoid poking internal
# search domains.
SENTRY_ENSURE_FQDN = False
# Hosts that are allowed to use system token authentication.
# http://en.wikipedia.org/wiki/Reserved_IP_addresses
INTERNAL_SYSTEM_IPS = (
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/29",
"192.0.2.0/24",
"192.88.99.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"224.0.0.0/4",
"240.0.0.0/4",
"255.255.255.255/32",
)
MANAGERS = ADMINS
APPEND_SLASH = True
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), os.pardir))
# XXX(dcramer): handle case when we've installed from source vs just running
# this straight out of the repository
if "site-packages" in __file__:
NODE_MODULES_ROOT = os.path.join(PROJECT_ROOT, "node_modules")
else:
NODE_MODULES_ROOT = os.path.join(PROJECT_ROOT, os.pardir, os.pardir, "node_modules")
NODE_MODULES_ROOT = os.path.normpath(NODE_MODULES_ROOT)
DEVSERVICES_CONFIG_DIR = os.path.normpath(
os.path.join(PROJECT_ROOT, os.pardir, os.pardir, "config")
)
CLICKHOUSE_CONFIG_PATH = os.path.join(DEVSERVICES_CONFIG_DIR, "clickhouse", "config.xml")
RELAY_CONFIG_DIR = os.path.join(DEVSERVICES_CONFIG_DIR, "relay")
SYMBOLICATOR_CONFIG_DIR = os.path.join(DEVSERVICES_CONFIG_DIR, "symbolicator")
sys.path.insert(0, os.path.normpath(os.path.join(PROJECT_ROOT, os.pardir)))
DATABASES = {
"default": {
"ENGINE": "sentry.db.postgres",
"NAME": "sentry",
"USER": "postgres",
"PASSWORD": "",
"HOST": "127.0.0.1",
"PORT": "",
"AUTOCOMMIT": True,
"ATOMIC_REQUESTS": False,
}
}
if "DATABASE_URL" in os.environ:
url = urlparse(os.environ["DATABASE_URL"])
# Ensure default database exists.
DATABASES["default"] = DATABASES.get("default", {})
# Update with environment configuration.
DATABASES["default"].update(
{
"NAME": url.path[1:],
"USER": url.username,
"PASSWORD": url.password,
"HOST": url.hostname,
"PORT": url.port,
}
)
if url.scheme == "postgres":
DATABASES["default"]["ENGINE"] = "sentry.db.postgres"
# This should always be UTC.
TIME_ZONE = "UTC"
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "en-us"
LANGUAGES = (
("af", gettext_noop("Afrikaans")),
("ar", gettext_noop("Arabic")),
("az", gettext_noop("Azerbaijani")),
("bg", gettext_noop("Bulgarian")),
("be", gettext_noop("Belarusian")),
("bn", gettext_noop("Bengali")),
("br", gettext_noop("Breton")),
("bs", gettext_noop("Bosnian")),
("ca", gettext_noop("Catalan")),
("cs", gettext_noop("Czech")),
("cy", gettext_noop("Welsh")),
("da", gettext_noop("Danish")),
("de", gettext_noop("German")),
("el", gettext_noop("Greek")),
("en", gettext_noop("English")),
("eo", gettext_noop("Esperanto")),
("es", gettext_noop("Spanish")),
("et", gettext_noop("Estonian")),
("eu", gettext_noop("Basque")),
("fa", gettext_noop("Persian")),
("fi", gettext_noop("Finnish")),
("fr", gettext_noop("French")),
("ga", gettext_noop("Irish")),
("gl", gettext_noop("Galician")),
("he", gettext_noop("Hebrew")),
("hi", gettext_noop("Hindi")),
("hr", gettext_noop("Croatian")),
("hu", gettext_noop("Hungarian")),
("ia", gettext_noop("Interlingua")),
("id", gettext_noop("Indonesian")),
("is", gettext_noop("Icelandic")),
("it", gettext_noop("Italian")),
("ja", gettext_noop("Japanese")),
("ka", gettext_noop("Georgian")),
("kk", gettext_noop("Kazakh")),
("km", gettext_noop("Khmer")),
("kn", gettext_noop("Kannada")),
("ko", gettext_noop("Korean")),
("lb", gettext_noop("Luxembourgish")),
("lt", gettext_noop("Lithuanian")),
("lv", gettext_noop("Latvian")),
("mk", gettext_noop("Macedonian")),
("ml", gettext_noop("Malayalam")),
("mn", gettext_noop("Mongolian")),
("my", gettext_noop("Burmese")),
("nb", gettext_noop("Norwegian Bokmal")),
("ne", gettext_noop("Nepali")),
("nl", gettext_noop("Dutch")),
("nn", gettext_noop("Norwegian Nynorsk")),
("os", gettext_noop("Ossetic")),
("pa", gettext_noop("Punjabi")),
("pl", gettext_noop("Polish")),
("pt", gettext_noop("Portuguese")),
("pt-br", gettext_noop("Brazilian Portuguese")),
("ro", gettext_noop("Romanian")),
("ru", gettext_noop("Russian")),
("sk", gettext_noop("Slovak")),
("sl", gettext_noop("Slovenian")),
("sq", gettext_noop("Albanian")),
("sr", gettext_noop("Serbian")),
("sv-se", gettext_noop("Swedish")),
("sw", gettext_noop("Swahili")),
("ta", gettext_noop("Tamil")),
("te", gettext_noop("Telugu")),
("th", gettext_noop("Thai")),
("tr", gettext_noop("Turkish")),
("tt", gettext_noop("Tatar")),
("udm", gettext_noop("Udmurt")),
("uk", gettext_noop("Ukrainian")),
("ur", gettext_noop("Urdu")),
("vi", gettext_noop("Vietnamese")),
("zh-cn", gettext_noop("Simplified Chinese")),
("zh-tw", gettext_noop("Traditional Chinese")),
)
from .locale import CATALOGS
LANGUAGES = tuple((code, name) for code, name in LANGUAGES if code in CATALOGS)
SUPPORTED_LANGUAGES = frozenset(CATALOGS)
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
USE_TZ = True
# CAVEAT: If you're adding a middleware that modifies a response's content,
# and appears before CommonMiddleware, you must either reorder your middleware
# so that responses aren't modified after Content-Length is set, or have the
# response modifying middleware reset the Content-Length header.
# This is because CommonMiddleware Sets the Content-Length header for non-streaming responses.
MIDDLEWARE_CLASSES = (
"sentry.middleware.proxy.DecompressBodyMiddleware",
"sentry.middleware.security.SecurityHeadersMiddleware",
"sentry.middleware.maintenance.ServicesUnavailableMiddleware",
"sentry.middleware.env.SentryEnvMiddleware",
"sentry.middleware.proxy.SetRemoteAddrFromForwardedFor",
"sentry.middleware.debug.NoIfModifiedSinceMiddleware",
"sentry.middleware.stats.RequestTimingMiddleware",
"sentry.middleware.stats.ResponseCodeMiddleware",
"sentry.middleware.health.HealthCheck", # Must exist before CommonMiddleware
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"sentry.middleware.auth.AuthenticationMiddleware",
"sentry.middleware.user.UserActiveMiddleware",
"sentry.middleware.sudo.SudoMiddleware",
"sentry.middleware.superuser.SuperuserMiddleware",
"sentry.middleware.locale.SentryLocaleMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
)
ROOT_URLCONF = "sentry.conf.urls"
# TODO(joshuarli): Django 1.10 introduced this option, which restricts the size of a
# request body. We have some middleware in sentry.middleware.proxy that sets the
# Content Length to max uint32 in certain cases related to minidump.
# Once relay's fully rolled out, that can be deleted.
# Until then, the safest and easiest thing to do is to disable this check
# to leave things the way they were with Django <1.9.
DATA_UPLOAD_MAX_MEMORY_SIZE = None
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(PROJECT_ROOT, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django.template.context_processors.csrf",
"django.template.context_processors.request",
]
},
}
]
INSTALLED_APPS = (
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.sites",
"crispy_forms",
"rest_framework",
"sentry",
"sentry.analytics",
"sentry.incidents.apps.Config",
"sentry.discover",
"sentry.analytics.events",
"sentry.nodestore",
"sentry.search",
"sentry.snuba",
"sentry.lang.java.apps.Config",
"sentry.lang.javascript.apps.Config",
"sentry.lang.native.apps.Config",
"sentry.plugins.sentry_interface_types.apps.Config",
"sentry.plugins.sentry_urls.apps.Config",
"sentry.plugins.sentry_useragents.apps.Config",
"sentry.plugins.sentry_webhooks.apps.Config",
"social_auth",
"sudo",
"sentry.eventstream",
"sentry.auth.providers.google.apps.Config",
"django.contrib.staticfiles",
)
# Silence internal hints from Django's system checks
SILENCED_SYSTEM_CHECKS = (
# Django recommends to use OneToOneField over ForeignKey(unique=True)
# however this changes application behavior in ways that break association
# loading
"fields.W342",
# We have a "catch-all" react_page_view that we only want to match on URLs
# ending with a `/` to allow APPEND_SLASHES to kick in for the ones lacking
# the trailing slash. This confuses the warning as the regex is `/$` which
# looks like it starts with a slash but it doesn't.
"urls.W002",
)
STATIC_ROOT = os.path.realpath(os.path.join(PROJECT_ROOT, "static"))
STATIC_URL = "/_static/{version}/"
# various middleware will use this to identify resources which should not access
# cookies
ANONYMOUS_STATIC_PREFIXES = (
"/_static/",
"/avatar/",
"/organization-avatar/",
"/team-avatar/",
"/project-avatar/",
"/js-sdk-loader/",
)
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
)
ASSET_VERSION = 0
# setup a default media root to somewhere useless
MEDIA_ROOT = "/tmp/sentry-media"
LOCALE_PATHS = (os.path.join(PROJECT_ROOT, "locale"),)
CSRF_FAILURE_VIEW = "sentry.web.frontend.csrf_failure.view"
CSRF_COOKIE_NAME = "sc"
# Auth configuration
from django.core.urlresolvers import reverse_lazy
LOGIN_REDIRECT_URL = reverse_lazy("sentry-login-redirect")
LOGIN_URL = reverse_lazy("sentry-login")
AUTHENTICATION_BACKENDS = (
"sentry.utils.auth.EmailAuthBackend",
# The following authentication backends are used by social auth only.
# We don't use them for user authentication.
"social_auth.backends.asana.AsanaBackend",
"social_auth.backends.github.GithubBackend",
"social_auth.backends.bitbucket.BitbucketBackend",
"social_auth.backends.visualstudio.VisualStudioBackend",
)
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "sentry.auth.password_validation.MinimumLengthValidator",
"OPTIONS": {"min_length": 6},
},
{
"NAME": "sentry.auth.password_validation.MaximumLengthValidator",
"OPTIONS": {"max_length": 256},
},
]
SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL = "sentry.User"
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
SESSION_COOKIE_NAME = "sentrysid"
SESSION_SERIALIZER = "django.contrib.sessions.serializers.PickleSerializer"
GOOGLE_OAUTH2_CLIENT_ID = ""
GOOGLE_OAUTH2_CLIENT_SECRET = ""
BITBUCKET_CONSUMER_KEY = ""
BITBUCKET_CONSUMER_SECRET = ""
ASANA_CLIENT_ID = ""
ASANA_CLIENT_SECRET = ""
VISUALSTUDIO_APP_ID = ""
VISUALSTUDIO_APP_SECRET = ""
VISUALSTUDIO_CLIENT_SECRET = ""
VISUALSTUDIO_SCOPES = ["vso.work_write", "vso.project", "vso.code", "vso.release"]
SOCIAL_AUTH_PIPELINE = (
"social_auth.backends.pipeline.user.get_username",
"social_auth.backends.pipeline.social.social_auth_user",
"social_auth.backends.pipeline.associate.associate_by_email",
"social_auth.backends.pipeline.misc.save_status_to_session",
"social_auth.backends.pipeline.social.associate_user",
"social_auth.backends.pipeline.social.load_extra_data",
"social_auth.backends.pipeline.user.update_user_details",
"social_auth.backends.pipeline.misc.save_status_to_session",
)
SOCIAL_AUTH_REVOKE_TOKENS_ON_DISCONNECT = True
SOCIAL_AUTH_LOGIN_REDIRECT_URL = "/account/settings/identities/"
SOCIAL_AUTH_ASSOCIATE_ERROR_URL = SOCIAL_AUTH_LOGIN_REDIRECT_URL
INITIAL_CUSTOM_USER_MIGRATION = "0108_fix_user"
# Auth engines and the settings required for them to be listed
AUTH_PROVIDERS = {
"github": ("GITHUB_APP_ID", "GITHUB_API_SECRET"),
"bitbucket": ("BITBUCKET_CONSUMER_KEY", "BITBUCKET_CONSUMER_SECRET"),
"asana": ("ASANA_CLIENT_ID", "ASANA_CLIENT_SECRET"),
"visualstudio": (
"VISUALSTUDIO_APP_ID",
"VISUALSTUDIO_APP_SECRET",
"VISUALSTUDIO_CLIENT_SECRET",
),
}
AUTH_PROVIDER_LABELS = {
"github": "GitHub",
"bitbucket": "Bitbucket",
"asana": "Asana",
"visualstudio": "Visual Studio",
}
import random
def SOCIAL_AUTH_DEFAULT_USERNAME():
return random.choice(["Darth Vader", "Obi-Wan Kenobi", "R2-D2", "C-3PO", "Yoda"])
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ["email"]
SOCIAL_AUTH_FORCE_POST_DISCONNECT = True
# Queue configuration
from kombu import Exchange, Queue
BROKER_URL = "redis://127.0.0.1:6379"
BROKER_TRANSPORT_OPTIONS = {}
# Ensure workers run async by default
# in Development you might want them to run in-process
# though it would cause timeouts/recursions in some cases
CELERY_ALWAYS_EAGER = False
# We use the old task protocol because during benchmarking we noticed that it's faster
# than the new protocol. If we ever need to bump this it should be fine, there were no
# compatibility issues, just need to run benchmarks and do some tests to make sure
# things run ok.
CELERY_TASK_PROTOCOL = 1
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
CELERY_IGNORE_RESULT = True
CELERY_SEND_EVENTS = False
CELERY_RESULT_BACKEND = None
CELERY_TASK_RESULT_EXPIRES = 1
CELERY_DISABLE_RATE_LIMITS = True
CELERY_DEFAULT_QUEUE = "default"
CELERY_DEFAULT_EXCHANGE = "default"
CELERY_DEFAULT_EXCHANGE_TYPE = "direct"
CELERY_DEFAULT_ROUTING_KEY = "default"
CELERY_CREATE_MISSING_QUEUES = True
CELERY_REDIRECT_STDOUTS = False
CELERYD_HIJACK_ROOT_LOGGER = False
CELERY_TASK_SERIALIZER = "pickle"
CELERY_RESULT_SERIALIZER = "pickle"
CELERY_ACCEPT_CONTENT = {"pickle"}
CELERY_IMPORTS = (
"sentry.data_export.tasks",
"sentry.discover.tasks",
"sentry.incidents.tasks",
"sentry.tasks.assemble",
"sentry.tasks.auth",
"sentry.tasks.auto_resolve_issues",
"sentry.tasks.beacon",
"sentry.tasks.check_auth",
"sentry.tasks.check_monitors",
"sentry.tasks.clear_expired_snoozes",
"sentry.tasks.collect_project_platforms",
"sentry.tasks.commits",
"sentry.tasks.deletion",
"sentry.tasks.digests",
"sentry.tasks.email",
"sentry.tasks.files",
"sentry.tasks.integrations",
"sentry.tasks.members",
"sentry.tasks.merge",
"sentry.tasks.options",
"sentry.tasks.ping",
"sentry.tasks.post_process",
"sentry.tasks.process_buffer",
"sentry.tasks.reports",
"sentry.tasks.reprocessing",
"sentry.tasks.scheduler",
"sentry.tasks.sentry_apps",
"sentry.tasks.servicehooks",
"sentry.tasks.signals",
"sentry.tasks.store",
"sentry.tasks.unmerge",
"sentry.tasks.update_user_reports",
"sentry.tasks.relay",
"sentry.tasks.release_registry",
)
CELERY_QUEUES = [
Queue("activity.notify", routing_key="activity.notify"),
Queue("alerts", routing_key="alerts"),
Queue("app_platform", routing_key="app_platform"),
Queue("auth", routing_key="auth"),
Queue("assemble", routing_key="assemble"),
Queue("buffers.process_pending", routing_key="buffers.process_pending"),
Queue("commits", routing_key="commits"),
Queue("cleanup", routing_key="cleanup"),
Queue("data_export", routing_key="data_export"),
Queue("default", routing_key="default"),
Queue("digests.delivery", routing_key="digests.delivery"),
Queue("digests.scheduling", routing_key="digests.scheduling"),
Queue("email", routing_key="email"),
Queue("events.preprocess_event", routing_key="events.preprocess_event"),
Queue(
"events.reprocessing.preprocess_event", routing_key="events.reprocessing.preprocess_event"
),
Queue("events.symbolicate_event", routing_key="events.symbolicate_event"),
Queue(
"events.reprocessing.symbolicate_event", routing_key="events.reprocessing.symbolicate_event"
),
Queue("events.process_event", routing_key="events.process_event"),
Queue("events.reprocessing.process_event", routing_key="events.reprocessing.process_event"),
Queue("events.reprocess_events", routing_key="events.reprocess_events"),
Queue("events.save_event", routing_key="events.save_event"),
Queue("files.delete", routing_key="files.delete"),
Queue("incidents", routing_key="incidents"),
Queue("incident_snapshots", routing_key="incident_snapshots"),
Queue("integrations", routing_key="integrations"),
Queue("merge", routing_key="merge"),
Queue("options", routing_key="options"),
Queue("relay_config", routing_key="relay_config"),
Queue("reports.deliver", routing_key="reports.deliver"),
Queue("reports.prepare", routing_key="reports.prepare"),
Queue("search", routing_key="search"),
Queue("sleep", routing_key="sleep"),
Queue("stats", routing_key="stats"),
Queue("subscriptions", routing_key="subscriptions"),
Queue("unmerge", routing_key="unmerge"),
Queue("update", routing_key="update"),
]
for queue in CELERY_QUEUES:
queue.durable = False
CELERY_ROUTES = ("sentry.queue.routers.SplitQueueRouter",)
def create_partitioned_queues(name):
exchange = Exchange(name, type="direct")
for num in range(1):
CELERY_QUEUES.append(Queue(u"{0}-{1}".format(name, num), exchange=exchange))
create_partitioned_queues("counters")
create_partitioned_queues("triggers")
from celery.schedules import crontab
# XXX: Make sure to register the monitor_id for each job in `SENTRY_CELERYBEAT_MONITORS`!
CELERYBEAT_SCHEDULE_FILENAME = os.path.join(tempfile.gettempdir(), "sentry-celerybeat")
CELERYBEAT_SCHEDULE = {
"check-auth": {
"task": "sentry.tasks.check_auth",
"schedule": timedelta(minutes=1),
"options": {"expires": 60, "queue": "auth"},
},
"enqueue-scheduled-jobs": {
"task": "sentry.tasks.enqueue_scheduled_jobs",
"schedule": timedelta(minutes=1),
"options": {"expires": 60},
},
"send-beacon": {
"task": "sentry.tasks.send_beacon",
"schedule": timedelta(hours=1),
"options": {"expires": 3600},
},
"send-ping": {
"task": "sentry.tasks.send_ping",
"schedule": timedelta(minutes=1),
"options": {"expires": 60},
},
"flush-buffers": {
"task": "sentry.tasks.process_buffer.process_pending",
"schedule": timedelta(seconds=10),
"options": {"expires": 10, "queue": "buffers.process_pending"},
},
"sync-options": {
"task": "sentry.tasks.options.sync_options",
"schedule": timedelta(seconds=10),
"options": {"expires": 10, "queue": "options"},
},
"schedule-digests": {
"task": "sentry.tasks.digests.schedule_digests",
"schedule": timedelta(seconds=30),
"options": {"expires": 30},
},
"check-monitors": {
"task": "sentry.tasks.check_monitors",
"schedule": timedelta(minutes=1),
"options": {"expires": 60},
},
"clear-expired-snoozes": {
"task": "sentry.tasks.clear_expired_snoozes",
"schedule": timedelta(minutes=5),
"options": {"expires": 300},
},
"clear-expired-raw-events": {
"task": "sentry.tasks.clear_expired_raw_events",
"schedule": timedelta(minutes=15),
"options": {"expires": 300},
},
"collect-project-platforms": {
"task": "sentry.tasks.collect_project_platforms",
"schedule": timedelta(days=1),
"options": {"expires": 3600 * 24},
},
"update-user-reports": {
"task": "sentry.tasks.update_user_reports",
"schedule": timedelta(minutes=15),
"options": {"expires": 300},
},
"schedule-auto-resolution": {
"task": "sentry.tasks.schedule_auto_resolution",
"schedule": timedelta(minutes=15),
"options": {"expires": 60 * 25},
},
"schedule-deletions": {
"task": "sentry.tasks.deletion.run_scheduled_deletions",
"schedule": timedelta(minutes=15),
"options": {"expires": 60 * 25},
},
"schedule-weekly-organization-reports": {
"task": "sentry.tasks.reports.prepare_reports",
"schedule": crontab(
minute=0, hour=12, day_of_week="monday" # 05:00 PDT, 09:00 EDT, 12:00 UTC
),
"options": {"expires": 60 * 60 * 3},
},
"schedule-vsts-integration-subscription-check": {
"task": "sentry.tasks.integrations.kickoff_vsts_subscription_check",
"schedule": timedelta(hours=6),
"options": {"expires": 60 * 25},
},
"process_pending_incident_snapshots": {
"task": "sentry.incidents.tasks.process_pending_incident_snapshots",
"schedule": timedelta(hours=1),
"options": {"expires": 3600, "queue": "incidents"},
},
"fetch-release-registry-data": {
"task": "sentry.tasks.release_registry.fetch_release_registry_data",
"schedule": timedelta(minutes=5),
"options": {"expires": 3600},
},
}
BGTASKS = {
"sentry.bgtasks.clean_dsymcache:clean_dsymcache": {"interval": 5 * 60, "roles": ["worker"]},
"sentry.bgtasks.clean_releasefilecache:clean_releasefilecache": {
"interval": 5 * 60,
"roles": ["worker"],
},
}
# Sentry logs to two major places: stdout, and it's internal project.
# To disable logging to the internal project, add a logger who's only
# handler is 'console' and disable propagating upwards.
# Additionally, Sentry has the ability to override logger levels by
# providing the cli with -l/--loglevel or the SENTRY_LOG_LEVEL env var.
# The loggers that it overrides are root and any in LOGGING.overridable.
# Be very careful with this in a production system, because the celery
# logger can be extremely verbose when given INFO or DEBUG.
LOGGING = {
"default_level": "INFO",
"version": 1,
"disable_existing_loggers": True,
"handlers": {
"null": {"class": "logging.NullHandler"},
"console": {"class": "sentry.logging.handlers.StructLogHandler"},
"internal": {"level": "ERROR", "class": "sentry_sdk.integrations.logging.EventHandler"},
"metrics": {
"level": "WARNING",
"filters": ["important_django_request"],
"class": "sentry.logging.handlers.MetricsLogHandler",
},
"django_internal": {
"level": "WARNING",
"filters": ["important_django_request"],
"class": "sentry_sdk.integrations.logging.EventHandler",
},
},
"filters": {
"important_django_request": {
"()": "sentry.logging.handlers.MessageContainsFilter",
"contains": ["CSRF"],
}
},
"root": {"level": "NOTSET", "handlers": ["console", "internal"]},
# LOGGING.overridable is a list of loggers including root that will change
# based on the overridden level defined above.
"overridable": ["celery", "sentry"],
"loggers": {
"celery": {"level": "WARNING"},
"sentry": {"level": "INFO"},
"sentry_plugins": {"level": "INFO"},
"sentry.files": {"level": "WARNING"},
"sentry.minidumps": {"handlers": ["internal"], "propagate": False},
"sentry.reprocessing": {"handlers": ["internal"], "propagate": False},
"sentry.interfaces": {"handlers": ["internal"], "propagate": False},
# This only needs to go to Sentry for now.
"sentry.similarity": {"handlers": ["internal"], "propagate": False},
"sentry.errors": {"handlers": ["console"], "propagate": False},
"sentry_sdk.errors": {"handlers": ["console"], "level": "INFO", "propagate": False},
"sentry.rules": {"handlers": ["console"], "propagate": False},
"multiprocessing": {
"handlers": ["console"],
# https://github.com/celery/celery/commit/597a6b1f3359065ff6dbabce7237f86b866313df
# This commit has not been rolled into any release and leads to a
# large amount of errors when working with postgres.
"level": "CRITICAL",
"propagate": False,
},
"celery.worker.job": {"handlers": ["console"], "propagate": False},
"static_compiler": {"level": "INFO"},
"django.request": {
"level": "WARNING",
"handlers": ["console", "metrics", "django_internal"],
"propagate": False,
},
"toronado": {"level": "ERROR", "handlers": ["null"], "propagate": False},
"urllib3.connectionpool": {"level": "ERROR", "handlers": ["console"], "propagate": False},
"boto3": {"level": "WARNING", "handlers": ["console"], "propagate": False},
"botocore": {"level": "WARNING", "handlers": ["console"], "propagate": False},
},
}
# django-rest-framework
REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": ["rest_framework.renderers.JSONRenderer"],
"DEFAULT_PARSER_CLASSES": [
"rest_framework.parsers.JSONParser",
"rest_framework.parsers.MultiPartParser",
"rest_framework.parsers.FormParser",
],
"TEST_REQUEST_DEFAULT_FORMAT": "json",
"DEFAULT_PERMISSION_CLASSES": ("sentry.api.permissions.NoPermission",),
"EXCEPTION_HANDLER": "sentry.api.handlers.custom_exception_handler",
}
CRISPY_TEMPLATE_PACK = "bootstrap3"
# Sentry and internal client configuration
SENTRY_FEATURES = {
# Enables user registration.
"auth:register": True,
# Enable advanced search features, like negation and wildcard matching.
"organizations:advanced-search": True,
# Enable android mappings in processing section of settings.
"organizations:android-mappings": False,
# Enable obtaining and using API keys.
"organizations:api-keys": False,
# Enable explicit use of AND and OR in search.
"organizations:boolean-search": False,
# Enable creating organizations within sentry (if SENTRY_SINGLE_ORGANIZATION
# is not enabled).
"organizations:create": True,
# Enable the 'discover' interface.
"organizations:discover": False,
# Enable attaching arbitrary files to events.
"organizations:event-attachments": True,
# Allow organizations to configure built-in symbol sources.
"organizations:symbol-sources": True,
# Allow organizations to configure custom external symbol sources.
"organizations:custom-symbol-sources": True,
# Enable the events stream interface.
"organizations:events": False,
# Enable discover 2 basic functions
"organizations:discover-basic": True,
# Enable discover 2 custom queries and saved queries
"organizations:discover-query": True,
# Enable Performance view
"organizations:performance-view": False,
# Enable Performance in the Release View
"organizations:release-performance-views": False,
# Enable multi project selection
"organizations:global-views": False,
# Lets organizations manage grouping configs
"organizations:set-grouping-config": False,
# Lets organizations set a custom title through fingerprinting
"organizations:custom-event-title": False,
# Enable rule page.
"organizations:rule-page": False,
# Enable incidents feature
"organizations:incidents": False,
# Enable metric aggregate in metric alert rule builder
"organizations:metric-alert-builder-aggregate": False,
# Enable new GUI filters in the metric alert rule builder
"organizations:metric-alert-gui-filters": False,
# Enable integration functionality to create and link groups to issues on
# external services.
"organizations:integrations-issue-basic": True,
# Enable interface functionality to synchronize groups between sentry and
# issues on external services.
"organizations:integrations-issue-sync": True,
# Enable interface functionality to receive event hooks.
"organizations:integrations-event-hooks": True,
# Enable integration functionality to work with alert rules
"organizations:integrations-alert-rule": True,
# Enable integration functionality to work with alert rules (specifically chat integrations)
"organizations:integrations-chat-unfurl": True,
# Enable integration functionality to work with alert rules (specifically incident
# management integrations)
"organizations:integrations-incident-management": True,
# Allow orgs to automatically create Tickets in Issue Alerts
"organizations:integrations-ticket-rules": False,
# Allow orgs to install AzureDevops with limited scopes
"organizations:integrations-vsts-limited-scopes": False,
# Allow orgs to use the stacktrace linking feature
"organizations:integrations-stacktrace-link": False,
# Enable data forwarding functionality for organizations.
"organizations:data-forwarding": True,
# Enable experimental performance improvements.
"organizations:enterprise-perf": False,
# Special feature flag primarily used on the sentry.io SAAS product for
# easily enabling features while in early development.
"organizations:internal-catchall": False,
# Enable inviting members to organizations.
"organizations:invite-members": True,
# Enable rate limits for inviting members.
"organizations:invite-members-rate-limits": True,
# Enable key transactions as a column in performance
"organizations:key-transactions": False,
# Enable org-wide saved searches and user pinned search
"organizations:org-saved-searches": False,
# Prefix host with organization ID when giving users DSNs (can be
# customized with SENTRY_ORG_SUBDOMAIN_TEMPLATE)
"organizations:org-subdomains": False,
# Enable the new Related Events feature
"organizations:related-events": False,
# Enable usage of external relays, for use with Relay. See
# https://github.com/getsentry/relay.
"organizations:relay": False,
# Enable basic SSO functionality, providing configurable single sign on
# using services like GitHub / Google. This is *not* the same as the signup
# and login with Github / Azure DevOps that sentry.io provides.
"organizations:sso-basic": True,
# Enable SAML2 based SSO functionality. getsentry/sentry-auth-saml2 plugin
# must be installed to use this functionality.
"organizations:sso-saml2": True,
# Enable Rippling SSO functionality.
"organizations:sso-rippling": False,
# Enable workaround for migrating IdP instances
"organizations:sso-migration": False,
# Enable transaction comparison view for performance.
"organizations:transaction-comparison": False,
# Enable graph for subscription quota for errors, transactions and
# attachments
"organizations:usage-stats-graph": False,
# Enable inbox support in the issue stream
"organizations:inbox": False,
# Return unhandled information on the issue level
"organizations:unhandled-issue-flag": False,
# Enable functionality to specify custom inbound filters on events.
"projects:custom-inbound-filters": False,
# Enable data forwarding functionality for projects.
"projects:data-forwarding": True,
# Enable functionality to discard groups.
"projects:discard-groups": False,
# DEPRECATED: pending removal
"projects:dsym": False,
# Enable selection of members, teams or code owners as email targets for issue alerts.
"projects:issue-alerts-targeting": True,
# Enable functionality for attaching minidumps to events and displaying
# then in the group UI.
"projects:minidump": True,
# Enable functionality for project plugins.
"projects:plugins": True,
# Enable functionality for rate-limiting events on projects.
"projects:rate-limits": True,
# Enable version 2 of reprocessing (completely distinct from v1)
"projects:reprocessing-v2": False,
# Enable functionality for sampling of events on projects.
"projects:sample-events": False,
# Enable functionality to trigger service hooks upon event ingestion.
"projects:servicehooks": False,
# Use Kafka (instead of Celery) for ingestion pipeline.
"projects:kafka-ingest": False,
# Don't add feature defaults down here! Please add them in their associated
# group sorted alphabetically.
}
# Default time zone for localization in the UI.
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
SENTRY_DEFAULT_TIME_ZONE = "UTC"
# Enable the Sentry Debugger (Beta)
SENTRY_DEBUGGER = None
SENTRY_IGNORE_EXCEPTIONS = ("OperationalError",)
# Should we send the beacon to the upstream server?
SENTRY_BEACON = True
# Allow access to Sentry without authentication.
SENTRY_PUBLIC = False
# Instruct Sentry that this install intends to be run by a single organization
# and thus various UI optimizations should be enabled.
SENTRY_SINGLE_ORGANIZATION = False
# Login url (defaults to LOGIN_URL)
SENTRY_LOGIN_URL = None
# Default project ID (for internal errors)
SENTRY_PROJECT = 1
SENTRY_PROJECT_KEY = None
# Default organization to represent the Internal Sentry project.
# Used as a default when in SINGLE_ORGANIZATION mode.
SENTRY_ORGANIZATION = None
# Project ID for recording frontend (javascript) exceptions
SENTRY_FRONTEND_PROJECT = None
# DSN for the frontend to use explicitly, which takes priority
# over SENTRY_FRONTEND_PROJECT or SENTRY_PROJECT
SENTRY_FRONTEND_DSN = None
# DSN for tracking all client HTTP requests (which can be noisy) [experimental]
SENTRY_FRONTEND_REQUESTS_DSN = None
# Configuration for JavaScript's whitelistUrls - defaults to ALLOWED_HOSTS
SENTRY_FRONTEND_WHITELIST_URLS = None
# ----
# APM config
# ----
# sample rate for transactions initiated from the frontend
SENTRY_APM_SAMPLING = 0
# Sample rate for symbolicate_event task transactions
SENTRY_SYMBOLICATE_EVENT_APM_SAMPLING = 0
# Sample rate for the process_event task transactions
SENTRY_PROCESS_EVENT_APM_SAMPLING = 0
# sample rate for the relay projectconfig endpoint