Package com.azure.core.util
Class MetricsOptions
java.lang.Object
com.azure.core.util.MetricsOptions
Metrics configuration options for clients.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates new instance ofMetricsOptionsprotectedMetricsOptions(Class<? extends MeterProvider> meterProvider) Creates new instance ofMetricsOptions -
Method Summary
Modifier and TypeMethodDescriptionstatic MetricsOptionsfromConfiguration(Configuration configuration) Attempts to load metrics options from the configuration.Class<? extends MeterProvider> Gets configuredMeterProviderimplementation that should be used to construct an instance ofMeter.booleanFlag indicating if metrics should be enabled.setEnabled(boolean enabled) Enables or disables metrics.
-
Constructor Details
-
MetricsOptions
public MetricsOptions()Creates new instance ofMetricsOptions -
MetricsOptions
Creates new instance ofMetricsOptions- Parameters:
meterProvider- type of theMeterProviderimplementation that should be used to construct an instance ofMeter. If the value is not set (ornull), then the firstMeterProviderresolved byServiceLoaderwill be used to create an instance ofMeter. If the value is set and doesn't match anyMeterProviderresolved byServiceLoaderanIllegalStateExceptionwill be thrown when attempting to create an instance ofMeter.
-
-
Method Details
-
fromConfiguration
Attempts to load metrics options from the configuration.- Parameters:
configuration- TheConfigurationinstance containing metrics options. Ifnullis passed thenConfiguration.getGlobalConfiguration()will be used.- Returns:
- A
MetricsOptionsreflecting a metrics loaded from configuration, if no options are found, default (enabled) options will be returned.
-
isEnabled
public boolean isEnabled()Flag indicating if metrics should be enabled.- Returns:
trueif metrics are enabled,falseotherwise.
-
setEnabled
Enables or disables metrics. By default, metrics are enabled if and only if metrics implementation is detected.- Parameters:
enabled- passtrueto enable metrics.- Returns:
- the updated
MetricsOptionsobject.
-
getMeterProvider
Gets configuredMeterProviderimplementation that should be used to construct an instance ofMeter.- Returns:
- The
MeterProviderimplementation used to create an instance ofMeter.
-