From e5a6c59f7ad17de6f117c081ed5d768c3926a18f Mon Sep 17 00:00:00 2001 From: ThomasTaroni Date: Sat, 21 Jun 2025 22:22:21 +0200 Subject: [PATCH] Add execution time logging to smd_detail_article function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced performance tracking in the smd_detail_article function by adding execution time logging. This helps in monitoring and optimizing the function’s runtime during API requests and processing. --- src/phoenix_technologies/smd/server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/phoenix_technologies/smd/server.py b/src/phoenix_technologies/smd/server.py index 45b89a8..c5bc19d 100644 --- a/src/phoenix_technologies/smd/server.py +++ b/src/phoenix_technologies/smd/server.py @@ -10,6 +10,7 @@ import logging import aiohttp import asyncio import requests +import time from dotenv import load_dotenv from mcp.server.fastmcp import FastMCP @@ -55,6 +56,8 @@ async def summarize_to_words(text: str, title: str, target_word_count: int = 100 return await response.text() async def smd_detail_article(article_id): + logger.info("Starting smd_detail_article function.") + start_time = time.perf_counter() url = f"https://api.swissdox.ch/api/documents/{article_id}" headers = { "Authorization": f"Bearer {os.getenv('SWISSDOX_BEARER_TOKEN', '')}", @@ -67,6 +70,8 @@ async def smd_detail_article(article_id): if response.status == 200: data = await response.json() summarized_content = await summarize_to_words(title=data.get("title"), text=data.get("text"), target_word_count=10000) + execution_time = time.perf_counter() - start_time + logger.info(f"smd_detail_article executed in {execution_time:.2f} seconds.") return { "message": summarized_content, "article_id": article_id