Skip to content

Commit

Permalink
CLient telemetry miscellaneous fixes (Azure#18543)
Browse files Browse the repository at this point in the history
  • Loading branch information
simplynaveen20 authored Jan 11, 2021
1 parent b37e6c6 commit 4afcfd9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void end(int statusCode, Throwable throwable, Context context) {
tracer.end(statusCode, throwable, context);
}

public void fillClientTelemetry(CosmosAsyncClient cosmosAsyncClient,
private void fillClientTelemetry(CosmosAsyncClient cosmosAsyncClient,
CosmosDiagnostics cosmosDiagnostics,
int statusCode,
Integer objectSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ClientTelemetry {
private HttpClient httpClient;
private final ScheduledThreadPoolExecutor scheduledExecutorService = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory());
private final Scheduler scheduler = Schedulers.fromExecutor(scheduledExecutorService);
private static final Logger logger = LoggerFactory.getLogger(GlobalEndpointManager.class);
private static final Logger logger = LoggerFactory.getLogger(ClientTelemetry.class);
private volatile boolean isClosed;
private volatile boolean isClientTelemetryEnabled;
private static String AZURE_VM_METADATA = "http://169.254.169.254:80/metadata/instance?api-version=2020-06-01";
Expand Down Expand Up @@ -94,15 +94,15 @@ public ClientTelemetryInfo getClientTelemetryInfo() {
return clientTelemetryInfo;
}

public static void recordValue(DoubleHistogram doubleHistogram, long value) {
public static void recordValue(ConcurrentDoubleHistogram doubleHistogram, long value) {
try {
doubleHistogram.recordValue(value);
} catch (Exception ex) {
logger.warn("Error while recording value for client telemetry. ", ex);
}
}

public static void recordValue(DoubleHistogram doubleHistogram, double value) {
public static void recordValue(ConcurrentDoubleHistogram doubleHistogram, double value) {
try {
doubleHistogram.recordValue(value);
} catch (Exception ex) {
Expand Down Expand Up @@ -178,7 +178,7 @@ private void loadAzureVmMetaData() {
private void clearDataForNextRun() {
this.clientTelemetryInfo.getOperationInfoMap().clear();
this.clientTelemetryInfo.getCacheRefreshInfoMap().clear();
for (DoubleHistogram histogram : this.clientTelemetryInfo.getSystemInfoMap().values()) {
for (ConcurrentDoubleHistogram histogram : this.clientTelemetryInfo.getSystemInfoMap().values()) {
histogram.reset();
}
}
Expand Down Expand Up @@ -217,17 +217,18 @@ private void readHistogram() {
}
}

private void fillMetricsInfo(ReportPayload payload, DoubleHistogram histogram) {
payload.getMetricInfo().setCount(histogram.getTotalCount());
payload.getMetricInfo().setMax(histogram.getMaxValue());
payload.getMetricInfo().setMin(histogram.getMinValue());
payload.getMetricInfo().setMean(histogram.getMean());
private void fillMetricsInfo(ReportPayload payload, ConcurrentDoubleHistogram histogram) {
DoubleHistogram copyHistogram = histogram.copy();
payload.getMetricInfo().setCount(copyHistogram.getTotalCount());
payload.getMetricInfo().setMax(copyHistogram.getMaxValue());
payload.getMetricInfo().setMin(copyHistogram.getMinValue());
payload.getMetricInfo().setMean(copyHistogram.getMean());
Map<Double, Double> percentile = new HashMap<>();
percentile.put(PERCENTILE_50, histogram.getValueAtPercentile(PERCENTILE_50));
percentile.put(PERCENTILE_90, histogram.getValueAtPercentile(PERCENTILE_90));
percentile.put(PERCENTILE_95, histogram.getValueAtPercentile(PERCENTILE_95));
percentile.put(PERCENTILE_99, histogram.getValueAtPercentile(PERCENTILE_99));
percentile.put(PERCENTILE_999, histogram.getValueAtPercentile(PERCENTILE_999));
percentile.put(PERCENTILE_50, copyHistogram.getValueAtPercentile(PERCENTILE_50));
percentile.put(PERCENTILE_90, copyHistogram.getValueAtPercentile(PERCENTILE_90));
percentile.put(PERCENTILE_95, copyHistogram.getValueAtPercentile(PERCENTILE_95));
percentile.put(PERCENTILE_99, copyHistogram.getValueAtPercentile(PERCENTILE_99));
percentile.put(PERCENTILE_999, copyHistogram.getValueAtPercentile(PERCENTILE_999));
payload.getMetricInfo().setPercentiles(percentile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import com.azure.cosmos.ConnectionMode;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.HdrHistogram.ConcurrentDoubleHistogram;
import org.HdrHistogram.DoubleHistogram;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

@JsonSerialize(using = ClientTelemetrySerializer.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.
package com.azure.cosmos.implementation.clientTelemetry;

import java.util.HashMap;
import java.util.Map;

public class MetricInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@


import com.azure.cosmos.implementation.Configs;
import com.azure.cosmos.implementation.clientTelemetry.ClientTelemetry;
import org.HdrHistogram.ConcurrentDoubleHistogram;
import org.HdrHistogram.DoubleHistogram;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private Flux<FeedResponse<T>> byPage(CosmosPagedFluxOptions pagedFluxOptions, Co
});
}

public void fillClientTelemetry(CosmosAsyncClient cosmosAsyncClient,
private void fillClientTelemetry(CosmosAsyncClient cosmosAsyncClient,
int statusCode,
String containerId,
String databaseId,
Expand Down

0 comments on commit 4afcfd9

Please sign in to comment.