Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Errors in guest_api were not reported on Sentry #425

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions guest_api/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
from typing import Optional

import aiohttp
from aiohttp import web
import aioredis
from aiohttp import web
from setproctitle import setproctitle

try:
import sentry_sdk
except ImportError:
sentry_sdk = None

logger = logging.getLogger(__name__)

ALEPH_API_SERVER = "https://official.aleph.cloud"
Expand Down Expand Up @@ -155,7 +160,23 @@ async def list_keys_from_cache(request: web.Request):
return web.json_response(keys)


def run_guest_api(unix_socket_path, vm_hash: Optional[str] = None):
def run_guest_api(
unix_socket_path,
vm_hash: Optional[str] = None,
sentry_dsn: Optional[str] = None,
server_name: Optional[str] = None,
):
# This function runs in a separate process, requiring to reinitialize the Sentry SDK
if sentry_sdk and sentry_dsn:
sentry_sdk.init(
dsn=sentry_dsn,
server_name=server_name,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=1.0,
)

setproctitle(f"aleph-vm guest_api on {unix_socket_path}")
app = web.Application()
app["meta_vm_hash"] = vm_hash or "_"
Expand Down
2 changes: 1 addition & 1 deletion vm_supervisor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def main():
traces_sample_rate=1.0,
)
else:
logger.debug("Sentry SDK found with no DNS configured.")
logger.debug("Sentry SDK found with no DSN configured.")
else:
logger.debug(
"Sentry SDK not found. \n"
Expand Down
3 changes: 2 additions & 1 deletion vm_supervisor/vm/firecracker/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ async def start_guest_api(self):
vsock_path = f"{self.fvm.vsock_path}_53"
vm_hash = self.vm_hash
self.guest_api_process = Process(
target=run_guest_api, args=(vsock_path, vm_hash)
target=run_guest_api,
args=(vsock_path, vm_hash, settings.SENTRY_DSN, settings.DOMAIN_NAME),
)
self.guest_api_process.start()
while not exists(vsock_path):
Expand Down