fix: align instrumentation tests with current APIs and close LiteLLM/FastAPI gaps#326
Open
AkhileshNair2201 wants to merge 15 commits into
Open
fix: align instrumentation tests with current APIs and close LiteLLM/FastAPI gaps#326AkhileshNair2201 wants to merge 15 commits into
AkhileshNair2201 wants to merge 15 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Restore the 0.1.95 changelog entry, bump to 0.1.96, skip cache writes for non-positive TTL, and add shutdown and edge-case tests. Co-authored-by: Cursor <cursoragent@cursor.com>
…FastAPI gaps Co-authored-by: Cursor <cursoragent@cursor.com>
ae30af0 to
695ee6a
Compare
* feat: add opt-in TTL caching for get_prompt Co-authored-by: Cursor <cursoragent@cursor.com> * update doc * remove 0.1.95 changelog * fix: address PR review feedback for get_prompt caching Restore the 0.1.95 changelog entry, bump to 0.1.96, skip cache writes for non-positive TTL, and add shutdown and edge-case tests. Co-authored-by: Cursor <cursoragent@cursor.com> * fix * fix: align instrumentation tests with current APIs and close LiteLLM/FastAPI gaps Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
…k-py into feat/sdk-caching
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
This PR brings the unit test suite back in sync with the current instrumentation and SDK APIs, and fixes two small production gaps that the updated tests exposed.
Tests had drifted after recent renames and API changes (instrumentor class names, wrapt-based wrapping, span attribute conventions, Config/Tracer kwargs, default span attributes). Several suites were failing or asserting obsolete contracts. This change updates those expectations so failures again mean a real behavior break, not a stale mock.
What changed
Production
build_request_url— when the ASGI scope has noserver, fall back to the path instead of leavingurlundefined._uninstrument— also unwrapresponses/aresponses, matching what_instrumentwraps, so uninstrument fully restores the original methods.Tests
NetraGoogleGenAiInstrumentor; drop tests for helpers that no longer exist.DEFAULT_INSTRUMENTSand newer Config fields (cache_ttl_seconds, metrics knobs, etc.).netra.span.typeand mock Filtering/Trial exporters used by current Tracer setup.llm_guardimport path used at runtime.Why
Without this, CI and local
pytesteither fail on outdated assertions or pass with weak checks (e.g.call_count >= 1) that would miss partial instrumentation regressions. Aligning tests to the live contracts makes the suite a reliable gate for future instrumentation changes.Test plan
pytest tests/test_openai_instrumentation.py tests/test_litellm_instrumentation.py tests/test_google_genai_instrumentation.py -qpytest tests/test_fastapi_instrumentation.py tests/test_netra_init.py tests/test_span_wrapper.py tests/test_tracer.py tests/test_input_scanner.py -qpytestgreen locally