# Class DatastoreOpenTelemetryOptions (3.1.0)

3.1.0 (latest) 2.40.0 2.37.0 2.36.0 2.34.0 2.33.3 2.32.3 2.31.4 2.30.0 2.29.1 2.28.2 2.27.1 2.26.4 2.25.2 2.24.3 2.23.0 2.22.0 2.21.3 2.20.2 2.19.2 2.18.5 2.17.6

    public class DatastoreOpenTelemetryOptions

Represents the options that are used to configure the use of OpenTelemetry for telemetry
collection in the Datastore SDK.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> DatastoreOpenTelemetryOptions

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### newBuilder()

    public static DatastoreOpenTelemetryOptions.Builder newBuilder()

Returns a new default Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreOpenTelemetryOptions.Builder` | a new Builder. |

## Methods

### getOpenTelemetry()

    public OpenTelemetry getOpenTelemetry()

Returns the configured custom OpenTelemetry instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `io.opentelemetry.api.OpenTelemetry` | the configured OpenTelemetry instance, or the global instance if a custom one was not provided. If there is no global instance, then `OpenTelemetry.noop()` is returned. |

### isEnabled()

    public boolean isEnabled()

Returns whether either tracing or custom metrics (via a user-provided OpenTelemetry
instance) are enabled.

**Note:** This method does *not* reflect the state of built-in metrics export to
Google Cloud Monitoring, which is controlled separately by [#isExportBuiltinMetricsToGoogleCloudMonitoring()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreOpenTelemetryOptions#com_google_cloud_datastore_DatastoreOpenTelemetryOptions_isExportBuiltinMetricsToGoogleCloudMonitoring__) and is `false` by default. To check
whether any telemetry is active, also consult that flag.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if tracing or custom OTel metrics are enabled, `false` otherwise. |

### isExportBuiltinMetricsToGoogleCloudMonitoring()

    public boolean isExportBuiltinMetricsToGoogleCloudMonitoring()

> [!WARNING]
> **Beta**
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Returns whether built-in metrics should be exported to Google Cloud Monitoring.

When enabled, client-side metrics are automatically exported to Google Cloud Monitoring
using the Cloud Monitoring API. This is independent of the custom OpenTelemetry backend
configured via [#getOpenTelemetry()](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreOpenTelemetryOptions#com_google_cloud_datastore_DatastoreOpenTelemetryOptions_getOpenTelemetry__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if built-in metrics export to Cloud Monitoring is enabled, `false` otherwise. |

### isMetricsEnabled()

    public boolean isMetricsEnabled()

Returns whether metrics are enabled for the custom (user-provided) OpenTelemetry backend.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if metrics are enabled, `false` otherwise. |

### isTracingEnabled()

    public boolean isTracingEnabled()

Returns whether tracing is enabled.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if tracing is enabled, `false` otherwise. |

### toBuilder()

    public DatastoreOpenTelemetryOptions.Builder toBuilder()

Returns a new Builder initialized with the values from this options instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreOpenTelemetryOptions.Builder` | a new Builder. |