[FLINK-39059][models] Add unified inference metrics for model functions#27724
Open
dubin555 wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39059][models] Add unified inference metrics for model functions#27724dubin555 wants to merge 1 commit intoapache:masterfrom
dubin555 wants to merge 1 commit intoapache:masterfrom
Conversation
Add inference metrics (request count, success/failure counters, latency gauge) to both Triton and OpenAI model inference functions. The flink-models module previously had zero MetricGroup/Counter/Gauge references, making it impossible to monitor model inference performance in production. Metrics registered under "model_inference" group: - inference_requests: total inference requests - inference_requests_success: successful completions - inference_requests_failure: failed requests (network, HTTP errors, parse) - inference_latency_ms: last inference round-trip latency
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
The
flink-modelsmodule (bothflink-model-tritonandflink-model-openai) currently has no metric instrumentation. Users running model inference in production have no visibility into request rates, error rates, or latency — making it impossible to set up monitoring or alerting for inference degradation.This PR adds unified inference metrics to both Triton and OpenAI model function base classes, following the same
MetricGrouppatterns used elsewhere in Flink (e.g.,CachingAsyncLookupFunction,AsyncMLPredictRunner).Four metrics are registered under the
model_inferencegroup:inference_requestsinference_requests_successinference_requests_failureinference_latency_msBrief change log
registerMetrics()call inAbstractTritonModelFunction.open()so all Triton subclasses automatically get metricsTritonInferenceModelFunction.asyncPredict()with counter increments and latency trackingwhenComplete()instrumentation inAbstractOpenAIModelFunction.open()/asyncPredict()volatile longgauge for latency rather than histogram, sinceDescriptiveStatisticsHistogramlives inflink-runtimewhich is not available as a dependency inflink-modelsVerifying this change
This change added tests and can be verified as follows:
TritonInferenceMetricsTest— integration test using MockWebServer that verifies metrics are correctly registered and updated after successful inference callsOpenAIInferenceMetricsTest— integration test using MockWebServer that verifies chat inference metrics and null-input skip behaviorDoes this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation