# Interface TraceUtil (3.43.1)

3.43.1 (latest) 3.41.0 3.38.0 3.37.0 3.36.0 3.35.1 3.33.4 3.32.2 3.31.9 3.30.11 3.28.0 3.27.2 3.26.5 3.25.1 3.24.3 3.22.0 3.21.4 3.20.0 3.17.0 3.16.3 3.15.7 3.14.4 3.13.2 3.12.1 3.11.0 3.10.0 3.9.6 3.8.2 3.7.10 3.6.0 3.5.0 3.4.2 3.3.0 3.2.0 3.1.0 3.0.21

    public interface TraceUtil

A utility interface for trace collection. Classes that implement this interface may make their
own design choices for how they approach trace collection. For instance, they may be no-op, or
they may use a particular tracing framework such as OpenTelemetry.

## Static Fields

### ATTRIBUTE_GCP_RESOURCE_NAME

    public static final String ATTRIBUTE_GCP_RESOURCE_NAME

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_GCP_RESOURCE_NAME_FORMAT

    public static final String ATTRIBUTE_GCP_RESOURCE_NAME_FORMAT

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_ATTEMPT

    public static final String ATTRIBUTE_KEY_ATTEMPT

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_ATTEMPTS_ALLOWED

    public static final String ATTRIBUTE_KEY_ATTEMPTS_ALLOWED

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_ATTEMPTS_REMAINING

    public static final String ATTRIBUTE_KEY_ATTEMPTS_REMAINING

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_DOC_COUNT

    public static final String ATTRIBUTE_KEY_DOC_COUNT

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_IS_RETRY_WITH_CURSOR

    public static final String ATTRIBUTE_KEY_IS_RETRY_WITH_CURSOR

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_IS_TRANSACTIONAL

    public static final String ATTRIBUTE_KEY_IS_TRANSACTIONAL

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_NUM_RESPONSES

    public static final String ATTRIBUTE_KEY_NUM_RESPONSES

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_KEY_TRANSACTION_TYPE

    public static final String ATTRIBUTE_KEY_TRANSACTION_TYPE

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ATTRIBUTE_SERVICE_PREFIX

    public static final String ATTRIBUTE_SERVICE_PREFIX

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### ENABLE_TRACING_ENV_VAR

    public static final String ENABLE_TRACING_ENV_VAR

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### LIBRARY_NAME

    public static final String LIBRARY_NAME

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Static Methods

### getInstance(FirestoreOptions firestoreOptions)

    public static TraceUtil getInstance(FirestoreOptions firestoreOptions)

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

Creates and returns an instance of the TraceUtil class.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `firestoreOptions` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.FirestoreOptions` The FirestoreOptions object that is requesting an instance of TraceUtil. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TraceUtil` | An instance of the TraceUtil class. |

## Methods

### currentContext()

    public abstract TraceUtil.Context currentContext()

Returns the current Context.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TraceUtil.Context` |   |

### currentSpan()

    public abstract TraceUtil.Span currentSpan()

Returns the current span.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TraceUtil.Span` |   |

### getChannelConfigurator()

    public abstract ApiFunction<ManagedChannelBuilder,ManagedChannelBuilder> getChannelConfigurator()

Returns a channel configurator for gRPC, or `null` if tracing is disabled.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFunction.html<io.grpc.ManagedChannelBuilder,io.grpc.ManagedChannelBuilder>` |   |

### startSpan(String spanName)

    public abstract TraceUtil.Span startSpan(String spanName)

Starts a new span with the given name, sets it as the current span, and returns it.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `spanName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TraceUtil.Span` |   |

### startSpan(String spanName, TraceUtil.Context parent)

    public abstract TraceUtil.Span startSpan(String spanName, TraceUtil.Context parent)

Starts a new span with the given name and the given context as its parent, sets it as the
current span, and returns it.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `spanName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TraceUtil.Context` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TraceUtil.Span` |   |