Skip to content

Commit b87ffd0

Browse files
feat: add detailed logfire spans for economy comparison timing
1 parent 491955b commit b87ffd0

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/policyengine_api/modal_app.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -657,15 +657,18 @@ def simulate_economy_us(simulation_id: str, traceparent: str | None = None) -> N
657657
def economy_comparison_uk(job_id: str, traceparent: str | None = None) -> None:
658658
"""Run UK economy comparison analysis (decile impacts, budget impact, etc)."""
659659
import os
660-
from datetime import datetime, timezone
661-
from uuid import UUID
662660

663661
import logfire
664-
from sqlmodel import Session, create_engine
665662

663+
# Configure logfire FIRST to capture all time including imports
666664
configure_logfire("policyengine-modal-uk", traceparent)
667665

668666
with logfire.span("economy_comparison_uk", job_id=job_id):
667+
from datetime import datetime, timezone
668+
from uuid import UUID
669+
670+
from sqlmodel import Session, create_engine
671+
669672
logfire.info("Starting UK economy comparison", job_id=job_id)
670673

671674
database_url = get_database_url()
@@ -742,17 +745,18 @@ def economy_comparison_uk(job_id: str, traceparent: str | None = None) -> None:
742745
)
743746

744747
# Download dataset
745-
logfire.info("Loading dataset", filepath=dataset.filepath)
746-
local_path = download_dataset(
747-
dataset.filepath, supabase_url, supabase_key, storage_bucket
748-
)
748+
with logfire.span("download_dataset", filepath=dataset.filepath):
749+
local_path = download_dataset(
750+
dataset.filepath, supabase_url, supabase_key, storage_bucket
751+
)
749752

750-
pe_dataset = PolicyEngineUKDataset(
751-
name=dataset.name,
752-
description=dataset.description or "",
753-
filepath=local_path,
754-
year=dataset.year,
755-
)
753+
with logfire.span("load_dataset"):
754+
pe_dataset = PolicyEngineUKDataset(
755+
name=dataset.name,
756+
description=dataset.description or "",
757+
filepath=local_path,
758+
year=dataset.year,
759+
)
756760

757761
# Create and run simulations
758762
with logfire.span("run_baseline_simulation"):

0 commit comments

Comments
 (0)