Skip to content

Commit ca1cb77

Browse files
committed
add scout apm middleware
1 parent 436f359 commit ca1cb77

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class _Settings(BaseSettings):
1111
port: int = 5000
1212
rediscloud_url: AnyUrl = None
1313
local_redis_url: AnyUrl = None
14+
# Scout APM
15+
scout_name: str = None
1416

1517

1618
@functools.lru_cache()

app/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from fastapi.middleware.cors import CORSMiddleware
1010
from fastapi.middleware.gzip import GZipMiddleware
1111
from fastapi.responses import JSONResponse
12+
from scout_apm.async_.starlette import ScoutMiddleware
1213

1314
from .config import get_settings
1415
from .data import data_source
@@ -39,6 +40,11 @@
3940
# Middleware
4041
#######################
4142

43+
# Scout APM
44+
if SETTINGS.scout_name:
45+
LOGGER.info(f"Adding Scout APM middleware for `{SETTINGS.scout_name}`")
46+
APP.add_middleware(ScoutMiddleware)
47+
4248
# Enable CORS.
4349
APP.add_middleware(
4450
CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],

0 commit comments

Comments
 (0)