共用方式為


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 is not set (or null), then 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.

Parameters:

configuration - The Configuration instance containing metrics options. 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