ClientOptions Class

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

public class ClientOptions

General configuration options for clients.

Constructor Summary

Constructor Description
ClientOptions()

Creates a new instance of ClientOptions.

Method Summary

Modifier and Type Method and Description
String getApplicationId()

Gets the application ID.

Iterable<Header> getHeaders()

Gets the Header.

MetricsOptions getMetricsOptions()

Gets MetricsOptions

TracingOptions getTracingOptions()

Gets MetricsOptions

ClientOptions setApplicationId(String applicationId)

Sets the application ID.

ClientOptions setHeaders(Iterable<Header> headers)

Sets the Header.

ClientOptions setMetricsOptions(MetricsOptions metricsOptions)

Sets MetricsOptions that are applied to each metric reported by the client.

ClientOptions setTracingOptions(TracingOptions tracingOptions)

Sets TracingOptions that are applied to each tracing reported by the client.

Methods inherited from java.lang.Object

Constructor Details

ClientOptions

public ClientOptions()

Creates a new instance of ClientOptions.

Method Details

getApplicationId

public String getApplicationId()

Gets the application ID.

Returns:

The application ID.

getHeaders

public Iterable

getHeaders()

Gets the Header.

Returns:

The Header, if headers weren't set previously an empty list is returned.

getMetricsOptions

public MetricsOptions getMetricsOptions()

Gets MetricsOptions

Returns:

The MetricsOptions instance, if metric options weren't set previously, null is returned.

getTracingOptions

public TracingOptions getTracingOptions()

Gets MetricsOptions

Returns:

The MetricsOptions instance, if metric options weren't set previously, null is returned.

setApplicationId

public ClientOptions setApplicationId(String applicationId)

Sets the application ID.

The applicationId is used to configure UserAgentPolicy for telemetry/monitoring purposes.

See Azure Core: Telemetry policy for additional information.

Code Samples

Create ClientOptions with application ID 'myApplicationId'

ClientOptions clientOptions = new ClientOptions()
     .setApplicationId("myApplicationId");

Parameters:

applicationId - The application ID.

Returns:

The updated ClientOptions object.

setHeaders

public ClientOptions setHeaders(Iterable

headers)

Sets the Header.

The passed headers are applied to each request sent with the client.

This overwrites all previously set headers.

Code Samples

Create ClientOptions with Header 'myCustomHeader':'myStaticValue'

ClientOptions clientOptions = new ClientOptions()
     .setHeaders(Collections.singletonList(new Header("myCustomHeader", "myStaticValue")));

Parameters:

headers - The headers.

Returns:

The updated ClientOptions object.

setMetricsOptions

public ClientOptions setMetricsOptions(MetricsOptions metricsOptions)

Sets MetricsOptions that are applied to each metric reported by the client. Use metrics options to enable and disable metrics or pass implementation-specific configuration.

Parameters:

metricsOptions - instance of MetricsOptions to set.

Returns:

The updated ClientOptions object.

setTracingOptions

public ClientOptions setTracingOptions(TracingOptions tracingOptions)

Sets TracingOptions that are applied to each tracing reported by the client. Use tracing options to enable and disable tracing or pass implementation-specific configuration.

Parameters:

tracingOptions - instance of TracingOptions to set.

Returns:

The updated ClientOptions object.

Applies to