diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionAsyncClient.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionAsyncClient.java index c7f72a2d1eac..86a688fda3b7 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionAsyncClient.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionAsyncClient.java @@ -35,14 +35,14 @@ import java.util.function.Consumer; import static com.azure.core.util.FluxUtil.withContext; -import static com.azure.monitor.ingestion.implementation.Utils.CONTENT_ENCODING; import static com.azure.monitor.ingestion.implementation.Utils.GZIP; import static com.azure.monitor.ingestion.implementation.Utils.getConcurrency; import static com.azure.monitor.ingestion.implementation.Utils.gzipRequest; /** *

This class provides an asynchronous client for uploading custom logs to an Azure Monitor Log Analytics workspace. - * This client encapsulates REST API calls, used to send data to a Log Analytics workspace, into a set of asynchronous operations.

+ * This client encapsulates REST API calls, used to send data to a Log Analytics workspace, into a set of asynchronous + * operations.

* *

Getting Started

* @@ -52,9 +52,11 @@ *
    *
  1. {@code endpoint} - The data collection endpoint. * See {@link LogsIngestionClientBuilder#endpoint(String) endpoint} method for more details.
  2. - *
  3. {@code credential} - The AAD authentication credential that has the "Monitoring Metrics Publisher" role assigned to it. + *
  4. {@code credential} - The AAD authentication credential that has the "Monitoring Metrics Publisher" role assigned + * to it. * Azure Identity - * provides a variety of AAD credential types that can be used. See {@link LogsIngestionClientBuilder#credential(TokenCredential) credential } method for more details.
  5. + * provides a variety of AAD credential types that can be used. See + * {@link LogsIngestionClientBuilder#credential(TokenCredential) credential} method for more details. *
* *

Instantiating an asynchronous Logs ingestion client

@@ -75,13 +77,16 @@ * * * @@ -95,6 +100,7 @@ public final class LogsIngestionAsyncClient { /** * Creates a {@link LogsIngestionAsyncClient} that sends requests to the data collection endpoint. + * * @param service The {@link IngestionUsingDataCollectionRulesClient} that the client routes its request through. */ LogsIngestionAsyncClient(IngestionUsingDataCollectionRulesAsyncClient service) { @@ -169,22 +175,22 @@ public Mono upload(String ruleId, String streamName, Iterable logs * @throws IllegalArgumentException if {@code logs} is empty. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono upload(String ruleId, String streamName, - Iterable logs, LogsUploadOptions options) { + public Mono upload(String ruleId, String streamName, Iterable logs, LogsUploadOptions options) { return withContext(context -> upload(ruleId, streamName, logs, options, context)); } /** - * This method is used to upload logs to Azure Monitor Log Analytics with specified data collection rule id and stream name. This - * upload method provides a more granular control of the HTTP request sent to the service. Use {@link RequestOptions} - * to configure the HTTP request. + * This method is used to upload logs to Azure Monitor Log Analytics with specified data collection rule id and + * stream name. This upload method provides a more granular control of the HTTP request sent to the service. Use + * {@link RequestOptions} to configure the HTTP request. * *

* The input logs should be a JSON array with each element in the array * matching the schema defined - * by the stream name. The stream's schema can be found in the Azure portal. This content will be gzipped before sending to the service. - * If the content is already gzipped, then set the {@code Content-Encoding} header to {@code gzip} using {@link RequestOptions#setHeader(HttpHeaderName, String) requestOptions} - * and pass the content as is. + * by the stream name. The stream's schema can be found in the Azure portal. This content will be gzipped before + * sending to the service. If the content is already gzipped, then set the {@code Content-Encoding} header to + * {@code gzip} using {@link RequestOptions#setHeader(HttpHeaderName, String) requestOptions} and pass the content + * as is. *

* *

Header Parameters @@ -208,15 +214,15 @@ public Mono upload(String ruleId, String streamName, * @param streamName The streamDeclaration name as defined in the Data Collection Rule. * @param logs An array of objects matching the schema defined by the provided stream. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @return the {@link Response} on successful completion of {@link Mono}. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> uploadWithResponse( - String ruleId, String streamName, BinaryData logs, RequestOptions requestOptions) { + public Mono> uploadWithResponse(String ruleId, String streamName, BinaryData logs, + RequestOptions requestOptions) { Objects.requireNonNull(ruleId, "'ruleId' cannot be null."); Objects.requireNonNull(streamName, "'streamName' cannot be null."); Objects.requireNonNull(logs, "'logs' cannot be null."); @@ -225,44 +231,42 @@ public Mono> uploadWithResponse( requestOptions = new RequestOptions(); } requestOptions.addRequestCallback(request -> { - HttpHeader httpHeader = request.getHeaders().get(CONTENT_ENCODING); + HttpHeader httpHeader = request.getHeaders().get(HttpHeaderName.CONTENT_ENCODING); if (httpHeader == null) { BinaryData gzippedRequest = BinaryData.fromBytes(gzipRequest(logs.toBytes())); request.setBody(gzippedRequest); - request.setHeader(CONTENT_ENCODING, GZIP); + request.setHeader(HttpHeaderName.CONTENT_ENCODING, GZIP); } }); return service.uploadWithResponse(ruleId, streamName, logs, requestOptions); } - Mono upload(String ruleId, String streamName, - Iterable logs, LogsUploadOptions options, - Context context) { + Mono upload(String ruleId, String streamName, Iterable logs, LogsUploadOptions options, + Context context) { return Mono.defer(() -> splitAndUpload(ruleId, streamName, logs, options, context)); } - /** * This method splits the input logs into < 1MB HTTP requests and uploads to the Azure Monitor service. + * * @param ruleId The data collection rule id. * @param streamName The stream name configured in the data collection rule. * @param logs The input logs to upload. * @param options The options to configure the upload request. * @param context additional context that is passed through the Http pipeline during the service call. If no - * additional context is required, pass {@link Context#NONE} instead. + * additional context is required, pass {@link Context#NONE} instead. * @return the {@link Mono} that completes on completion of the upload request. */ private Mono splitAndUpload(String ruleId, String streamName, Iterable logs, - LogsUploadOptions options, Context context) { + LogsUploadOptions options, Context context) { int concurrency = getConcurrency(options); - return new Batcher(options, logs) - .toFlux() + return new Batcher(options, logs).toFlux() .flatMapSequential(request -> uploadToService(ruleId, streamName, context, request), concurrency) .handle((responseHolder, sink) -> processResponse(options, responseHolder, sink)) .collectList() - .handle((result, sink) -> processExceptions(result, sink)); + .handle(this::processExceptions); } private void processExceptions(List result, SynchronousSink sink) { @@ -279,33 +283,33 @@ private void processExceptions(List result, SynchronousSink } } - private void processResponse(LogsUploadOptions options, UploadLogsResponseHolder responseHolder, SynchronousSink sink) { + private void processResponse(LogsUploadOptions options, UploadLogsResponseHolder responseHolder, + SynchronousSink sink) { if (responseHolder.getException() != null) { Consumer uploadLogsErrorConsumer = null; if (options != null) { uploadLogsErrorConsumer = options.getLogsUploadErrorConsumer(); } if (uploadLogsErrorConsumer != null) { - uploadLogsErrorConsumer.accept(new LogsUploadError(responseHolder.getException(), responseHolder.getRequest().getLogs())); + uploadLogsErrorConsumer.accept( + new LogsUploadError(responseHolder.getException(), responseHolder.getRequest().getLogs())); return; } // emit the responseHolder without the original logs only if there's an error and there's no // error consumer sink.next(new LogsUploadException(Collections.singletonList(responseHolder.getException()), - responseHolder.getRequest().getLogs().size())); + responseHolder.getRequest().getLogs().size())); } } - private Mono uploadToService(String ruleId, String streamName, - Context context, - LogsIngestionRequest request) { - RequestOptions requestOptions = new RequestOptions() - .addHeader(CONTENT_ENCODING, GZIP) - .setContext(context); - return service.uploadWithResponse(ruleId, streamName, - BinaryData.fromBytes(request.getRequestBody()), requestOptions) - .map(response -> new UploadLogsResponseHolder(null, null)) - .onErrorResume(HttpResponseException.class, - ex -> Mono.fromSupplier(() -> new UploadLogsResponseHolder(request, ex))); + private Mono uploadToService(String ruleId, String streamName, Context context, + LogsIngestionRequest request) { + RequestOptions requestOptions = new RequestOptions().addHeader(HttpHeaderName.CONTENT_ENCODING, GZIP) + .setContext(context); + return service.uploadWithResponse(ruleId, streamName, BinaryData.fromBytes(request.getRequestBody()), + requestOptions) + .map(response -> new UploadLogsResponseHolder(null, null)) + .onErrorResume(HttpResponseException.class, + ex -> Mono.fromSupplier(() -> new UploadLogsResponseHolder(request, ex))); } } diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClient.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClient.java index 94af5b9b70de..605c8dfcfae5 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClient.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClient.java @@ -34,7 +34,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.azure.monitor.ingestion.implementation.Utils.CONTENT_ENCODING; import static com.azure.monitor.ingestion.implementation.Utils.GZIP; import static com.azure.monitor.ingestion.implementation.Utils.createThreadPool; import static com.azure.monitor.ingestion.implementation.Utils.getConcurrency; @@ -42,8 +41,9 @@ import static com.azure.monitor.ingestion.implementation.Utils.registerShutdownHook; /** - *

This class provides a synchronous client for uploading custom logs to an Azure Monitor Log Analytics workspace. This client - * encapsulates REST API calls, used to send data to a Log Analytics workspace, into a set of synchronous operations.

+ *

This class provides a synchronous client for uploading custom logs to an Azure Monitor Log Analytics workspace. + * This client encapsulates REST API calls, used to send data to a Log Analytics workspace, into a set of synchronous + * operations.

* *

Getting Started

* @@ -55,7 +55,8 @@ * See {@link LogsIngestionClientBuilder#endpoint(String) endpoint} method for more details. *
  • {@code credential} - The AAD authentication credential that has the "Monitoring Metrics Publisher" role assigned to it. * Azure Identity - * provides a variety of AAD credential types that can be used. See {@link LogsIngestionClientBuilder#credential(TokenCredential) credential } method for more details.
  • + * provides a variety of AAD credential types that can be used. See + * {@link LogsIngestionClientBuilder#credential(TokenCredential) credential} method for more details. * * *

    Instantiating a synchronous Logs ingestion client

    @@ -76,13 +77,16 @@ * *
      *
    • - * {@link LogsIngestionClient#upload(String, String, Iterable) upload(String, String, Iterable)} - Uploads logs to a Log Analytics workspace. + * {@link #upload(String, String, Iterable) upload(String, String, Iterable)} - Uploads logs to a Log Analytics + * workspace. *
    • *
    • - * {@link LogsIngestionClient#upload(String, String, Iterable, LogsUploadOptions) upload(String, String, Iterable, LogsUploadOptions)} - Uploads logs to a Log Analytics workspace with options to configure the upload request. + * {@link #upload(String, String, Iterable, LogsUploadOptions) upload(String, String, Iterable, LogsUploadOptions)} + * - Uploads logs to a Log Analytics workspace with options to configure the upload request. *
    • *
    • - * {@link LogsIngestionClient#uploadWithResponse(String, String, BinaryData, RequestOptions) uploadWithResponse(String, String, BinaryData, RequestOptions)} - Uploads logs to a Log Analytics workspace with options to configure the HTTP request. + * {@link #uploadWithResponse(String, String, BinaryData, RequestOptions) uploadWithResponse(String, String, BinaryData, RequestOptions)} + * - Uploads logs to a Log Analytics workspace with options to configure the HTTP request. *
    • *
    * @@ -147,8 +151,9 @@ public void upload(String ruleId, String streamName, Iterable logs) { * Uploads logs to Azure Monitor with specified data collection rule id and stream name. The input logs may be * too large to be sent as a single request to the Azure Monitor service. In such cases, this method will split * the input logs into multiple smaller requests before sending to the service. This method will block until all - * the logs are uploaded or an error occurs. If an {@link LogsUploadOptions#setLogsUploadErrorConsumer(Consumer) error handler} is set, - * then the service errors are surfaced to the error handler and this method won't throw an exception. + * the logs are uploaded or an error occurs. If an + * {@link LogsUploadOptions#setLogsUploadErrorConsumer(Consumer) error handler} is set, then the service errors are + * surfaced to the error handler and this method won't throw an exception. * *

    * Each log in the input collection must be a valid JSON object. The JSON object should match the @@ -166,6 +171,7 @@ public void upload(String ruleId, String streamName, Iterable logs) { * System.out.println("Logs uploaded successfully"); * * + * * @param ruleId the data collection rule id that is configured to collect and transform the logs. * @param streamName the stream name configured in data collection rule that matches defines the structure of the * logs sent in this request. @@ -175,8 +181,7 @@ public void upload(String ruleId, String streamName, Iterable logs) { * @throws IllegalArgumentException if {@code logs} is empty. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(String ruleId, String streamName, - Iterable logs, LogsUploadOptions options) { + public void upload(String ruleId, String streamName, Iterable logs, LogsUploadOptions options) { upload(ruleId, streamName, logs, options, Context.NONE); } @@ -184,8 +189,9 @@ public void upload(String ruleId, String streamName, * Uploads logs to Azure Monitor with specified data collection rule id and stream name. The input logs may be * too large to be sent as a single request to the Azure Monitor service. In such cases, this method will split * the input logs into multiple smaller requests before sending to the service. This method will block until all - * the logs are uploaded or an error occurs. If an {@link LogsUploadOptions#setLogsUploadErrorConsumer(Consumer) error handler} is set, - * then the service errors are surfaced to the error handler and this method won't throw an exception. + * the logs are uploaded or an error occurs. If an + * {@link LogsUploadOptions#setLogsUploadErrorConsumer(Consumer) error handler} is set, then the service errors are + * surfaced to the error handler and this method won't throw an exception. * *

    * Each log in the input collection must be a valid JSON object. The JSON object should match the @@ -204,39 +210,38 @@ public void upload(String ruleId, String streamName, * @throws IllegalArgumentException if {@code logs} is empty. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void upload(String ruleId, String streamName, - Iterable logs, LogsUploadOptions options, Context context) { + public void upload(String ruleId, String streamName, Iterable logs, LogsUploadOptions options, + Context context) { Objects.requireNonNull(ruleId, "'ruleId' cannot be null."); Objects.requireNonNull(streamName, "'streamName' cannot be null."); Objects.requireNonNull(logs, "'logs' cannot be null."); - Consumer uploadLogsErrorConsumer = options == null ? null : options.getLogsUploadErrorConsumer(); + Consumer uploadLogsErrorConsumer = options == null + ? null + : options.getLogsUploadErrorConsumer(); RequestOptions requestOptions = new RequestOptions(); - requestOptions.addHeader(CONTENT_ENCODING, GZIP); + requestOptions.addHeader(HttpHeaderName.CONTENT_ENCODING, GZIP); requestOptions.setContext(context); - Stream responses = new Batcher(options, logs) - .toStream() + Stream responses = new Batcher(options, logs).toStream() .map(r -> uploadToService(ruleId, streamName, requestOptions, r)); - responses = submit(responses, getConcurrency(options)) - .filter(response -> response.getException() != null); + responses = submit(responses, getConcurrency(options)).filter(response -> response.getException() != null); if (uploadLogsErrorConsumer != null) { - responses.forEach(response -> uploadLogsErrorConsumer.accept(new LogsUploadError(response.getException(), response.getRequest().getLogs()))); + responses.forEach(response -> uploadLogsErrorConsumer.accept( + new LogsUploadError(response.getException(), response.getRequest().getLogs()))); return; } final int[] failedLogCount = new int[1]; - List exceptions = responses - .map(response -> { - failedLogCount[0] += response.getRequest().getLogs().size(); - return response.getException(); - }) - .collect(Collectors.toList()); + List exceptions = responses.map(response -> { + failedLogCount[0] += response.getRequest().getLogs().size(); + return response.getException(); + }).collect(Collectors.toList()); - if (exceptions.size() > 0) { + if (!exceptions.isEmpty()) { throw LOGGER.logExceptionAsError(new LogsUploadException(exceptions, failedLogCount[0])); } } @@ -253,10 +258,12 @@ private Stream submit(Stream } } - private UploadLogsResponseHolder uploadToService(String ruleId, String streamName, RequestOptions requestOptions, LogsIngestionRequest request) { + private UploadLogsResponseHolder uploadToService(String ruleId, String streamName, RequestOptions requestOptions, + LogsIngestionRequest request) { HttpResponseException exception = null; try { - client.uploadWithResponse(ruleId, streamName, BinaryData.fromBytes(request.getRequestBody()), requestOptions); + client.uploadWithResponse(ruleId, streamName, BinaryData.fromBytes(request.getRequestBody()), + requestOptions); } catch (HttpResponseException ex) { exception = ex; } @@ -265,16 +272,17 @@ private UploadLogsResponseHolder uploadToService(String ruleId, String streamNam } /** - * This method is used to upload logs to Azure Monitor Log Analytics with specified data collection rule id and stream name. This - * upload method provides a more granular control of the HTTP request sent to the service. Use {@link RequestOptions} - * to configure the HTTP request. + * This method is used to upload logs to Azure Monitor Log Analytics with specified data collection rule id and + * stream name. This upload method provides a more granular control of the HTTP request sent to the service. Use + * {@link RequestOptions} to configure the HTTP request. * *

    * The input logs should be a JSON array with each element in the array * matching the schema defined - * by the stream name. The stream's schema can be found in the Azure portal. This content will be gzipped before sending to the service. - * If the content is already gzipped, then set the {@code Content-Encoding} header to {@code gzip} using {@link RequestOptions#setHeader(HttpHeaderName, String) requestOptions} - * and pass the content as is. + * by the stream name. The stream's schema can be found in the Azure portal. This content will be gzipped before + * sending to the service. If the content is already gzipped, then set the {@code Content-Encoding} header to + * {@code gzip} using {@link RequestOptions#setHeader(HttpHeaderName, String) requestOptions} and pass the content + * as is. *

    * *

    Header Parameters @@ -298,15 +306,15 @@ private UploadLogsResponseHolder uploadToService(String ruleId, String streamNam * @param streamName The streamDeclaration name as defined in the Data Collection Rule. * @param logs An array of objects matching the schema defined by the provided stream. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @return the {@link Response}. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response uploadWithResponse( - String ruleId, String streamName, BinaryData logs, RequestOptions requestOptions) { + public Response uploadWithResponse(String ruleId, String streamName, BinaryData logs, + RequestOptions requestOptions) { Objects.requireNonNull(ruleId, "'ruleId' cannot be null."); Objects.requireNonNull(streamName, "'streamName' cannot be null."); Objects.requireNonNull(logs, "'logs' cannot be null."); @@ -316,11 +324,11 @@ public Response uploadWithResponse( } requestOptions.addRequestCallback(request -> { - HttpHeader httpHeader = request.getHeaders().get(CONTENT_ENCODING); + HttpHeader httpHeader = request.getHeaders().get(HttpHeaderName.CONTENT_ENCODING); if (httpHeader == null) { BinaryData gzippedRequest = BinaryData.fromBytes(gzipRequest(logs.toBytes())); request.setBody(gzippedRequest); - request.setHeader(CONTENT_ENCODING, GZIP); + request.setHeader(HttpHeaderName.CONTENT_ENCODING, GZIP); } }); return client.uploadWithResponse(ruleId, streamName, logs, requestOptions); diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClientBuilder.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClientBuilder.java index 071e0eb274d3..30ba22687456 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClientBuilder.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionClientBuilder.java @@ -35,7 +35,8 @@ * See {@link LogsIngestionClientBuilder#endpoint(String) endpoint} method for more details. *

  • {@code credential} - The AAD authentication credential that has the "Monitoring Metrics Publisher" role assigned to it. * Azure Identity - * provides a variety of AAD credential types that can be used. See {@link LogsIngestionClientBuilder#credential(TokenCredential) credential } method for more details.
  • + * provides a variety of AAD credential types that can be used. See + * {@link LogsIngestionClientBuilder#credential(TokenCredential) credential} method for more details. * * *

    Instantiating an asynchronous Logs ingestion client

    @@ -58,16 +59,16 @@ * * */ -@ServiceClientBuilder(serviceClients = {LogsIngestionClient.class, LogsIngestionAsyncClient.class}) -public final class LogsIngestionClientBuilder implements ConfigurationTrait, - HttpTrait, EndpointTrait, TokenCredentialTrait { +@ServiceClientBuilder(serviceClients = { LogsIngestionClient.class, LogsIngestionAsyncClient.class }) +public final class LogsIngestionClientBuilder + implements ConfigurationTrait, HttpTrait, + EndpointTrait, TokenCredentialTrait { private static final ClientLogger LOGGER = new ClientLogger(LogsIngestionClientBuilder.class); - private final IngestionUsingDataCollectionRulesClientBuilder innerLogBuilder = - new IngestionUsingDataCollectionRulesClientBuilder(); + private final IngestionUsingDataCollectionRulesClientBuilder innerLogBuilder + = new IngestionUsingDataCollectionRulesClientBuilder(); private String endpoint; private TokenCredential tokenCredential; - /** * Creates a new instance of {@link LogsIngestionClientBuilder}. */ @@ -75,9 +76,9 @@ public LogsIngestionClientBuilder() { } - /** * Sets the data collection endpoint. + * * @param endpoint the data collection endpoint. * @return the updated {@link LogsIngestionClientBuilder}. */ @@ -89,7 +90,8 @@ public LogsIngestionClientBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } catch (MalformedURLException exception) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'endpoint' must be a valid URL.", exception)); + throw LOGGER.logExceptionAsError( + new IllegalArgumentException("'endpoint' must be a valid URL.", exception)); } } @@ -131,6 +133,7 @@ public LogsIngestionClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) /** * Sets The retry policy that will attempt to retry failed requests, if applicable. + * * @param retryPolicy the retryPolicy value. * @return the updated {@link LogsIngestionClientBuilder}. */ @@ -172,7 +175,6 @@ public LogsIngestionClientBuilder credential(TokenCredential tokenCredential) { return this; } - /** * Sets the audience for the authorization scope of log ingestion clients. If this value is not set, the default * audience will be the azure public cloud. @@ -202,12 +204,14 @@ public LogsIngestionClientBuilder clientOptions(ClientOptions clientOptions) { * @return the updated {@link LogsIngestionClientBuilder}. */ public LogsIngestionClientBuilder serviceVersion(LogsIngestionServiceVersion serviceVersion) { - innerLogBuilder.serviceVersion(IngestionUsingDataCollectionRulesServiceVersion.valueOf(serviceVersion.getVersion())); + innerLogBuilder.serviceVersion( + IngestionUsingDataCollectionRulesServiceVersion.valueOf(serviceVersion.getVersion())); return this; } /** * Creates a synchronous client with the configured options in this builder. + * * @return A synchronous {@link LogsIngestionClient}. */ public LogsIngestionClient buildClient() { @@ -222,6 +226,7 @@ public LogsIngestionClient buildClient() { /** * Creates an asynchronous client with the configured options in this builder. + * * @return An asynchronous {@link LogsIngestionAsyncClient}. */ public LogsIngestionAsyncClient buildAsyncClient() { diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionServiceVersion.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionServiceVersion.java index efb51b44d058..7405124c36b2 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionServiceVersion.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/LogsIngestionServiceVersion.java @@ -14,7 +14,7 @@ public enum LogsIngestionServiceVersion implements ServiceVersion { */ V2023_01_01("2023-01-01"); - String version; + final String version; /** * The service version. diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Batcher.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Batcher.java index 8d7e3769e09f..39f5786372f8 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Batcher.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Batcher.java @@ -10,7 +10,6 @@ import com.azure.json.JsonProviders; import com.azure.json.JsonWriter; import com.azure.monitor.ingestion.models.LogsUploadOptions; - import reactor.core.publisher.Flux; import java.io.ByteArrayOutputStream; @@ -30,7 +29,7 @@ import static com.azure.monitor.ingestion.implementation.Utils.gzipRequest; /** - * Provides iterator and streams for batches over log objects. + * Provides iterator and streams for batches over log objects. */ public class Batcher implements Iterator { private static final ClientLogger LOGGER = new ClientLogger(Batcher.class); @@ -139,7 +138,7 @@ private LogsIngestionRequest nextInternal() throws IOException { private LogsIngestionRequest createRequest(boolean last) throws IOException { try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - JsonWriter writer = JsonProviders.createWriter(byteArrayOutputStream)) { + JsonWriter writer = JsonProviders.createWriter(byteArrayOutputStream)) { writer.writeStartArray(); for (String log : serializedLogs) { writer.writeRawValue(log); @@ -161,7 +160,6 @@ private static ObjectSerializer getSerializer(LogsUploadOptions options) { return options.getObjectSerializer(); } - return DEFAULT_SERIALIZER; + return DEFAULT_SERIALIZER; } - } diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Utils.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Utils.java index 53474ba27e62..def73f52078e 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Utils.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/Utils.java @@ -17,7 +17,6 @@ public final class Utils { public static final long MAX_REQUEST_PAYLOAD_SIZE = 1024 * 1024; // 1 MB - public static final String CONTENT_ENCODING = "Content-Encoding"; public static final String GZIP = "gzip"; private static final ClientLogger LOGGER = new ClientLogger(Utils.class); @@ -58,9 +57,7 @@ public static int getConcurrency(LogsUploadOptions options) { * @return {@link ExecutorService} instance. */ public static ExecutorService createThreadPool() { - - return new ThreadPoolExecutor(0, MAX_CONCURRENCY, - 60L, TimeUnit.SECONDS, new SynchronousQueue<>()); + return new ThreadPoolExecutor(0, MAX_CONCURRENCY, 60L, TimeUnit.SECONDS, new SynchronousQueue<>()); } /** diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/models/LogsUploadOptions.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/models/LogsUploadOptions.java index eac3dea5ac73..387fbc8149ea 100644 --- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/models/LogsUploadOptions.java +++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/models/LogsUploadOptions.java @@ -70,7 +70,8 @@ public Consumer getLogsUploadErrorConsumer() { /** * Sets the error handler that is called when a request to the Azure Monitor service to upload logs fails. - * @param logsUploadErrorConsumer the error handler that is called when a request to the Azure Monitor service to upload logs fails. + * @param logsUploadErrorConsumer the error handler that is called when a request to the Azure Monitor service to + * upload logs fails. * @return the updated {@link LogsUploadOptions} instance. */ public LogsUploadOptions setLogsUploadErrorConsumer(Consumer logsUploadErrorConsumer) {