Interface MetricsUtil
@InternalApi
public interface MetricsUtil
A utility interface for metrics collection. Classes that implement this interface may make their
own design choices for how they approach metrics collection. For instance, they may be no-op, or
they may use a particular metrics framework such as OpenTelemetry.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA context for recording metrics in the Firestore SDK. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetricsTracerFactory(List<com.google.api.gax.tracing.ApiTracerFactory> apiTracerFactories) Adds a metrics tracer factory to the given list of API tracer factories.createMetricsContext(String methodName) Creates a newMetricsContextfor the given method and starts timing.static MetricsUtilgetInstance(FirestoreOptions firestoreOptions) Creates an instance ofMetricsUtil.static boolean
-
Field Details
-
logger
-
ENABLE_METRICS_ENV_VAR
- See Also:
-
-
Method Details
-
getInstance
Creates an instance ofMetricsUtil. If the environment variable `FIRESTORE_ENABLE_METRICS` is set to false or off, an instance ofDisabledMetricsUtilwill be returned. Otherwise, an instance ofEnabledMetricsUtilwill be returned.- Parameters:
firestoreOptions- The Firestore options that configures client side metrics.- Returns:
- An instance of
MetricsUtil.
-
shouldCreateEnabledInstance
static boolean shouldCreateEnabledInstance() -
createMetricsContext
Creates a newMetricsContextfor the given method and starts timing.- Parameters:
methodName- The name of the method.- Returns:
- A new
MetricsContext.
-
addMetricsTracerFactory
Adds a metrics tracer factory to the given list of API tracer factories.- Parameters:
apiTracerFactories- The list of API tracer factories.
-