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.
Static Fields
ENABLE_METRICS_ENV_VAR
public static final String ENABLE_METRICS_ENV_VAR
Field Value | |
---|---|
Type | Description |
String |
logger
public static final Logger logger
Field Value | |
---|---|
Type | Description |
Logger |
Static Methods
getInstance(FirestoreOptions firestoreOptions)
public static MetricsUtil getInstance(FirestoreOptions firestoreOptions)
Creates an instance of MetricsUtil
. If the environment variable
FIRESTORE_ENABLE_METRICS
is set to false or off, an instance of DisabledMetricsUtil
will be returned. Otherwise, an instance of EnabledMetricsUtil will be returned.
Parameter | |
---|---|
Name | Description |
firestoreOptions |
FirestoreOptions The Firestore options that configures client side metrics. |
Returns | |
---|---|
Type | Description |
MetricsUtil |
An instance of |
shouldCreateEnabledInstance()
public static boolean shouldCreateEnabledInstance()
Returns | |
---|---|
Type | Description |
boolean |
Methods
addMetricsTracerFactory(List<ApiTracerFactory> apiTracerFactories)
public abstract void addMetricsTracerFactory(List<ApiTracerFactory> apiTracerFactories)
Adds a metrics tracer factory to the given list of API tracer factories.
Parameter | |
---|---|
Name | Description |
apiTracerFactories |
List<ApiTracerFactory> The list of API tracer factories. |
createMetricsContext(String methodName)
public abstract MetricsUtil.MetricsContext createMetricsContext(String methodName)
Creates a new MetricsContext
for the given method and starts timing.
Parameter | |
---|---|
Name | Description |
methodName |
String The name of the method. |
Returns | |
---|---|
Type | Description |
MetricsUtil.MetricsContext |
A new |