public class BuiltInDatastoreMetricsProviderProvides a built-in OpenTelemetry instance for Datastore client-side metrics.
This class is responsible for configuring a private OpenTelemetrySdk that exports metrics to Google Cloud Monitoring using a DatastoreCloudMonitoringExporter.
The implementation follows the pattern used in other Google Cloud client libraries, providing automated environment detection and resource attribute configuration for the TelemetryConstants#DATASTORE_RESOURCE_TYPE monitored resource.
Static Fields
INSTANCE
public static final BuiltInDatastoreMetricsProvider INSTANCE| Field Value | |
|---|---|
| Type | Description |
BuiltInDatastoreMetricsProvider |
|
Methods
createOpenTelemetry(DatastoreOptions options)
public OpenTelemetry createOpenTelemetry(DatastoreOptions options)Creates a new OpenTelemetry instance for a single Datastore client's built-in metrics.
Each call returns a dedicated OpenTelemetrySdk wrapping an SdkMeterProvider configured with the provided project's monitored resource attributes and a DatastoreCloudMonitoringExporter. No global or shared state is modified.
Lifecycle: The returned instance is owned by the caller. It should be closed by calling io.opentelemetry.sdk.OpenTelemetrySdk#close() (or via OpenTelemetryDatastoreMetricsRecorder#close()) when the associated Datastore client is closed.
No caching is performed here; callers are responsible for holding the returned instance for the lifetime of their Datastore client.
| Parameter | |
|---|---|
| Name | Description |
options |
DatastoreOptionsDatastore Client Options |
| Returns | |
|---|---|
| Type | Description |
io.opentelemetry.api.OpenTelemetry |
a new OpenTelemetry instance, or |