Skip to content

Improve logfire run instrumentation recommendations#1922

Closed
snoopuppy582 wants to merge 5 commits into
pydantic:mainfrom
snoopuppy582:fix/run-summary-disclaimer
Closed

Improve logfire run instrumentation recommendations#1922
snoopuppy582 wants to merge 5 commits into
pydantic:mainfrom
snoopuppy582:fix/run-summary-disclaimer

Conversation

@snoopuppy582
Copy link
Copy Markdown

Fixes #1296

Summary

  • Added a short disclaimer under logfire run instrumentation recommendations.
  • The note tells users to install instrumentation only for packages their app actually uses.
  • Added test coverage for the recommendation text.

Tests

  • uv run pytest tests/test_cli.py::test_get_recommendation_texts tests/test_cli.py::test_recommended_packages_with_dependencies -q
  • uv run ruff check logfire/_internal/cli/run.py tests/test_cli.py
  • git diff --check

Notes

  • uv run pytest tests/test_cli.py::test_get_recommendation_texts tests/test_cli.py::test_parse_run_script_with_summary tests/test_cli.py::test_inspect -q passed the first two tests, but test_inspect failed locally on Windows due to existing console/snapshot rendering differences for box-drawing characters.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@snoopuppy582
Copy link
Copy Markdown
Author

Follow-up pushed to address the CI failure in tests/test_cli.py::test_inspect.

The exact Rich panel snapshot was sensitive to terminal width, so I replaced it with stable assertions for the important output lines, including the new disclaimer and recommended instrumentation packages.

Re-ran locally:

  • uv run pytest tests/test_cli.py::test_inspect tests/test_cli.py::test_get_recommendation_texts -q -> 2 passed
  • uv run ruff check logfire/_internal/cli/run.py tests/test_cli.py -> passed
  • uv run ruff format --check logfire/_internal/cli/run.py tests/test_cli.py -> passed
  • git diff --check -> passed

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread tests/test_cli.py Outdated
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

""")
err = capsys.readouterr().err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, please keep the table assertion.

Comment thread logfire/_internal/cli/run.py Outdated
for pkg_name, instrumented_pkg in sorted_recommendations:
recommended_text.append(f'☐ {instrumented_pkg} (need to install {pkg_name})\n', style='grey50')
if sorted_recommendations:
recommended_text.append('Only install instrumentation for packages your app actually uses.\n', style='grey50')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't really helping. the point is to note the special cases like requests

@snoopuppy582
Copy link
Copy Markdown
Author

Thanks, I addressed both review comments in follow-ups:

  • removed the generic "Only install..." note
  • restored the rendered table snapshot assertion
  • adjusted the snapshot spacing to match the CI-rendered panel after removing the note

Verified locally:

  • uv run pytest tests/test_cli.py::test_get_recommendation_texts -q -> passed
  • uv run ruff check logfire/_internal/cli/run.py tests/test_cli.py -> passed before formatting

CI update: lint, docs, Pyodide, cubic, and the Python 3.9/3.10/3.11/3.12/3.13/3.14 pydantic 2 jobs now pass for the changed CLI snapshot. The remaining failure is in tests/otel_integrations/test_celery.py::test_instrument_celery on the Python 3.12 + pydantic 2.4 job and appears unrelated to this PR's changed files.

@alexmojaki alexmojaki closed this May 13, 2026
@alexmojaki
Copy link
Copy Markdown
Collaborator

Please open a fresh PR once you have changes again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logfire run always suggests requests, sqlite3, urllib

2 participants