Skip to content

Commit 6d29ca6

Browse files
phernandezclaude
andcommitted
feat: Add optional Logfire observability to sync operations
Add Logfire as a dependency for performance instrumentation. Logfire is disabled by default (via ignore_no_config) and only activates when LOGFIRE_TOKEN is set, keeping the FOSS version telemetry-free. Changes: - Added logfire>=0.73.0 as dependency - Instrumented sync_file() and sync_markdown_file() with @logfire.instrument() - Logfire captures function arguments and timing automatically - No changes to behavior when LOGFIRE_TOKEN is not set This will help diagnose performance bottlenecks in sync operations, particularly for understanding the 28% slowdown in initial sync compared to baseline (50.4ms vs 39.3ms per file). Related: SPEC-19 Phase 1 performance analysis 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
1 parent cc3dd25 commit 6d29ca6

3 files changed

Lines changed: 218 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies = [
3535
"python-dotenv>=1.1.0",
3636
"pytest-aio>=1.9.0",
3737
"aiofiles>=24.1.0", # Async file I/O
38+
"logfire>=0.73.0", # Optional observability (disabled by default via config)
3839
]
3940

4041

src/basic_memory/sync/sync_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pathlib import Path
1010
from typing import AsyncIterator, Dict, List, Optional, Set, Tuple
1111

12+
import logfire
1213
from loguru import logger
1314
from sqlalchemy.exc import IntegrityError
1415

@@ -495,6 +496,7 @@ async def scan(self, directory):
495496
)
496497
return report
497498

499+
@logfire.instrument()
498500
async def sync_file(
499501
self, path: str, new: bool = True
500502
) -> Tuple[Optional[Entity], Optional[str]]:
@@ -549,6 +551,7 @@ async def sync_file(
549551

550552
return None, None
551553

554+
@logfire.instrument()
552555
async def sync_markdown_file(self, path: str, new: bool = True) -> Tuple[Optional[Entity], str]:
553556
"""Sync a markdown file with full processing.
554557

0 commit comments

Comments
 (0)