Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
30a7011
enable 4 metrics from GAX
milaGGL Aug 14, 2024
ed85413
format
milaGGL Aug 16, 2024
57084c4
add default otel
milaGGL Aug 21, 2024
571c095
format
milaGGL Aug 21, 2024
f4b8416
move constants out
milaGGL Aug 22, 2024
da0fe82
format
milaGGL Aug 23, 2024
61432eb
add additional attributes
milaGGL Aug 26, 2024
b5bfe5c
Merge branch 'main' into mila/client-side-metrics-demo
milaGGL Aug 26, 2024
f0a029d
add attributes to gax metrics
milaGGL Aug 27, 2024
5456038
Update BuiltinMetricsConstants.java
milaGGL Sep 4, 2024
5efaba6
remove current metrics implementation
milaGGL Sep 9, 2024
c0b4cc1
add custom exporter, add latency recorder
milaGGL Sep 11, 2024
3979331
use 2 otel instances
milaGGL Sep 18, 2024
a9d08b5
set custom apiTracerFactory to gax
milaGGL Sep 20, 2024
029bd8c
Merge branch 'main' into mila/client-side-metrics-demo2
milaGGL Sep 23, 2024
50e05fb
fix opentelemtry dependency version conflict issue
milaGGL Sep 23, 2024
53cd48a
use enabled/disabled style
milaGGL Sep 24, 2024
7adb9d6
modify access modifiers
milaGGL Sep 24, 2024
690e4ee
format
milaGGL Sep 24, 2024
e6f8ba6
rename boolean
milaGGL Sep 26, 2024
c4ca4ae
Merge branch 'main' into mila/client-side-metrics-demo2
milaGGL Sep 27, 2024
887221d
chore: generate libraries at Fri Sep 27 19:25:02 UTC 2024
cloud-java-bot Sep 27, 2024
a2c715a
Update pom.xml
milaGGL Sep 27, 2024
ed78182
resolve comments from proto
milaGGL Oct 1, 2024
e0d46be
e2E latency for runTransaction
milaGGL Oct 3, 2024
a72a685
Merge branch 'main' into mila/client-side-metrics-demo2
milaGGL Oct 4, 2024
92c83c1
chore: generate libraries at Fri Oct 4 14:44:19 UTC 2024
cloud-java-bot Oct 4, 2024
c5137c1
remove noise
milaGGL Oct 4, 2024
63b5bd3
reformat code
milaGGL Oct 4, 2024
ac424a6
re-format code
milaGGL Oct 7, 2024
52f428f
add documentations/comments
milaGGL Oct 8, 2024
c06b2cb
remove logger.info
milaGGL Oct 8, 2024
daf9fbe
record AggregationQuery firstResponseLatency
milaGGL Oct 10, 2024
1999ff7
Update BuiltinMetricsProvider.java
milaGGL Oct 10, 2024
6aa816b
add 2 new metrics
milaGGL Oct 16, 2024
81e349b
Merge branch 'main' into mila/client-side-metrics-demo2
milaGGL Oct 16, 2024
f4e36d9
resolve comments
milaGGL Oct 16, 2024
05e8efb
Update pom.xml
milaGGL Oct 16, 2024
b0b1687
remove duplicated tracing dependency
milaGGL Oct 16, 2024
4abbcf0
add opentelemetry-sdk-metrics dependency
milaGGL Oct 17, 2024
328855d
adjust end-to-end latency in streaming queries
milaGGL Oct 19, 2024
c619029
Merge branch 'mila/client-side-metrics-demo2' into mila/client-side-m…
milaGGL Oct 21, 2024
5e1fb4b
fix clirr error
milaGGL Oct 21, 2024
4a2a8d8
Merge branch 'mila/client-side-metrics-demo2' into mila/client-side-m…
milaGGL Oct 21, 2024
47f6b37
record serverSicdeTransaction
milaGGL Oct 22, 2024
4fa8874
add exportBuiltinMetricsToGoogleCloudMonitoring flag
milaGGL Oct 23, 2024
f988db9
Merge branch 'mila/client-side-metrics-demo2' into mila/client-side-m…
milaGGL Oct 28, 2024
cc3834d
create TransactionMetricsContext
milaGGL Oct 28, 2024
39e5293
refactor the metrics recorders to use enum
milaGGL Oct 28, 2024
f17a62b
remove TransactionMetricsContext
milaGGL Oct 28, 2024
0662da5
Update pom.xml
milaGGL Oct 29, 2024
48c5cd3
resolve comments
milaGGL Oct 31, 2024
65280fa
Update BuiltinMetricsProvider.java
milaGGL Oct 31, 2024
3ebd6e8
Merge branch 'main' into mila/client-side-metrics-transaction
milaGGL Nov 5, 2024
21172a1
remove protected from internalStream
milaGGL Nov 5, 2024
1b6d2cb
Update BuiltinMetricsProvider.java
milaGGL Nov 5, 2024
53a3705
format
milaGGL Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.cloud.Timestamp;
import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext;
import com.google.cloud.firestore.telemetry.TelemetryConstants;
import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType;
import com.google.cloud.firestore.telemetry.TraceUtil;
import com.google.cloud.firestore.telemetry.TraceUtil.Scope;
import com.google.cloud.firestore.v1.FirestoreSettings;
Expand Down Expand Up @@ -223,12 +224,12 @@ ApiFuture<T> getFuture() {
}

void deliverFirstResponse() {
metricsContext.recordFirstResponseLatency();
metricsContext.recordLatency(MetricType.FIRST_RESPONSE_LATENCY);
}

void deliverError(Throwable throwable) {
future.setException(throwable);
metricsContext.recordEndToEndLatency(throwable);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable);
}

void deliverResult(
Expand All @@ -238,7 +239,7 @@ void deliverResult(
try {
T result = processResult(serverData, readTime, metrics);
future.set(result);
metricsContext.recordEndToEndLatency();
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY);
} catch (Exception error) {
deliverError(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.api.gax.rpc.StatusCode.Code;
import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext;
import com.google.cloud.firestore.telemetry.TelemetryConstants;
import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType;
import com.google.cloud.firestore.telemetry.TraceUtil;
import com.google.cloud.firestore.telemetry.TraceUtil.Context;
import com.google.cloud.firestore.telemetry.TraceUtil.Scope;
Expand Down Expand Up @@ -935,10 +936,10 @@ private void sendBatchLocked(final BulkCommitBatch batch, final boolean flush) {
},
bulkWriterExecutor);
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.api.gax.rpc.ApiStreamObserver;
import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext;
import com.google.cloud.firestore.telemetry.TelemetryConstants;
import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType;
import com.google.cloud.firestore.telemetry.TraceUtil;
import com.google.cloud.firestore.telemetry.TraceUtil.Scope;
import com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse;
Expand Down Expand Up @@ -137,15 +138,15 @@ public ApiFuture<List<QueryPartition>> getPartitions(long desiredPartitionCount)
},
MoreExecutors.directExecutor());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (ApiException exception) {
span.end(exception);
metricsContext.recordEndToEndLatency(exception);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, exception);
throw FirestoreException.forApiException(exception);
} catch (Throwable throwable) {
span.end(throwable);
metricsContext.recordEndToEndLatency(throwable);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable);
throw throwable;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.cloud.firestore.spi.v1.FirestoreRpc;
import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext;
import com.google.cloud.firestore.telemetry.TelemetryConstants;
import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType;
import com.google.cloud.firestore.telemetry.TraceUtil;
import com.google.cloud.firestore.telemetry.TraceUtil.Scope;
import com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse;
Expand Down Expand Up @@ -184,15 +185,15 @@ public void remove() {
}
};
span.end();
metricsContext.recordEndToEndLatency();
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY);
return result;
} catch (ApiException exception) {
span.end(exception);
metricsContext.recordEndToEndLatency(exception);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, exception);
throw FirestoreException.forApiException(exception);
} catch (Throwable throwable) {
span.end(throwable);
metricsContext.recordEndToEndLatency(throwable);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable);
throw throwable;
}
}
Expand Down Expand Up @@ -229,11 +230,11 @@ public ApiFuture<DocumentReference> add(@Nonnull final Map<String, Object> field
ApiFutures.transform(
createFuture, writeResult -> documentReference, MoreExecutors.directExecutor());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.cloud.firestore.telemetry.MetricsUtil;
import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext;
import com.google.cloud.firestore.telemetry.TelemetryConstants;
import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType;
import com.google.cloud.firestore.telemetry.TraceUtil;
import com.google.cloud.firestore.telemetry.TraceUtil.Scope;
import com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse;
Expand Down Expand Up @@ -165,11 +166,11 @@ public ApiFuture<WriteResult> create(@Nonnull Map<String, Object> fields) {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.create(this, fields).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -191,11 +192,11 @@ public ApiFuture<WriteResult> create(@Nonnull Object pojo) {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.create(this, pojo).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -217,11 +218,11 @@ public ApiFuture<WriteResult> set(@Nonnull Map<String, Object> fields) {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.set(this, fields).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -246,11 +247,11 @@ public ApiFuture<WriteResult> set(
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.set(this, fields, options).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -272,11 +273,11 @@ public ApiFuture<WriteResult> set(@Nonnull Object pojo) {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.set(this, pojo).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -300,11 +301,11 @@ public ApiFuture<WriteResult> set(@Nonnull Object pojo, @Nonnull SetOptions opti
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.set(this, pojo, options).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -326,11 +327,11 @@ public ApiFuture<WriteResult> update(@Nonnull Map<String, Object> fields) {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.update(this, fields).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -354,11 +355,11 @@ public ApiFuture<WriteResult> update(@Nonnull Map<String, Object> fields, Precon
ApiFuture<WriteResult> result =
extractFirst(writeBatch.update(this, fields, options).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -384,11 +385,11 @@ public ApiFuture<WriteResult> update(
ApiFuture<WriteResult> result =
extractFirst(writeBatch.update(this, field, value, moreFieldsAndValues).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -414,11 +415,11 @@ public ApiFuture<WriteResult> update(
ApiFuture<WriteResult> result =
extractFirst(writeBatch.update(this, fieldPath, value, moreFieldsAndValues).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand Down Expand Up @@ -449,11 +450,11 @@ public ApiFuture<WriteResult> update(
extractFirst(
writeBatch.update(this, options, field, value, moreFieldsAndValues).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand Down Expand Up @@ -484,11 +485,11 @@ public ApiFuture<WriteResult> update(
extractFirst(
writeBatch.update(this, options, fieldPath, value, moreFieldsAndValues).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -509,11 +510,11 @@ public ApiFuture<WriteResult> delete(@Nonnull Precondition options) {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.delete(this, options).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -533,11 +534,11 @@ public ApiFuture<WriteResult> delete() {
WriteBatch writeBatch = rpcContext.getFirestore().batch();
ApiFuture<WriteResult> result = extractFirst(writeBatch.delete(this).commit());
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -558,11 +559,11 @@ public ApiFuture<DocumentSnapshot> get() {
try (Scope ignored = span.makeCurrent()) {
ApiFuture<DocumentSnapshot> result = extractFirst(rpcContext.getFirestore().getAll(this));
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand All @@ -585,11 +586,11 @@ public ApiFuture<DocumentSnapshot> get(FieldMask fieldMask) {
ApiFuture<DocumentSnapshot> result =
extractFirst(rpcContext.getFirestore().getAll(new DocumentReference[] {this}, fieldMask));
span.endAtFuture(result);
metricsContext.recordEndToEndLatencyAtFuture(result);
metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result);
return result;
} catch (Exception error) {
span.end(error);
metricsContext.recordEndToEndLatency(error);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error);
throw error;
}
}
Expand Down Expand Up @@ -641,11 +642,11 @@ public void remove() {
}
};
span.end();
metricsContext.recordEndToEndLatency();
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY);
return result;
} catch (ApiException exception) {
span.end(exception);
metricsContext.recordEndToEndLatency(exception);
metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, exception);
throw FirestoreException.forApiException(exception);
}
}
Expand Down
Loading