MetricsOptions Class

  • java.lang.Object
    • com.azure.core.util.MetricsOptions

public class MetricsOptions

Metrics configuration options for clients.

Constructor Summary

Modifier Constructor Description
MetricsOptions()

Creates new instance of MetricsOptions

protected MetricsOptions(Class<? extends MeterProvider> meterProvider)

Creates new instance of MetricsOptions

Method Summary

Modifier and Type Method and Description
static MetricsOptions fromConfiguration(Configuration configuration)

Attempts to load metrics options from the configuration.

Class<> getMeterProvider()

Gets configured MeterProvider implementation that should be used to construct an instance of Meter.

boolean isEnabled()

Flag indicating if metrics should be enabled.

MetricsOptions setEnabled(boolean enabled)

Enables or disables metrics.

Methods inherited from java.lang.Object

Constructor Details

MetricsOptions

public MetricsOptions()

Creates new instance of MetricsOptions

MetricsOptions

protected MetricsOptions(Class meterProvider)

Creates new instance of MetricsOptions

Parameters:

meterProvider - type of the MeterProvider implementation that should be used to construct an instance of Meter. If the value isn't set or is an empty string the first MeterProvider resolved by ServiceLoader will be used to create an instance of Meter. If the value is set and doesn't match any MeterProvider resolved by ServiceLoader an IllegalStateException will be thrown when attempting to create an instance of Meter.

Method Details

fromConfiguration

public static MetricsOptions fromConfiguration(Configuration configuration)

Attempts to load metrics options from the configuration.

null will be returned if no metric options are found in the environment.

Parameters:

configuration - The Configuration that is used to load proxy configurations from the environment. If null is passed then getGlobalConfiguration() will be used.

Returns:

A MetricsOptions reflecting a metrics loaded from configuration, if no options are found, default (enabled) options will be returned.

getMeterProvider

public Class getMeterProvider()

Gets configured MeterProvider implementation that should be used to construct an instance of Meter.

Returns:

The MeterProvider implementation used to create an instance of Meter.

isEnabled

public boolean isEnabled()

Flag indicating if metrics should be enabled.

Returns:

true if metrics are enabled, false otherwise.

setEnabled

public MetricsOptions setEnabled(boolean enabled)

Enables or disables metrics. By default, metrics are enabled if and only if metrics implementation is detected.

Parameters:

enabled - pass true to enable metrics.

Returns:

the updated MetricsOptions object.

Applies to