Skip to content

Commit c237386

Browse files
committed
chore: Add comments for public methods for otel
1 parent ada560a commit c237386

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public boolean isMetricsEnabled() {
6868
/**
6969
* Returns whether built-in metrics should be exported to Google Cloud Monitoring.
7070
*
71-
* <p>When enabled, client-side metrics are automatically exported to Google Cloud Monitoring using
72-
* the Cloud Monitoring API. This is independent of the custom OpenTelemetry backend configured via
73-
* {@link #getOpenTelemetry()}.
71+
* <p>When enabled, client-side metrics are automatically exported to Google Cloud Monitoring
72+
* using the Cloud Monitoring API. This is independent of the custom OpenTelemetry backend
73+
* configured via {@link #getOpenTelemetry()}.
7474
*
7575
* @return {@code true} if built-in metrics export to Cloud Monitoring is enabled, {@code false}
7676
* otherwise.

java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/MetricsRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static MetricsRecorder getInstance(@Nonnull DatastoreOptions datastoreOptions) {
9494
OpenTelemetry builtInOtel =
9595
DatastoreBuiltInMetricsProvider.INSTANCE.getOrCreateOpenTelemetry(
9696
datastoreOptions.getProjectId(),
97+
datastoreOptions.getDatabaseId(),
9798
datastoreOptions.getCredentials(),
9899
null,
99100
datastoreOptions.getUniverseDomain());
@@ -126,5 +127,4 @@ static MetricsRecorder getInstance(@Nonnull DatastoreOptions datastoreOptions) {
126127
}
127128
return new CompositeMetricsRecorder(recorders);
128129
}
129-
130130
}

java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TelemetryConstants.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,17 @@ public class TelemetryConstants {
4747
// Monitored resource type for Cloud Monitoring
4848
public static final String DATASTORE_RESOURCE_TYPE = "firestore.googleapis.com/Database";
4949

50-
// Resource label keys
51-
public static final String RESOURCE_KEY_RESOURCE_CONTAINER = "resource_container";
52-
public static final String RESOURCE_KEY_LOCATION = "location";
53-
public static final String RESOURCE_KEY_DATABASE_ID = "database_id";
50+
// Resource label keys for firestore.googleapis.com/Database
51+
public static final String RESOURCE_LABEL_PROJECT_ID = "project_id";
52+
public static final String RESOURCE_LABEL_DATABASE_ID = "database_id";
53+
public static final String RESOURCE_LABEL_LOCATION = "location";
5454
public static final Set<String> DATASTORE_RESOURCE_LABELS =
5555
ImmutableSet.of(
56-
RESOURCE_KEY_RESOURCE_CONTAINER, RESOURCE_KEY_LOCATION, RESOURCE_KEY_DATABASE_ID);
56+
RESOURCE_LABEL_PROJECT_ID, RESOURCE_LABEL_DATABASE_ID, RESOURCE_LABEL_LOCATION);
5757

5858
// Resource attribute keys (used on OTel Resource)
5959
public static final AttributeKey<String> PROJECT_ID_KEY = AttributeKey.stringKey("project_id");
60+
public static final AttributeKey<String> DATABASE_ID_KEY = AttributeKey.stringKey("database_id");
6061
public static final AttributeKey<String> LOCATION_ID_KEY = AttributeKey.stringKey("location");
6162

6263
// Metric attribute keys (used on metric data points)

java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TelemetryUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public static void recordOperationMetrics(
7474
String methodName,
7575
String status) {
7676
if (methodName != null
77-
&& !TelemetryConstants.Transport.GRPC.getTransport()
77+
&& !TelemetryConstants.Transport.GRPC
78+
.getTransport()
7879
.equals(TelemetryConstants.getTransportName(datastoreOptions.getTransportOptions()))) {
7980
Map<String, String> attributes = buildMetricAttributes(datastoreOptions, methodName, status);
8081
metricsRecorder.recordOperationLatency(
@@ -110,7 +111,8 @@ public static <T> Callable<T> attemptMetricsCallable(
110111
status = DatastoreException.extractStatusCode(e);
111112
throw e;
112113
} finally {
113-
if (!TelemetryConstants.Transport.GRPC.getTransport()
114+
if (!TelemetryConstants.Transport.GRPC
115+
.getTransport()
114116
.equals(TelemetryConstants.getTransportName(datastoreOptions.getTransportOptions()))) {
115117
Map<String, String> attributes =
116118
buildMetricAttributes(datastoreOptions, methodName, status);

0 commit comments

Comments
 (0)