Skip to content

Conversation

@Dwij1704
Copy link
Member

📥 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

  • Replaced BaseInstrumentor with EnhancedBaseInstrumentor in agentops/instrumentation/*/instrumentor.py, adding properties for library metadata, wrapped methods, and streaming support. This improves modularity and extensibility. [1] [2]
  • Refactored _instrument and _uninstrument methods into _create_provider_metrics, _apply_streaming_wrappers, and _remove_streaming_wrappers, streamlining the setup and teardown of instrumentation.

Advanced Attribute Handling

  • Introduced agentops/instrumentation/common/attribute_handlers.py, which provides utilities for extracting and managing attributes for LLM requests, responses, and streaming data. This includes classes like LLMAttributeHandler and StreamingAttributeHandler for specialized use cases.
  • Added AttributeExtractor to support safe extraction and merging of attributes with error handling.

Shared Utilities in Common Module

  • Expanded agentops/instrumentation/common/__init__.py to include new exports like EnhancedBaseInstrumentor, SpanLifecycleManager, and LLMAttributeHandler, 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.

@Dwij1704 Dwij1704 marked this pull request as draft June 11, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants