Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

lzchen
Copy link
Member

@lzchen lzchen commented Sep 11, 2025

Removes global variables and lock to control sdk stats instance.
We use the Manager and Singleton patterns to control state. Separated functions into different modules.

@Copilot Copilot AI review requested due to automatic review settings September 11, 2025 18:57
Copy link
Contributor

@Copilot Copilot AI left a 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
        )

@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Sep 11, 2025
Copy link

github-actions bot commented Sep 11, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-monitor-opentelemetry-exporter

Copy link
Member

@rads-1996 rads-1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lzchen lzchen merged commit 6d11ecc into Azure:main Sep 13, 2025
19 checks passed
@lzchen lzchen deleted the stats branch September 13, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor - Exporter Monitor OpenTelemetry Exporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants