Skip to content

Commit eb75f0b

Browse files
authored
Merge pull request #177 from tacerus/sentry
feat(deps): import sentry-sdk only if needed
2 parents 1432d76 + 1099327 commit eb75f0b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

powerdns_api_proxy/proxy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
from http import HTTPStatus
44
from typing import Literal
55

6-
import sentry_sdk
76
from fastapi import APIRouter, Depends, FastAPI, Header, Request, Response
87
from fastapi.responses import HTMLResponse, JSONResponse
98
from prometheus_fastapi_instrumentator import Instrumentator, metrics
10-
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
11-
from sentry_sdk.integrations.fastapi import FastApiIntegration
129
from starlette.exceptions import HTTPException as StarletteHTTPException
1310

1411
from powerdns_api_proxy.config import (
@@ -39,6 +36,10 @@
3936
from powerdns_api_proxy.pdns import PDNSConnector, handle_pdns_response
4037

4138
if os.getenv("SENTRY_DSN"):
39+
import sentry_sdk
40+
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
41+
from sentry_sdk.integrations.fastapi import FastApiIntegration
42+
4243
sentry_sdk.init(
4344
traces_sample_rate=float(os.getenv("SENTRY_TRACES_SAMPLE_RATE") or 0.1),
4445
environment=os.getenv("ENVIRONMENT") or "DEV",

0 commit comments

Comments
 (0)