Repository navigation
Description
Summary
DatastoreOpenTelemetryOptions exposes an exportBuiltinMetricsToGoogleCloudMonitoring flag that defaults to false. The clear intent is to allow users to opt out of the built-in Cloud Monitoring metrics export. However, BuiltInDatastoreMetricsProvider.createOpenTelemetry() never reads this flag, so the PeriodicMetricReader is unconditionally created for any application using real credentials.
The result is an unavoidable "Exporter failed" warning logged every 60 seconds by io.opentelemetry.sdk.metrics.export.PeriodicMetricReader for any application that either:
- runs locally with ADC credentials that lack roles/monitoring.metricWriter, or
- intentionally does not want to export Datastore metrics to Cloud Monitoring.
Affected version
google-cloud-datastore:2.41.0
Steps to reproduce
- Use google-cloud-datastore:2.41.0 with real ADC credentials (e.g. a service account without roles/monitoring.metricWriter)
- Do not set DATASTORE_EMULATOR_HOST or use NoCredentials
- Start the application
Observed: PeriodicMetricReader is created and logs "Exporter failed" every ~60 seconds to monitoring.googleapis.com.
Expected: Since exportBuiltinMetricsToGoogleCloudMonitoring defaults to false, no PeriodicMetricReader should be created and no export should be attempted.
Root cause
In DatastoreImpl, the constructor unconditionally calls:
BuiltInDatastoreMetricsProvider.INSTANCE.createOpenTelemetry(options)
Inside BuiltInDatastoreMetricsProvider.createOpenTelemetry(), the only conditions that return OpenTelemetry.noop() are:
- DATASTORE_EMULATOR_HOST system property / env var is set
- credentials are NoCredentials
- MetricServiceClient creation throws IOException
The flag options.getOpenTelemetryOptions().isExportBuiltinMetricsToGoogleCloudMonitoring() is never checked. The fix should be straightforward:
// BuiltInDatastoreMetricsProvider.java
public OpenTelemetry createOpenTelemetry(DatastoreOptions options) {
// NEW: respect the opt-out flag
if (!options.getOpenTelemetryOptions().isExportBuiltinMetricsToGoogleCloudMonitoring()) {
return OpenTelemetry.noop();
}
// ... existing logic
} Workaround
Until this is fixed, the only available workaround is to set the DATASTORE_EMULATOR_HOST system property to a non-empty dummy value before the DatastoreImpl is instantiated, then override spring.cloud.gcp.datastore.host (or equivalent) with the real endpoint to prevent the gRPC connection from being misdirected:
// In main() before application start
System.setProperty("DATASTORE_EMULATOR_HOST", "metrics-disabled"); This exploits the emulator detection path as a side effect, which is fragile and unintuitive.
Impact
This is particularly painful for local development and CI environments where ADC credentials exist but Cloud Monitoring IAM permissions are absent.
The warning fires every minute, clutters logs, and there is no documented, supported way to suppress it without resorting to the emulator side-channel.
Activity
gendolf3d commentedon Jun 26, 2026
It affects us well - we are not going to use oTEL at all and this issue spams in the logs. Need definitely have a way to disable it - it would be better to disable by default and turn on if someone interested in it.
lqiu96 commentedon Jun 26, 2026
Hey all, thanks for reporting this. Apologies for this impacting you all, this was a slip on our end and we did not intend for this. We saw another report of this: googleapis/google-cloud-java#13469 and I think we should have a proper fix for it. We will be releasing this soon and will try to also release the fix in Spring.
Thanks!
lqiu96 commentedon Jun 30, 2026
Update: I will try to cut a release soon (aiming before the end of the week). Apologies for the delay, we are prepping the release for some features
lqiu96 commentedon Jul 1, 2026
Update: Apologies for the delay. We are running into some unexpected upstream issues. The changes will require this release first: googleapis/google-cloud-java#13631 which I will get released ASAP.
ETA: After the US July 4th weekend. ~July 7th
lqiu96 commentedon Jul 10, 2026
We have cut a release and spring-cloud-gcp v8.0.5 should be available on maven central now. Thanks for your patience :)
lqiu96 commentedon Jul 13, 2026
We have released this fix to Maven Central. Closing out the ticket. Feel free to open if there is another issue. Thanks!