Class MetricsFeatureListener
java.lang.Object
cloud.opencode.base.feature.audit.MetricsFeatureListener
- All Implemented Interfaces:
FeatureListener
Metrics Feature Listener
指标功能监听器
Listener that collects metrics on feature changes.
收集功能变更指标的监听器。
Features | 主要功能:
- Change counting - 变更计数
- Enable/Disable tracking - 启用/禁用跟踪
- Per-feature metrics - 按功能指标
Usage Examples | 使用示例:
MetricsFeatureListener metrics = new MetricsFeatureListener();
OpenFeature.getInstance().addListener(metrics);
// Later, get metrics
long totalChanges = metrics.getTotalChanges();
long enableCount = metrics.getEnableCount("feature-key");
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial (validates inputs) - 空值安全: 部分(验证输入)
- Since:
- JDK 25, opencode-base-feature V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet all disable counts 获取所有禁用计数Get all enable counts 获取所有启用计数longgetDisableCount(String key) Get disable count for a feature 获取功能的禁用次数longgetEnableCount(String key) Get enable count for a feature 获取功能的启用次数longGet total number of changes 获取总变更数voidonFeatureChanged(String key, boolean oldValue, boolean newValue) Called when a feature's enabled state changes 当功能的启用状态改变时调用voidreset()Reset all metrics 重置所有指标
-
Constructor Details
-
MetricsFeatureListener
public MetricsFeatureListener()
-
-
Method Details
-
onFeatureChanged
Description copied from interface:FeatureListenerCalled when a feature's enabled state changes 当功能的启用状态改变时调用- Specified by:
onFeatureChangedin interfaceFeatureListener- Parameters:
key- the feature key | 功能键oldValue- the old enabled state | 旧的启用状态newValue- the new enabled state | 新的启用状态
-
getTotalChanges
public long getTotalChanges()Get total number of changes 获取总变更数- Returns:
- total changes | 总变更数
-
getEnableCount
Get enable count for a feature 获取功能的启用次数- Parameters:
key- the feature key | 功能键- Returns:
- enable count | 启用次数
-
getDisableCount
Get disable count for a feature 获取功能的禁用次数- Parameters:
key- the feature key | 功能键- Returns:
- disable count | 禁用次数
-
getAllEnableCounts
-
getAllDisableCounts
-
reset
public void reset()Reset all metrics 重置所有指标
-