-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Refactor customer sdk stats #42969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor customer sdk stats #42969
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the customer SDK stats implementation to eliminate global variables and locks by adopting the Manager
and Singleton
patterns. The changes separate functionality into different modules and improve state management for better thread safety and cleaner code organization.
Key Changes:
- Replaced global variables and locks with a
CustomerSdkStatsManager
singleton pattern - Reorganized code into separate modules under
statsbeat/customer/
directory - Simplified state management through a centralized manager instance
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
tests/test_base_exporter.py | Removed customer SDK stats test cases and unused imports |
tests/test_base_customer_sdkstats.py | Updated imports and simplified test setup using class-level resources |
tests/statsbeat/test_customer_sdkstats.py | Completely removed old test implementation |
tests/customer_sdk_stats/test_utils.py | New comprehensive test suite for utility functions |
tests/customer_sdk_stats/test_manager.py | New test suite for the manager implementation |
tests/customer_sdk_stats/test_customer_sdkstats.py | New test suite for core functionality |
azure/monitor/.../customer/_utils.py | New utility functions module with helper methods |
azure/monitor/.../customer/_state.py | New state management module with singleton access |
azure/monitor/.../customer/_manager.py | New manager implementation using singleton pattern |
azure/monitor/.../customer/_customer_sdkstats.py | New core functionality module |
azure/monitor/.../customer/init.py | New package initialization |
azure/monitor/.../_utils.py | Removed customer SDK stats functions (moved to customer module) |
azure/monitor/.../_statsbeat.py | Temporarily disabled configuration manager |
azure/monitor/.../_state.py | Removed customer SDK stats global state variables |
azure/monitor/.../_customer_sdkstats.py | Removed old implementation |
azure/monitor/.../export/_base.py | Updated imports and manager usage |
azure/monitor/.../_storage.py | Updated import path for storage state |
azure/monitor/.../_constants.py | Removed unused CustomerSdkStatsProperties class |
CHANGELOG.md | Added entry for the refactoring changes |
Comments suppressed due to low confidence (1)
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py:479
- There's trailing whitespace after
manager.is_shutdown
on line 475. This should be removed for consistency with code formatting standards.
manager = get_customer_stats_manager()
return (
manager.is_enabled
and not manager.is_shutdown
and not self._is_stats_exporter()
and not self._is_customer_sdkstats_exporter()
and not self._instrumentation_collection
)
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_exporter.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py
Show resolved
Hide resolved
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
...itor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py
Show resolved
Hide resolved
...or/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py
Show resolved
Hide resolved
...or/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py
Show resolved
Hide resolved
...zure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_state.py
Show resolved
Hide resolved
...zure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_utils.py
Show resolved
Hide resolved
...metry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/customer/_customer_sdkstats.py
Outdated
Show resolved
Hide resolved
...r-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/customer/_manager.py
Show resolved
Hide resolved
...tor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/customer/_state.py
Outdated
Show resolved
Hide resolved
...or/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Removes global variables and lock to control sdk stats instance.
We use the
Manager
andSingleton
patterns to control state. Separated functions into different modules.