Skip to content

Commit ad5efe0

Browse files
committed
chore: Resolve merge conflicts
1 parent abd527e commit ad5efe0

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

java-datastore/samples/snippets/src/main/java/com/example/datastore/DatastoreMetricsSample.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
* firestore.googleapis.com/Database} monitored resource. The {@code service} metric label is set to
3838
* {@code datastore.googleapis.com} to distinguish Datastore traffic from Firestore.
3939
*
40-
* <p>No configuration is required to enable metrics — they are on by default. To disable them, set
41-
* {@link DatastoreOpenTelemetryOptions#setExportBuiltinMetricsToGoogleCloudMonitoring(boolean)} to
42-
* {@code false}, or set the environment variable {@code DATASTORE_ENABLE_METRICS=false}.
40+
* <p>Built-in metrics are currently disabled by default until the Cloud Monitoring namespace is
41+
* fully deployed. To enable them, set {@link
42+
* DatastoreOpenTelemetryOptions.Builder#setExportBuiltinMetricsToGoogleCloudMonitoring(boolean)} to
43+
* {@code true}, or set the environment variable {@code DATASTORE_ENABLE_METRICS=true}.
4344
*
4445
* <p>Metrics recorded by this sample:
4546
*
@@ -73,17 +74,23 @@ public static void main(String[] args) throws Exception {
7374

7475
static void runSample(String projectId, String databaseId, String kind) throws Exception {
7576
// [START datastore_client_side_metrics_default]
76-
// Built-in metrics are exported to Cloud Monitoring by default.
77-
// No additional configuration is required.
77+
// Built-in metrics are disabled by default. Enable them explicitly.
7878
DatastoreOptions options =
79-
DatastoreOptions.newBuilder().setProjectId(projectId).setDatabaseId(databaseId).build();
79+
DatastoreOptions.newBuilder()
80+
.setProjectId(projectId)
81+
.setDatabaseId(databaseId)
82+
.setOpenTelemetryOptions(
83+
DatastoreOpenTelemetryOptions.newBuilder()
84+
.setExportBuiltinMetricsToGoogleCloudMonitoring(true)
85+
.build())
86+
.build();
8087
// [END datastore_client_side_metrics_default]
8188

8289
try (Datastore datastore = options.getService()) {
8390
System.out.printf(
8491
"Connected to project=%s database=%s%n", projectId, databaseId);
8592
System.out.println(
86-
"Built-in metrics are enabled by default and will be exported to"
93+
"Built-in metrics are explicitly enabled and will be exported to"
8794
+ " Google Cloud Monitoring under custom.googleapis.com/internal/client/*");
8895

8996
runTransactionFlow(datastore, kind);

java-datastore/samples/snippets/src/test/java/com/example/datastore/DatastoreMetricsSampleIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void tearDown() {
8585
public void testTransactionFlowRecordsMetrics() throws Exception {
8686
DatastoreMetricsSample.runSample(PROJECT_ID, DATABASE_ID, kind);
8787

88-
systemsOutRule.assertContains("Built-in metrics are enabled by default");
88+
systemsOutRule.assertContains("Built-in metrics are explicitly enabled");
8989
systemsOutRule.assertContains("Inserted entity");
9090
systemsOutRule.assertContains("Transaction committed");
9191
systemsOutRule.assertContains("transaction_latency and transaction_attempt_count metrics recorded");

0 commit comments

Comments
 (0)