Class SpannerClientMetrics

java.lang.Object
io.github.flink.gcp.connector.spanner.SpannerClientMetrics

@Internal public final class SpannerClientMetrics extends Object
The Spanner client's own metrics, registered as rpcMethod.METHOD.leaf on a component's metric group through a ClientMetrics.

The instruments are what google-cloud-spanner records into the OpenTelemetry of a CustomOpenTelemetryMetricsProvider (6.124.0, BuiltInMetricsRecorder and its gax parent OpenTelemetryMetricsRecorder), all named under spanner/client/: the operation and attempt counts and latencies gax records for every data-client RPC, and the Google front end (GFE) and Spanner API front end (AFE) latencies and missing-header counts Spanner adds per attempt. The client's gRPC-layer metrics need an OpenTelemetry SDK instance and are not recorded here. The operation and attempt counts come from the client's counters; the latency histograms, which the client records at the same points, keep only their sums.

The client records nothing into a provider when it runs in its emulator mode, which is how the connector reaches an emulator (SpannerClients).

This file is a [[subgroups]] source of scripts/config/metric-docs.toml: the group and every leaf below are read from it, so each leaf owes a row on the connector's page.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The RPC the sink writes through.
    static final String
    The RPC that opens a batch read's snapshot.
    static final String
    The RPC every client's database handle sends once, for its multiplexed session.
    static final String
    The RPC of every query: the dialect, schema reads, Change Streams queries, partitions.
    static final String
    The RPC that partitions a query.
    static final String
    The RPC that partitions a table read.
    static final String
    The RPC of a point or table read, including a partition of one.
  • Method Summary

    Modifier and Type
    Method
    Description
    register(org.apache.flink.metrics.MetricGroup owner, String... methods)
    Creates the client metrics and registers every series of the given methods on the owner's group.
    registerForEnumerators(org.apache.flink.metrics.groups.SplitEnumeratorMetricGroup group, String... methods)
    Returns the client metrics of a source's enumerators: created on the enumerator metric group the first time and handed to every later enumerator built on the same group, with the series of each given method registered once.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CREATE_SESSION

      public static final String CREATE_SESSION
      The RPC every client's database handle sends once, for its multiplexed session.
      See Also:
    • EXECUTE_STREAMING_SQL

      public static final String EXECUTE_STREAMING_SQL
      The RPC of every query: the dialect, schema reads, Change Streams queries, partitions.
      See Also:
    • STREAMING_READ

      public static final String STREAMING_READ
      The RPC of a point or table read, including a partition of one.
      See Also:
    • BATCH_WRITE

      public static final String BATCH_WRITE
      The RPC the sink writes through.
      See Also:
    • BEGIN_TRANSACTION

      public static final String BEGIN_TRANSACTION
      The RPC that opens a batch read's snapshot.
      See Also:
    • PARTITION_QUERY

      public static final String PARTITION_QUERY
      The RPC that partitions a query.
      See Also:
    • PARTITION_READ

      public static final String PARTITION_READ
      The RPC that partitions a table read.
      See Also:
  • Method Details

    • register

      public static ClientMetrics register(org.apache.flink.metrics.MetricGroup owner, String... methods)
      Creates the client metrics and registers every series of the given methods on the owner's group. Call it when the component opens, before its client is built and before any reporter reads the group.
      Parameters:
      owner - the component's metric group
      methods - the RPC methods the component's client calls, without the Spanner. prefix, such as BATCH_WRITE
      Returns:
      the client metrics, whose ClientMetrics.openTelemetry() goes to the client and which the client's owner closes after the client
    • registerForEnumerators

      @Nullable public static ClientMetrics registerForEnumerators(@Nullable org.apache.flink.metrics.groups.SplitEnumeratorMetricGroup group, String... methods)
      Returns the client metrics of a source's enumerators: created on the enumerator metric group the first time and handed to every later enumerator built on the same group, with the series of each given method registered once.

      A coordinator reset builds the next enumerator on the group the first one registered on, where a second registration of a name would be dropped and the series would freeze; see EnumeratorMetrics. Shared, they keep counting across resets. Each method is registered on its own, so the sub-sources of a HybridSource, which share one group, each get the series of the methods they call. The client metrics are never closed: a client an enumerator is still closing may record into them, which is no error.

      Parameters:
      group - the enumerator's metric group, or null where the context offers none
      methods - the RPC methods the enumerators' clients call, without the Spanner. prefix
      Returns:
      the shared client metrics, or null where there is no group