Add Sentry
This commit is contained in:
parent
ce78aa7e55
commit
54a36adebf
16
poetry.lock
generated
16
poetry.lock
generated
@ -131,6 +131,18 @@ d = ["aiohttp (>=3.7.4)"]
|
|||||||
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
||||||
uvloop = ["uvloop (>=0.15.2)"]
|
uvloop = ["uvloop (>=0.15.2)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "blinker"
|
||||||
|
version = "1.5"
|
||||||
|
description = "Fast, simple object-to-object and broadcast signaling"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||||
|
files = [
|
||||||
|
{file = "blinker-1.5-py2.py3-none-any.whl", hash = "sha256:1eb563df6fdbc39eeddc177d953203f99f097e9bf0e2b8f9f3cf18b6ca425e36"},
|
||||||
|
{file = "blinker-1.5.tar.gz", hash = "sha256:923e5e2f69c155f2cc42dafbbd70e16e3fde24d2d4aa2ab72fbe386238892462"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "certifi"
|
name = "certifi"
|
||||||
version = "2022.12.7"
|
version = "2022.12.7"
|
||||||
@ -1308,7 +1320,9 @@ files = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
|
blinker = {version = ">=1.1", optional = true, markers = "extra == \"flask\""}
|
||||||
certifi = "*"
|
certifi = "*"
|
||||||
|
flask = {version = ">=0.11", optional = true, markers = "extra == \"flask\""}
|
||||||
urllib3 = {version = ">=1.26.11", markers = "python_version >= \"3.6\""}
|
urllib3 = {version = ">=1.26.11", markers = "python_version >= \"3.6\""}
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
@ -1707,4 +1721,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.7"
|
python-versions = "^3.7"
|
||||||
content-hash = "e3031b5c16ad6cf25f786cf4d14f0871d0abace95d3380c1a6b14b7e1ab37756"
|
content-hash = "ea1fd278a3dc000ed3d374c9006b959014cf8f67c62c99bc4b15aeeca2e64311"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from os import getenv
|
||||||
from secrets import token_hex
|
from secrets import token_hex
|
||||||
|
|
||||||
from flask import Flask, redirect, render_template, request, url_for
|
from flask import Flask, redirect, render_template, request, url_for
|
||||||
@ -8,6 +9,25 @@ from pynyaata.bridge import search_all
|
|||||||
from pynyaata.forms import SearchForm
|
from pynyaata.forms import SearchForm
|
||||||
from pynyaata.translations import current_lang, i18n
|
from pynyaata.translations import current_lang, i18n
|
||||||
|
|
||||||
|
from sentry_sdk import init
|
||||||
|
from sentry_sdk.integrations.asyncio import AsyncioIntegration
|
||||||
|
from sentry_sdk.integrations.flask import FlaskIntegration
|
||||||
|
from sentry_sdk.integrations.redis import RedisIntegration
|
||||||
|
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
||||||
|
|
||||||
|
|
||||||
|
SENTRY_DNS = getenv("SENTRY_DSN")
|
||||||
|
if SENTRY_DNS:
|
||||||
|
init(
|
||||||
|
SENTRY_DNS,
|
||||||
|
integrations=[
|
||||||
|
AsyncioIntegration(),
|
||||||
|
FlaskIntegration(),
|
||||||
|
RedisIntegration(),
|
||||||
|
SqlalchemyIntegration(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config["SECRET_KEY"] = token_hex()
|
app.config["SECRET_KEY"] = token_hex()
|
||||||
|
@ -22,4 +22,4 @@ async def search_all(query: str = "", page: int = 1) -> List[RemoteFile]:
|
|||||||
for bridge in BRIDGES:
|
for bridge in BRIDGES:
|
||||||
tasks.append(create_task(bridge.search(query, page)))
|
tasks.append(create_task(bridge.search(query, page)))
|
||||||
|
|
||||||
return await gather(*tasks)
|
return await gather(*tasks, return_exceptions=True)
|
||||||
|
@ -27,7 +27,7 @@ class AnimeUltime(Bridge):
|
|||||||
return parse_obj_as(
|
return parse_obj_as(
|
||||||
HttpUrl,
|
HttpUrl,
|
||||||
(
|
(
|
||||||
f"{self.base_url}"
|
f"{self.base_url}/"
|
||||||
f"{'search' if query else 'history'}-0-1/"
|
f"{'search' if query else 'history'}-0-1/"
|
||||||
f"{page_date.strftime('%m%Y') if query else ''}"
|
f"{page_date.strftime('%m%Y') if query else ''}"
|
||||||
),
|
),
|
||||||
|
@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from logging import error
|
from logging import exception
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel, ByteSize, HttpUrl
|
from pydantic import BaseModel, ByteSize, HttpUrl
|
||||||
@ -72,7 +72,7 @@ def log_async(f):
|
|||||||
try:
|
try:
|
||||||
return await f(*args, **kwargs)
|
return await f(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error(e)
|
exception(e)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
@ -27,7 +27,7 @@ pydantic = "1.10.4"
|
|||||||
pymysql = "1.0.2"
|
pymysql = "1.0.2"
|
||||||
redis = "4.4.0"
|
redis = "4.4.0"
|
||||||
requests = "2.28.1"
|
requests = "2.28.1"
|
||||||
sentry-sdk = "1.12.1"
|
sentry-sdk = {extras = ["flask"], version = "1.12.1"}
|
||||||
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
Reference in New Issue
Block a user