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.
📥 Pull Request
This pull request introduces significant enhancements to the instrumentation module, focusing on refactoring, improved attribute handling, and better support for streaming responses. The changes include replacing the base instrumentor with an enhanced version, adding utilities for advanced attribute extraction and streaming support, and centralizing shared functionality in the common module.
Refactoring and Enhancements to Instrumentation
BaseInstrumentorwithEnhancedBaseInstrumentorinagentops/instrumentation/*/instrumentor.py, adding properties for library metadata, wrapped methods, and streaming support. This improves modularity and extensibility. [1] [2]_instrumentand_uninstrumentmethods into_create_provider_metrics,_apply_streaming_wrappers, and_remove_streaming_wrappers, streamlining the setup and teardown of instrumentation.Advanced Attribute Handling
agentops/instrumentation/common/attribute_handlers.py, which provides utilities for extracting and managing attributes for LLM requests, responses, and streaming data. This includes classes likeLLMAttributeHandlerandStreamingAttributeHandlerfor specialized use cases.AttributeExtractorto support safe extraction and merging of attributes with error handling.Shared Utilities in Common Module
agentops/instrumentation/common/__init__.pyto include new exports likeEnhancedBaseInstrumentor,SpanLifecycleManager, andLLMAttributeHandler, consolidating shared functionality for reuse across instrumentors.These updates improve the modularity, maintainability, and feature set of the instrumentation, particularly for handling complex telemetry scenarios like streaming responses.