Class FcCombineMetrics

java.lang.Object
org.frontcache.include.combine.FcCombineMetrics

public class FcCombineMetrics extends Object
Combine-and-reduce outcomes, counted per batch and per member. See docs/archive/combine-reduce-proposal.md section 12.

What these are for

The feature's whole claim is "N fragments, one origin request", and nothing else in the process can tell you whether that is actually happening. The command metrics count origin calls but cannot say how many fragments each one carried; the cache metrics count hits but a combined batch IS the miss path. So the ratio that matters -
rate(frontcache_include_combine_members_total{result="combined"}[5m])
  / rate(frontcache_include_combine_batches_total{result="ok"}[5m])
average members per batch - is computed from two counters taken here.

Counters, not a distribution summary

Batch size is the obvious candidate for a DistributionSummary, and it is deliberately not one. A summary has to be recorded into a Micrometer meter at event time, which would put a hard dependency on the (optional, off-by-default) metrics registry on the include path. Two monotonic counters give the mean, are free when export is off, and follow FcCacheMetrics: count where the answer is known, let Prometheus compute the windows.

The accounting is exhaustive

Every include that reaches isCombinable as a candidate - it carries combine="..." and combining is enabled - lands in exactly one FcCombineMetrics.Member bucket, so cached + combined + individual + fallback is the number of combine candidates seen. That is an invariant, and CombineMetricsTest holds it: a member silently accounted twice, or not at all, would make the members-per-batch ratio quietly wrong in a way no single counter reveals.
  • Method Details

    • record

      public static void record(FcCombineMetrics.Batch outcome)
      Records one combined origin call. Like FcCacheMetrics.record, this runs on the request path and is a LongAdder increment and nothing else - no allocation, no lock, and no check for whether export is even enabled. Counting unconditionally keeps the numbers right for a node that has export switched on later, and costs less than the check would.
    • record

      public static void record(FcCombineMetrics.Member outcome)
      Records one combine candidate's resolution.
    • record

      public static void record(FcCombineMetrics.Member outcome, int count)
      Records count candidates resolved the same way - the batch paths resolve in bulk.
    • record

      public static void record(FcCombineMetrics.Error kind)
      Records one rejected envelope. Always paired with a FcCombineMetrics.Batch.ERROR.
    • count

      public static long count(FcCombineMetrics.Batch outcome)
    • count

      public static long count(FcCombineMetrics.Member outcome)
    • count

      public static long count(FcCombineMetrics.Error kind)
    • reset

      public static void reset()
      Test seam - back to zero.