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.
  • Field Details

  • Method Details

    • getInstance

      static MetricsUtil getInstance(@Nonnull 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.
      Parameters:
      firestoreOptions - The Firestore options that configures client side metrics.
      Returns:
      An instance of MetricsUtil.
    • shouldCreateEnabledInstance

      static boolean shouldCreateEnabledInstance()
    • createMetricsContext

      MetricsUtil.MetricsContext createMetricsContext(String methodName)
      Creates a new MetricsContext for the given method and starts timing.
      Parameters:
      methodName - The name of the method.
      Returns:
      A new MetricsContext.
    • addMetricsTracerFactory

      void addMetricsTracerFactory(List<com.google.api.gax.tracing.ApiTracerFactory> apiTracerFactories)
      Adds a metrics tracer factory to the given list of API tracer factories.
      Parameters:
      apiTracerFactories - The list of API tracer factories.