Add Module 1: Observability Primitives & Instrumentation#6
Merged
Conversation
Implement comprehensive FastAPI + Logfire observability lab with:
Phase 1 - Service Skeleton:
- Initialize FastAPI application with auto-instrumentation
- Configure Logfire with service name 'observability-lab-01'
- Apply logfire.instrument_fastapi(app) hook for automatic tracing
- Add fallback console-only mode for local development
Phase 2 - Structural Depth:
- Implement GET /process-order/{order_id} endpoint
- Use structured logging (key-value pairs) instead of string formatting
- Create manual 'verify_inventory' span for granular tracing
- Simulate database latency with random sleep (0.1s-0.5s)
- Log warnings for slow queries (>0.4s threshold)
- Attach metadata to spans for queryability
Phase 3 - Verification Challenge:
- Add conditional error injection for order_id='error-test'
- Raise HTTPException with 500 status code
- Provide structured error logging with context
- Enable full exception trace correlation
Testing & Verification:
- All endpoints tested and verified working
- Regular order processing with timing information
- Slow query detection and warning logging
- Error case with proper exception handling
- Comprehensive test results documented
Documentation:
- Complete README with setup instructions
- Detailed implementation guide
- Testing and verification procedures
- TEST_RESULTS.md with actual test outputs
- Logfire dashboard usage instructions
This implementation demonstrates production-ready observability
practices suitable for real-world applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement comprehensive FastAPI + Logfire observability lab with:
Phase 1 - Service Skeleton:
Phase 2 - Structural Depth:
Phase 3 - Verification Challenge:
Testing & Verification:
Documentation:
This implementation demonstrates production-ready observability
practices suitable for real-world applications.