Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Commit 6ea5682

Browse files
Updated samples
1 parent f450ba3 commit 6ea5682

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/main/java/com/azure/cosmos/examples/diagnostics/async/CosmosDiagnosticsQuickStartAsync.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ private void diagnosticsDemo() throws Exception {
6969

7070
logger.info("Using Azure Cosmos DB endpoint: {}", AccountSettings.HOST);
7171

72-
// Create diagnostics threshold
72+
// Create Diagnostics threshold
7373
CosmosDiagnosticsThresholds cosmosDiagnosticsThresholds = new CosmosDiagnosticsThresholds();
74-
cosmosDiagnosticsThresholds.setPayloadSizeThreshold(10000);
7574
// For demo purposes, we will reduce the threshold so to log all diagnostics
7675
// NOTE: Do not use the same thresholds for production
76+
cosmosDiagnosticsThresholds.setPayloadSizeThreshold(10);
7777
cosmosDiagnosticsThresholds.setPointOperationLatencyThreshold(Duration.ofMillis(10));
7878
cosmosDiagnosticsThresholds.setNonPointOperationLatencyThreshold(Duration.ofMillis(10));
7979
cosmosDiagnosticsThresholds.setRequestChargeThreshold(5f);
@@ -117,7 +117,7 @@ private void createDatabaseIfNotExists() throws Exception {
117117
CosmosDatabaseResponse cosmosDatabaseResponse = databaseResponseMono.block();
118118

119119
CosmosDiagnostics diagnostics = cosmosDatabaseResponse.getDiagnostics();
120-
// logger.info("Create database diagnostics : {}", diagnostics);
120+
logger.info("Create database diagnostics : {}", diagnostics);
121121

122122
database = client.getDatabase(cosmosDatabaseResponse.getProperties().getId());
123123

@@ -140,7 +140,7 @@ private void createContainerIfNotExists() throws Exception {
140140
throughputProperties);
141141
CosmosContainerResponse cosmosContainerResponse = containerResponseMono.block();
142142
CosmosDiagnostics diagnostics = cosmosContainerResponse.getDiagnostics();
143-
// logger.info("Create container diagnostics : {}", diagnostics);
143+
logger.info("Create container diagnostics : {}", diagnostics);
144144
container = database.getContainer(cosmosContainerResponse.getProperties().getId());
145145

146146
logger.info("Done.");
@@ -163,7 +163,7 @@ private void createDocument() throws Exception {
163163

164164
CosmosItemResponse<Family> itemResponse = itemResponseMono.block();
165165
CosmosDiagnostics diagnostics = itemResponse.getDiagnostics();
166-
// logger.info("Create item diagnostics : {}", diagnostics);
166+
logger.info("Create item diagnostics : {}", diagnostics);
167167

168168
logger.info("Done.");
169169
}
@@ -178,7 +178,7 @@ private void readDocumentById() throws Exception {
178178

179179
CosmosItemResponse<Family> familyCosmosItemResponse = itemResponseMono.block();
180180
CosmosDiagnostics diagnostics = familyCosmosItemResponse.getDiagnostics();
181-
// logger.info("Read item diagnostics : {}", diagnostics);
181+
logger.info("Read item diagnostics : {}", diagnostics);
182182

183183
Family family = familyCosmosItemResponse.getItem();
184184

@@ -198,7 +198,7 @@ private void readDocumentDoesntExist() throws Exception {
198198
new PartitionKey("bad-lastName"), Family.class).block();
199199
} catch (CosmosException cosmosException) {
200200
CosmosDiagnostics diagnostics = cosmosException.getDiagnostics();
201-
// logger.info("Read item exception diagnostics : {}", diagnostics);
201+
logger.info("Read item exception diagnostics : {}", diagnostics);
202202
}
203203

204204
logger.info("Done.");
@@ -214,13 +214,13 @@ private void queryDocuments() throws Exception {
214214

215215
// Add handler to capture diagnostics
216216
filteredFamilies = filteredFamilies.handle(familyFeedResponse -> {
217-
// logger.info("Query Item diagnostics through handler : {}", familyFeedResponse.getCosmosDiagnostics());
217+
logger.info("Query Item diagnostics through handler : {}", familyFeedResponse.getCosmosDiagnostics());
218218
});
219219

220220
// Or capture diagnostics through byPage() APIs.
221221
filteredFamilies.byPage().toIterable().forEach(familyFeedResponse -> {
222-
// logger.info("Query item diagnostics through iterableByPage : {}", familyFeedResponse
223-
// .getCosmosDiagnostics());
222+
logger.info("Query item diagnostics through iterableByPage : {}",
223+
familyFeedResponse.getCosmosDiagnostics());
224224
});
225225

226226
logger.info("Done.");
@@ -241,8 +241,8 @@ private void replaceDocument() throws Exception {
241241

242242
CosmosItemResponse<Family> itemResponse = itemResponseMono.block();
243243
CosmosDiagnostics diagnostics = itemResponse.getDiagnostics();
244-
// logger.info("Replace item diagnostics : {}", diagnostics);
245-
// logger.info("Request charge of replace operation: {} RU", itemResponse.getRequestCharge());
244+
logger.info("Replace item diagnostics : {}", diagnostics);
245+
logger.info("Request charge of replace operation: {} RU", itemResponse.getRequestCharge());
246246

247247
logger.info("Done.");
248248
}
@@ -261,7 +261,7 @@ private void upsertDocument() throws Exception {
261261

262262
CosmosItemResponse<Family> itemResponse = itemResponseMono.block();
263263
CosmosDiagnostics diagnostics = itemResponse.getDiagnostics();
264-
// logger.info("Upsert item diagnostics : {}", diagnostics);
264+
logger.info("Upsert item diagnostics : {}", diagnostics);
265265

266266
logger.info("Done.");
267267
}
@@ -276,7 +276,7 @@ private void deleteDocument() throws Exception {
276276

277277
CosmosItemResponse<Object> itemResponse = itemResponseMono.block();
278278
CosmosDiagnostics diagnostics = itemResponse.getDiagnostics();
279-
// logger.info("Delete item diagnostics : {}", diagnostics);
279+
logger.info("Delete item diagnostics : {}", diagnostics);
280280

281281
logger.info("Done.");
282282
}
@@ -288,7 +288,7 @@ private void deleteDatabase() throws Exception {
288288
// Delete database
289289
CosmosDatabaseResponse dbResp =
290290
client.getDatabase(databaseName).delete(new CosmosDatabaseRequestOptions()).block();
291-
// logger.info("Status code for database delete: {}", dbResp.getStatusCode());
291+
logger.info("Status code for database delete: {}", dbResp.getStatusCode());
292292

293293
logger.info("Done.");
294294
}

src/main/java/com/azure/cosmos/examples/diagnostics/sync/CosmosDiagnosticsQuickStart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ private void diagnosticsDemo() throws Exception {
7070

7171
// Create diagnostics threshold
7272
CosmosDiagnosticsThresholds cosmosDiagnosticsThresholds = new CosmosDiagnosticsThresholds();
73-
cosmosDiagnosticsThresholds.setPayloadSizeThreshold(10000);
7473
// For demo purposes, we will reduce the threshold so to log all diagnostics
7574
// NOTE: Do not use the same thresholds for production
75+
cosmosDiagnosticsThresholds.setPayloadSizeThreshold(10);
7676
cosmosDiagnosticsThresholds.setPointOperationLatencyThreshold(Duration.ofMillis(10));
7777
cosmosDiagnosticsThresholds.setNonPointOperationLatencyThreshold(Duration.ofMillis(10));
7878
cosmosDiagnosticsThresholds.setRequestChargeThreshold(5f);

0 commit comments

Comments
 (0)