# Interface MetricsUtil.MetricsContext (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 static interface MetricsUtil.MetricsContext

A context for recording metrics in the Firestore SDK.

## Methods

### \<T\>recordCounterAtFuture(TelemetryConstants.MetricType metric, ApiFuture\<T\> futureValue)

    public abstract void <T>recordCounterAtFuture(TelemetryConstants.MetricType metric, ApiFuture<T> futureValue)

Records the counter value for a metric type *after* the future has been completed. This
method "appends" the metrics recording code at the completion of the given future.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `metric` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType` |
| `futureValue` | `https://docs.cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFuture.html<T>` |

### \<T\>recordLatencyAtFuture(TelemetryConstants.MetricType metric, ApiFuture\<T\> futureValue)

    public abstract void <T>recordLatencyAtFuture(TelemetryConstants.MetricType metric, ApiFuture<T> futureValue)

If the operation ends in the future, its relevant metrics should be recorded *after* the
future has been completed. This method "appends" the metrics recording code at the completion
of the given future.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `metric` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType` |
| `futureValue` | `https://docs.cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFuture.html<T>` |

### incrementCounter()

    public abstract void incrementCounter()

Increments the counter tracked inside the MetricsContext.

### recordLatency(TelemetryConstants.MetricType metric)

    public abstract void recordLatency(TelemetryConstants.MetricType metric)

Records specific type of latency for the current operation.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `metric` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType` |

### recordLatency(TelemetryConstants.MetricType metric, Throwable t)

    public abstract void recordLatency(TelemetryConstants.MetricType metric, Throwable t)

Records specific type of latency for the current operation, which ended with a throwable.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `metric` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType` |
| `t` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html` |