|
3 | 3 | # You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
|
5 | 5 | import logging |
| 6 | +import os |
6 | 7 | import sys |
| 8 | +from subprocess import check_output |
| 9 | + |
| 10 | +import sentry_sdk |
7 | 11 |
|
8 | 12 | from . import config |
9 | 13 |
|
| 14 | + |
| 15 | +def get_version(): |
| 16 | + git_tags = ( |
| 17 | + check_output(["git", "tag", "--sort=-version:refname"]) |
| 18 | + .decode("utf-8") |
| 19 | + .splitlines() |
| 20 | + ) |
| 21 | + return git_tags[0] if git_tags else None |
| 22 | + |
| 23 | + |
| 24 | +__version__ = get_version() |
| 25 | + |
| 26 | + |
| 27 | +sentry_sdk.init( |
| 28 | + dsn="https://[email protected]/4510268495101953", |
| 29 | + release=__version__, |
| 30 | + environment=os.getenv("ENVIRONMENT", "development"), |
| 31 | + dist=check_output(["git", "rev-parse", "HEAD"]).decode("utf-8").rstrip(), |
| 32 | + server_name=check_output("hostname").decode("utf-8").rstrip(), |
| 33 | + # Add data like request headers and IP for users, |
| 34 | + # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info |
| 35 | + send_default_pii=True, |
| 36 | + # Enable sending logs to Sentry |
| 37 | + enable_logs=True, |
| 38 | + # Set traces_sample_rate to 1.0 to capture 100% |
| 39 | + # of transactions for tracing. |
| 40 | + traces_sample_rate=1.0, |
| 41 | + # Set profile_session_sample_rate to 1.0 to profile 100% |
| 42 | + # of profile sessions. |
| 43 | + profile_session_sample_rate=1.0, |
| 44 | +) |
| 45 | + |
| 46 | +sentry_sdk.profiler.start_profiler() |
| 47 | + |
10 | 48 | config.load() |
11 | 49 |
|
12 | 50 | # We can remove this hack and load utils in the same line as config when we fix |
|
17 | 55 | raise |
18 | 56 |
|
19 | 57 |
|
20 | | -VERSION = (0, 0, 1) |
21 | | -__version__ = ".".join(map(str, VERSION)) |
22 | | - |
23 | | - |
24 | 58 | path = utils.get_config("common", "log") |
25 | 59 |
|
26 | 60 | logger = logging.getLogger() |
|
0 commit comments