Skip to content

Commit 5e51bf3

Browse files
xinlian12annie-mac
andauthored
supportEnableClientTelemetryForBenchmark (Azure#30059)
* addSupportForEnableClientTelemetryInBenchmark Co-authored-by: annie-mac <[email protected]>
1 parent c7880d3 commit 5e51bf3

File tree

9 files changed

+63
-13
lines changed

9 files changed

+63
-13
lines changed

sdk/cosmos/azure-cosmos-benchmark/ctl/run_benchmark.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ else
6363
number_of_precreated_documents=$ctl_number_of_precreated_documents
6464
fi
6565

66+
if [ -z "$ctl_client_telemetry_enabled" ]; then
67+
client_telemetry_enabled=true
68+
else
69+
client_telemetry_enabled=$ctl_client_telemetry_enabled
70+
fi
71+
72+
if [ -z "$ctl_client_telemetry_endpoint" ]; then
73+
client_telemetry_endpoint=https://tools.cosmos.azure.com/api/clienttelemetry/trace
74+
else
75+
client_telemetry_enabled=$ctl_client_telemetry_endpoint
76+
fi
77+
6678
connection_mode=Direct
6779
gateway_connection_poolsize=5
6880

@@ -95,9 +107,9 @@ additional_benchmark_options="-documentDataFieldSize 10 -documentDataFieldCount
95107
additional_benchmark_options="$additional_benchmark_options -maxConnectionPoolSize $gateway_connection_poolsize"
96108

97109
if [ -z "$ctl_graphite_endpoint" ]; then
98-
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -DCOSMOS.CLIENT_TELEMETRY_ENDPOINT=$ctl_client_telemetry_endpoint -jar "$jar_file" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryReadManyPct "$read_write_query_readmany_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -numberOfPreCreatedDocuments $number_of_precreated_documents -preferredRegionsList "$ctl_preferred_regions" $additional_benchmark_options 2>&1 | tee -a "$log_filename"
110+
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -jar "$jar_file" -clientTelemetryEnabled="$client_telemetry_enabled" -clientTelemetryEndpoint="$client_telemetry_endpoint" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryReadManyPct "$read_write_query_readmany_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -numberOfPreCreatedDocuments $number_of_precreated_documents -preferredRegionsList "$ctl_preferred_regions" $additional_benchmark_options 2>&1 | tee -a "$log_filename"
99111
else
100-
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -DCOSMOS.CLIENT_TELEMETRY_ENDPOINT=$ctl_client_telemetry_endpoint -jar "$jar_file" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryReadManyPct "$read_write_query_readmany_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -graphiteEndpoint $ctl_graphite_endpoint -numberOfPreCreatedDocuments $number_of_precreated_documents -preferredRegionsList "$ctl_preferred_regions" $ctl_accountNameInGraphiteReporter $additional_benchmark_options 2>&1 | tee -a "$log_filename"
112+
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -jar "$jar_file" -clientTelemetryEnabled="$client_telemetry_enabled" -clientTelemetryEndpoint="$client_telemetry_endpoint" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryReadManyPct "$read_write_query_readmany_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -graphiteEndpoint $ctl_graphite_endpoint -numberOfPreCreatedDocuments $number_of_precreated_documents -preferredRegionsList "$ctl_preferred_regions" $ctl_accountNameInGraphiteReporter $additional_benchmark_options 2>&1 | tee -a "$log_filename"
101113
fi
102114

103115
end=$(date +%s)

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsynReadWithMultipleClients.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ private void createClients() {
197197
.preferredRegions(this.configuration.getPreferredRegionsList())
198198
.consistencyLevel(configuration.getConsistencyLevel())
199199
.connectionSharingAcrossClientsEnabled(true)
200-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(configuration.isContentResponseOnWriteEnabled()));
200+
.contentResponseOnWriteEnabled(configuration.isContentResponseOnWriteEnabled())
201+
.clientTelemetryEnabled(configuration.isClientTelemetryEnabled());
202+
201203
if (this.configuration.getConnectionMode().equals(ConnectionMode.DIRECT)) {
202204
cosmosClientBuilder = cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig());
203205
} else {

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsyncBenchmark.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ abstract class AsyncBenchmark<T> {
8181
.key(cfg.getMasterKey())
8282
.preferredRegions(cfg.getPreferredRegionsList())
8383
.consistencyLevel(cfg.getConsistencyLevel())
84-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
84+
.contentResponseOnWriteEnabled(cfg.isContentResponseOnWriteEnabled())
85+
.clientTelemetryEnabled(cfg.isClientTelemetryEnabled());
86+
8587
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {
8688
cosmosClientBuilder = cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig());
8789
} else {

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Configuration.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ public Duration convert(String value) {
186186
@Parameter(names = "-accountNameInGraphiteReporter", description = "if set, account name with be appended in graphite reporter")
187187
private boolean accountNameInGraphiteReporter = false;
188188

189+
@Parameter(names = "-clientTelemetryEnabled", description = "Switch to enable client telemetry")
190+
private String clientTelemetryEnabled = String.valueOf(false);
191+
192+
@Parameter(names = "-clientTelemetrySchedulingInSeconds", description = "Client telemetry scheduling intervals in seconds")
193+
private int clientTelemetrySchedulingInSeconds = 10 * 60;
194+
195+
@Parameter(names = "-clientTelemetryEndpoint", description = "Client Telemetry Juno endpoint")
196+
private String clientTelemetryEndpoint;
197+
189198
public enum Environment {
190199
Daily, // This is the CTL environment where we run the workload for a fixed number of hours
191200
Staging; // This is the CTL environment where the worload runs as a long running job
@@ -355,8 +364,8 @@ public ConsistencyLevel getConsistencyLevel() {
355364
return consistencyLevel;
356365
}
357366

358-
public String isContentResponseOnWriteEnabled() {
359-
return contentResponseOnWriteEnabled;
367+
public boolean isContentResponseOnWriteEnabled() {
368+
return Boolean.parseBoolean(contentResponseOnWriteEnabled);
360369
}
361370

362371
public String getDatabaseId() {
@@ -489,6 +498,18 @@ public boolean isEncryptionEnabled() {
489498
return encryptionEnabled;
490499
}
491500

501+
public boolean isClientTelemetryEnabled() {
502+
return Boolean.parseBoolean(clientTelemetryEnabled);
503+
}
504+
505+
public String getClientTelemetryEndpoint() {
506+
return clientTelemetryEndpoint;
507+
}
508+
509+
public int getClientTelemetrySchedulingInSeconds() {
510+
return clientTelemetrySchedulingInSeconds;
511+
}
512+
492513
public void tryGetValuesFromSystem() {
493514
serviceEndpoint = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("SERVICE_END_POINT")),
494515
serviceEndpoint);

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Main.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public static void main(String[] args) throws Exception {
3838
return;
3939
}
4040

41+
if (cfg.isClientTelemetryEnabled()) {
42+
System.setProperty("COSMOS.CLIENT_TELEMETRY_ENDPOINT", cfg.getClientTelemetryEndpoint());
43+
System.setProperty("COSMOS.CLIENT_TELEMETRY_SCHEDULING_IN_SECONDS", String.valueOf(cfg.getClientTelemetrySchedulingInSeconds()));
44+
}
45+
4146
validateConfiguration(cfg);
4247

4348
if (cfg.isSync()) {
@@ -69,7 +74,7 @@ private static void validateConfiguration(Configuration cfg) {
6974
case WriteThroughput:
7075
break;
7176
default:
72-
if (!Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled())) {
77+
if (!cfg.isContentResponseOnWriteEnabled()) {
7378
throw new IllegalArgumentException("contentResponseOnWriteEnabled parameter can only be set to false " +
7479
"for write latency and write throughput operations");
7580
}

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/SyncBenchmark.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public T apply(T o, Throwable throwable) {
109109
.preferredRegions(cfg.getPreferredRegionsList())
110110
.key(cfg.getMasterKey())
111111
.consistencyLevel(cfg.getConsistencyLevel())
112-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
112+
.contentResponseOnWriteEnabled(cfg.isContentResponseOnWriteEnabled())
113+
.clientTelemetryEnabled(cfg.isClientTelemetryEnabled());
114+
113115
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {
114116
cosmosClientBuilder = cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig());
115117
} else {

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/ctl/AsyncCtlWorkload.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ public AsyncCtlWorkload(Configuration cfg) {
9696
.key(cfg.getMasterKey())
9797
.preferredRegions(cfg.getPreferredRegionsList())
9898
.consistencyLevel(cfg.getConsistencyLevel())
99-
.clientTelemetryEnabled(true)
100-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
99+
.contentResponseOnWriteEnabled(cfg.isContentResponseOnWriteEnabled())
100+
.clientTelemetryEnabled(cfg.isClientTelemetryEnabled());
101+
101102
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {
102103
cosmosClientBuilder = cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig());
103104
} else {

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/encryption/AsyncEncryptionBenchmark.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ public abstract class AsyncEncryptionBenchmark<T> {
116116
.endpoint(cfg.getServiceEndpoint())
117117
.key(cfg.getMasterKey())
118118
.consistencyLevel(cfg.getConsistencyLevel())
119-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
119+
.contentResponseOnWriteEnabled(cfg.isContentResponseOnWriteEnabled())
120+
.clientTelemetryEnabled(cfg.isClientTelemetryEnabled());
121+
120122
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {
121123
cosmosClientBuilder = cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig());
122124
} else {

sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/linkedin/AsyncClientFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public static CosmosAsyncClient buildAsyncClient(final Configuration cfg) {
4848
.key(cfg.getMasterKey())
4949
.consistencyLevel(cfg.getConsistencyLevel())
5050
.throttlingRetryOptions(DEFAULT_THROTTLING_RETRY_OPTIONS)
51-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
51+
.contentResponseOnWriteEnabled(cfg.isContentResponseOnWriteEnabled())
52+
.clientTelemetryEnabled(cfg.isClientTelemetryEnabled());
5253

5354
// Configure the Direct/Gateway mode
5455
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {
@@ -72,12 +73,14 @@ public static CosmosAsyncClient buildAsyncClient(final Configuration cfg) {
7273
*/
7374
public static CosmosAsyncClient buildBulkLoadAsyncClient(final Configuration cfg) {
7475
Preconditions.checkNotNull(cfg, "The Workload configuration defining the parameters can not be null");
76+
7577
final CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
7678
.endpoint(cfg.getServiceEndpoint())
7779
.key(cfg.getMasterKey())
7880
.consistencyLevel(ConsistencyLevel.EVENTUAL)
7981
.throttlingRetryOptions(BULKLOAD_THROTTLING_RETRY_OPTIONS)
80-
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
82+
.contentResponseOnWriteEnabled(cfg.isContentResponseOnWriteEnabled())
83+
.clientTelemetryEnabled(cfg.isClientTelemetryEnabled());
8184

8285
// Configure the Direct/Gateway mode
8386
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {

0 commit comments

Comments
 (0)