Weiqing Yang created FLINK-40292:
------------------------------------

             Summary: Add UdfMetrics helper for UDF metrics
                 Key: FLINK-40292
                 URL: https://issues.apache.org/jira/browse/FLINK-40292
             Project: Flink
          Issue Type: Sub-task
          Components: Table SQL / Runtime
            Reporter: Weiqing Yang


  This is the first of four sub-tasks implementing FLIP-485: Add UDF Metrics, 
which was
  accepted on 2026-08-01 with 3 binding +1 and no -1.

  FLIP: 
https://cwiki.apache.org/confluence/spaces/FLINK/pages/373885706/FLIP-485+Add+UDF+Metrics
  Vote thread: https://lists.apache.org/thread/symqpswsohl2s5wmtkcw0jjp1w5dot0n

  Add the shared runtime helper {{UdfMetrics}} to flink-table-runtime, in the 
package
  org.apache.flink.table.runtime.operators.metrics. It owns metric 
registration, the
  sampling decision, timing, and exception counting, and it is the piece that 
both the
  synchronous and the asynchronous instrumentation paths use.

  The helper registers two metrics under {{addGroup("udf", udfName)}} on the 
executing
  operator's metric group, so the full identifier is
  {{<operator_name>.udf.<udf_name>.<metric>}}:

  * {{udfProcessingTime}}: a DescriptiveStatisticsHistogram of per-invocation 
nanoseconds.
    It is sampled with the same counter-based scheme as state latency tracking
    (FLINK-21736), including the "sample interval == 1" case that measures 
every call.
  * {{udfExceptionCount}}: a ThreadSafeSimpleCounter, incremented on every 
exception and
    not sampled.

  The histogram is safe to update from an async callback thread. The sampling 
counter is
  only advanced on the task thread at dispatch.

  No call site is added here. The first caller arrives in the sub-task that 
adds the
  configuration options and instruments synchronous scalar and table UDF calls.

  Covered by a new UdfMetricsTest unit test.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to