Skip to content

Commit 3600419

Browse files
committed
docs: add local logfire smoke playbook
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 396abd0 commit 3600419

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

docs/logfire-instrumentation-strategy.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,66 @@ Add:
403403

404404
This makes the trace view and the log stream tell the same story without forcing logger rewrites across the codebase.
405405

406+
## Local Dev Playbook
407+
408+
The fastest way to sanity-check the current trace shape is:
409+
410+
```bash
411+
LOGFIRE_TOKEN=lf_... just telemetry-smoke
412+
```
413+
414+
What this does:
415+
416+
- creates an isolated temp home, config dir, and project path
417+
- enables Logfire for the run
418+
- automatically exports to Logfire when `LOGFIRE_TOKEN` is present
419+
- defaults `BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED=false` so the smoke run stays fast and trace-friendly
420+
- disables promo telemetry so the trace is about Basic Memory work, not analytics noise
421+
- runs a small CLI workflow:
422+
- `project add`
423+
- `tool write-note`
424+
- `tool search-notes`
425+
- `doctor`
426+
427+
If you want to exercise the instrumentation without exporting anything upstream:
428+
429+
```bash
430+
BASIC_MEMORY_LOGFIRE_SEND_TO_LOGFIRE=false just telemetry-smoke
431+
```
432+
433+
If you want the smoke run to include vector or hybrid retrieval spans too:
434+
435+
```bash
436+
LOGFIRE_TOKEN=lf_... BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED=true just telemetry-smoke
437+
```
438+
439+
The recipe sets `BASIC_MEMORY_LOGFIRE_ENVIRONMENT=telemetry-smoke` by default so these traces are easy to isolate in Logfire. Override it if you want the smoke traces grouped under a different environment name.
440+
441+
### What to look for
442+
443+
You should see a small set of comparable root spans rather than a framework-generated span forest:
444+
445+
- `cli.command.project`
446+
- `cli.command.tool`
447+
- `mcp.tool.write_note`
448+
- `mcp.tool.search_notes`
449+
- `sync.project.run`
450+
451+
You should also see correlated logs under those traces with stable fields like:
452+
453+
- `project_name`
454+
- `route_mode`
455+
- `tool_name`
456+
- `entrypoint`
457+
458+
### Expected nuance
459+
460+
`doctor` creates its own temporary project on purpose. That means the sync trace will usually show a different project name than the `telemetry-smoke` write/search traces. That is fine for smoke testing because the goal is to confirm:
461+
462+
- root span names are meaningful
463+
- scoped logs stay attached to the active trace
464+
- routing, tool, search, and sync phases are easy to distinguish
465+
406466
## Validation Checklist
407467

408468
We should consider the integration successful when the following are true:

justfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,48 @@ doctor:
205205
BASIC_MEMORY_CONFIG_DIR="$TMP_CONFIG" \
206206
./.venv/bin/python -m basic_memory.cli.main doctor --local
207207

208+
# Run an isolated Logfire smoke workflow for local trace inspection
209+
telemetry-smoke:
210+
#!/usr/bin/env bash
211+
set -euo pipefail
212+
TMP_HOME=$(mktemp -d)
213+
TMP_CONFIG=$(mktemp -d)
214+
TMP_PROJECT=$(mktemp -d)
215+
export HOME="$TMP_HOME"
216+
export BASIC_MEMORY_ENV="${BASIC_MEMORY_ENV:-dev}"
217+
export BASIC_MEMORY_HOME="$TMP_PROJECT/home-root"
218+
export BASIC_MEMORY_CONFIG_DIR="$TMP_CONFIG"
219+
export BASIC_MEMORY_NO_PROMOS=1
220+
export BASIC_MEMORY_LOG_LEVEL="${BASIC_MEMORY_LOG_LEVEL:-INFO}"
221+
export BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED="${BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED:-false}"
222+
export BASIC_MEMORY_LOGFIRE_ENABLED="${BASIC_MEMORY_LOGFIRE_ENABLED:-true}"
223+
export BASIC_MEMORY_LOGFIRE_ENVIRONMENT="${BASIC_MEMORY_LOGFIRE_ENVIRONMENT:-telemetry-smoke}"
224+
if [[ -z "${BASIC_MEMORY_LOGFIRE_SEND_TO_LOGFIRE:-}" ]]; then
225+
if [[ -n "${LOGFIRE_TOKEN:-}" ]]; then
226+
export BASIC_MEMORY_LOGFIRE_SEND_TO_LOGFIRE=true
227+
else
228+
export BASIC_MEMORY_LOGFIRE_SEND_TO_LOGFIRE=false
229+
fi
230+
fi
231+
mkdir -p "$BASIC_MEMORY_HOME"
232+
echo "Telemetry smoke setup:"
233+
echo " logfire_enabled=$BASIC_MEMORY_LOGFIRE_ENABLED"
234+
echo " send_to_logfire=$BASIC_MEMORY_LOGFIRE_SEND_TO_LOGFIRE"
235+
echo " log_level=$BASIC_MEMORY_LOG_LEVEL"
236+
echo " semantic_search_enabled=$BASIC_MEMORY_SEMANTIC_SEARCH_ENABLED"
237+
echo " logfire_environment=$BASIC_MEMORY_LOGFIRE_ENVIRONMENT"
238+
echo " project_path=$TMP_PROJECT"
239+
./.venv/bin/python -m basic_memory.cli.main project add telemetry-smoke "$TMP_PROJECT" --default --local
240+
./.venv/bin/python -m basic_memory.cli.main tool write-note --title "Telemetry Smoke" --folder notes --content "hello from smoke" --project telemetry-smoke --local
241+
./.venv/bin/python -m basic_memory.cli.main tool search-notes telemetry --project telemetry-smoke --local
242+
./.venv/bin/python -m basic_memory.cli.main doctor --local
243+
echo ""
244+
echo "Telemetry smoke complete."
245+
echo "Search Logfire for:"
246+
echo " service_name: basic-memory-cli"
247+
echo " environment: $BASIC_MEMORY_LOGFIRE_ENVIRONMENT"
248+
echo " span names: mcp.tool.write_note, mcp.tool.search_notes, sync.project.run"
249+
208250

209251
# Update all dependencies to latest versions
210252
update-deps:

0 commit comments

Comments
 (0)