[Feature] Add API span tracking infrastructure (PR #5/9)#13
Merged
Conversation
Add span tracking dict and helper methods to OpenAIServing for future API-side journey tracing. This PR adds infrastructure only - no spans are created or managed yet (deferred to PR #6). Changes: - Add _api_spans dict to track (span, arrival_time, first_response_time) - Add _cached_is_tracing_enabled flag with defensive error handling - Add helper methods: _get_is_tracing_enabled, _store_api_span, _get_api_span_info, _cleanup_api_span - Add 8 comprehensive unit tests for dict operations and caching All state is private and lives outside Pydantic models to avoid serialization issues. Safe to merge independently - introduces no lifecycle obligations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Mark PR #5 as completed with implementation summary: - Status: Completed (PR #13 merged) - Branch: pr5ofjourney - Size: 67 lines production code, 177 lines test code - Tests: 8 comprehensive tests, all passing - Implementation details: Added _api_spans dict, helper methods, and defensive error handling Updated code examples to match actual implementation including error handling in _get_is_tracing_enabled() method.
Reduce Implementation History from 229 lines to 53 lines (~77% reduction): - Condensed PR #0-#5 to essential info only (commit, PR number, line stats) - Removed verbose implementation details (already in individual PR sections) - Added PR #5 completion entry - Added summary line: 5 PRs completed, ~350 production lines, ~1022 test lines, 31 tests Total file size: 2266 → 2089 lines (177 line reduction)
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.
Add span tracking dict and helper methods to OpenAIServing for future API-side journey tracing. This PR adds infrastructure only - no spans are created or managed yet (deferred to PR #6).
Changes
_api_spansdict to track(span, arrival_time, first_response_time)_cached_is_tracing_enabledflag with defensive error handling_get_is_tracing_enabled,_store_api_span,_get_api_span_info,_cleanup_api_spanKey Design Decisions
Falseto prevent tracing failures from breaking servingTesting
All 8 unit tests pass:
Non-Goals (Deferred to PR #6)
Part of Journey Tracing Series
This is PR #5 of 9 in the dual-stream journey tracing implementation:
🤖 Generated with Claude Code