Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 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
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
5e1fb4b
fix clirr error
milaGGL Oct 21, 2024
4fa8874
add exportBuiltinMetricsToGoogleCloudMonitoring flag
milaGGL Oct 23, 2024
7deb0d6
Merge branch 'main' into mila/client-side-metrics-demo2
milaGGL Oct 29, 2024
637f878
Merge branch 'main' into mila/client-side-metrics-demo2
milaGGL Nov 4, 2024
8480fa8
Update clirr-ignored-differences.xml
milaGGL Nov 4, 2024
ef9baa8
add internalStream clirr change back
milaGGL Nov 4, 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
Prev Previous commit
Next Next commit
add exportBuiltinMetricsToGoogleCloudMonitoring flag
  • Loading branch information
milaGGL committed Oct 23, 2024
commit 4fa8874849155d31c62d0cc9bd8683b5b6a98d3f
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@
@BetaApi
public class FirestoreOpenTelemetryOptions {
private final boolean tracingEnabled;
private final boolean exportBuiltinMetricsToGoogleCloudMonitoring;
private final @Nullable OpenTelemetry openTelemetry;

FirestoreOpenTelemetryOptions(Builder builder) {
this.tracingEnabled = builder.tracingEnabled;
this.exportBuiltinMetricsToGoogleCloudMonitoring =
builder.exportBuiltinMetricsToGoogleCloudMonitoring;
this.openTelemetry = builder.openTelemetry;
}

public boolean isTracingEnabled() {
return tracingEnabled;
}

public boolean exportBuiltinMetricsToGoogleCloudMonitoring() {
return exportBuiltinMetricsToGoogleCloudMonitoring;
}

public OpenTelemetry getOpenTelemetry() {
return openTelemetry;
}
Expand All @@ -56,16 +63,20 @@ public static FirestoreOpenTelemetryOptions.Builder newBuilder() {
public static class Builder {

private boolean tracingEnabled;

private boolean exportBuiltinMetricsToGoogleCloudMonitoring;
@Nullable private OpenTelemetry openTelemetry;

private Builder() {
tracingEnabled = false;
// TODO(metrics): default this to true when feature is ready
exportBuiltinMetricsToGoogleCloudMonitoring = false;
openTelemetry = null;
}

private Builder(FirestoreOpenTelemetryOptions options) {
this.tracingEnabled = options.tracingEnabled;
this.exportBuiltinMetricsToGoogleCloudMonitoring =
options.exportBuiltinMetricsToGoogleCloudMonitoring;
this.openTelemetry = options.openTelemetry;
}

Expand All @@ -85,6 +96,20 @@ public FirestoreOpenTelemetryOptions.Builder setTracingEnabled(boolean tracingEn
return this;
}

// TODO(metrics): make this public when feature is ready.
/**
* Sets whether built-in metrics should be exported to Google Cloud Monitoring
*
* @param exportBuiltinMetrics Whether built-in metrics should be exported to Google Cloud
* Monitoring.
*/
@Nonnull
private FirestoreOpenTelemetryOptions.Builder exportBuiltinMetricsToGoogleCloudMonitoring(
boolean exportBuiltinMetrics) {
this.exportBuiltinMetricsToGoogleCloudMonitoring = exportBuiltinMetrics;
return this;
}

/**
* Sets the {@link OpenTelemetry} to use with this Firestore instance. If telemetry collection
* is enabled, but an `OpenTelemetry` is not provided, the Firestore SDK will attempt to use the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public BuiltinMetricsProvider(OpenTelemetry openTelemetry) {
this.openTelemetry = openTelemetry;
this.staticAttributes = createStaticAttributes();

if (openTelemetry != null && openTelemetry.getMeterProvider() != MeterProvider.noop()) {
if (openTelemetry.getMeterProvider() != MeterProvider.noop()) {
configureRPCLayerMetrics();
configureSDKLayerMetrics();
}
Expand All @@ -66,7 +66,7 @@ public ApiTracerFactory getApiTracerFactory() {
return this.apiTracerFactory;
}

public void endToEndRequestLatencyRecorder(double latency, Map<String, String> attributes) {
public void endToEndLatencyRecorder(double latency, Map<String, String> attributes) {
recordLatency(endToEndRequestLatency, latency, attributes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,38 @@ class EnabledMetricsUtil implements MetricsUtil {

EnabledMetricsUtil(FirestoreOptions firestoreOptions) {
try {
OpenTelemetry defaultOpenTelemetry =
getDefaultOpenTelemetryInstance(firestoreOptions.getProjectId());
this.defaultMetricsProvider = new BuiltinMetricsProvider(defaultOpenTelemetry);

OpenTelemetry customOpenTelemetry =
firestoreOptions.getOpenTelemetryOptions().getOpenTelemetry();
if (customOpenTelemetry == null) {
customOpenTelemetry = GlobalOpenTelemetry.get();
}
this.customMetricsProvider = new BuiltinMetricsProvider(customOpenTelemetry);
configureDefaultMetricsProvider(firestoreOptions);
configureCustomMetricsProvider(firestoreOptions);
} catch (IOException e) {
logger.warning(
"Unable to create MetricsUtil object for client side metrics, will skip exporting client side metrics"
+ e);
}
}

private void configureDefaultMetricsProvider(FirestoreOptions firestoreOptions)
throws IOException {
OpenTelemetry defaultOpenTelemetry;
boolean exportBuiltinMetricsToGoogleCloudMonitoring =
firestoreOptions.getOpenTelemetryOptions().exportBuiltinMetricsToGoogleCloudMonitoring();
if (exportBuiltinMetricsToGoogleCloudMonitoring) {
defaultOpenTelemetry = getDefaultOpenTelemetryInstance(firestoreOptions.getProjectId());
} else {
defaultOpenTelemetry = OpenTelemetry.noop();
}
this.defaultMetricsProvider = new BuiltinMetricsProvider(defaultOpenTelemetry);
}

private void configureCustomMetricsProvider(FirestoreOptions firestoreOptions)
throws IOException {
OpenTelemetry customOpenTelemetry =
firestoreOptions.getOpenTelemetryOptions().getOpenTelemetry();
if (customOpenTelemetry == null) {
customOpenTelemetry = GlobalOpenTelemetry.get();
}
this.customMetricsProvider = new BuiltinMetricsProvider(customOpenTelemetry);
}

@Override
public MetricsContext createMetricsContext(String methodName) {
return new MetricsContext(methodName);
Expand Down Expand Up @@ -196,8 +211,8 @@ public void recordFirstResponseLatency() {
private void recordEndToEndLatency(String status) {
double elapsedTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
Map<String, String> attributes = createAttributes(status);
defaultMetricsProvider.endToEndRequestLatencyRecorder(elapsedTime, attributes);
customMetricsProvider.endToEndRequestLatencyRecorder(elapsedTime, attributes);
defaultMetricsProvider.endToEndLatencyRecorder(elapsedTime, attributes);
customMetricsProvider.endToEndLatencyRecorder(elapsedTime, attributes);
}

private Map<String, String> createAttributes(String status) {
Expand Down
Loading