Skip to content

feat: examples#101

Merged
CorentinGS merged 2 commits into
masterfrom
fix/fastapi
Jan 26, 2026
Merged

feat: examples#101
CorentinGS merged 2 commits into
masterfrom
fix/fastapi

Conversation

@CorentinGS
Copy link
Copy Markdown
Contributor

No description provided.

@CorentinGS CorentinGS marked this pull request as ready for review January 26, 2026 12:38
@CorentinGS CorentinGS requested a review from Copilot January 26, 2026 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a runnable microservices example showcasing Basalt observability across HTTP boundaries, and updates Basalt instrumentation behavior to better support framework-created parent spans.

Changes:

  • Add FastAPI “Service A / Service B” microservices example with distributed tracing, LLM calls, and prompt usage.
  • Improve Basalt root-span detection so start_observe can act as a Basalt root even when invoked under non-Basalt parent spans (e.g., FastAPI/httpx).
  • Update lockfile dependencies (e.g., openai, google-genai, google-auth) and add a small instrumentation fallback.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
uv.lock Dependency resolution updates and new entries.
pyproject.toml Removes an outdated comment in optional-deps section.
examples/microservices/service_a/main.py Service A example (FastAPI + httpx + OpenAI + Basalt spans).
examples/microservices/service_a/init.py Package marker for Service A.
examples/microservices/service_b/main.py Service B example (FastAPI + retrieval span + Google GenAI + Basalt prompts).
examples/microservices/service_b/init.py Package marker for Service B.
examples/microservices/run.sh Convenience script to run both services via Hatch.
examples/microservices/pyproject.toml Hatch env definition for the microservices example.
examples/microservices/.gitignore Ignores local env/IDE artifacts for the microservices example.
basalt/observability/instrumentation.py Adds fallback import logic for Google GenAI instrumentation.
basalt/observability/context_managers.py Updates Basalt root-span detection logic to cooperate with external parent spans.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/microservices/pyproject.toml Outdated
Comment thread examples/microservices/pyproject.toml
Comment thread examples/microservices/service_b/main.py
Comment thread examples/microservices/service_a/main.py
Comment thread examples/microservices/service_b/main.py
Comment on lines +728 to +732
# Determine if this should be treated as a Basalt root span
# A span is a Basalt root if:
# 1. There's no parent span at all (true root), OR
# 2. This is a start_observe (span_type="basalt_trace") AND the parent is NOT a Basalt span
# (e.g., parent is from FastAPI, httpx, or other instrumentation)
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

Root-span detection now treats start_observe spans as Basalt roots when there’s a non-Basalt parent span (e.g., FastAPI/httpx). There are existing context-manager tests, but none appear to cover the “external parent span present” case; add a unit test that sets a non-Basalt current span (with no ROOT_SPAN_CONTEXT_KEY) and asserts start_observe sets basalt.root and attaches ROOT_SPAN_CONTEXT_KEY.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment thread examples/microservices/pyproject.toml
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@CorentinGS CorentinGS merged commit bdadf25 into master Jan 26, 2026
5 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 26, 2026

@CorentinGS I've opened a new pull request, #102, to work on those changes. Once the pull request is ready, I'll request review from you.

@CorentinGS CorentinGS deleted the fix/fastapi branch January 28, 2026 16:01
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.

3 participants