MCPcopy Create free account
hub / github.com/InferCore/InferCore / initPrometheusMetrics

Method initPrometheusMetrics

internal/server/server.go:771–810  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

769}
770
771func (s *Server) initPrometheusMetrics() {
772 reg := prometheus.NewRegistry()
773 s.inferReqCounter = prometheus.NewCounter(prometheus.CounterOpts{
774 Namespace: "infercore",
775 Name: "requests_total",
776 Help: "Total /infer requests that passed validation and were assigned a request_id",
777 })
778 s.httpReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
779 Namespace: "infercore",
780 Name: "http_requests_total",
781 Help: "Total HTTP requests by path, method, and status code",
782 }, []string{"path", "method", "status"})
783 inflightGauge := prometheus.NewGaugeFunc(prometheus.GaugeOpts{
784 Namespace: "infercore",
785 Name: "infer_inflight",
786 Help: "Current /infer executions in flight (after overload admission)",
787 }, func() float64 { return float64(s.inferInflight.Load()) })
788 ttftGauge := prometheus.NewGaugeFunc(prometheus.GaugeOpts{
789 Namespace: "infercore",
790 Name: "scaling_ttft_degradation_ratio",
791 Help: "Rolling TTFT degradation ratio from in-memory SLO store (>1 suggests recent slowdown)",
792 }, func() float64 { return s.CurrentSignals().TTFTDegradationRatio })
793 fallbackGauge := prometheus.NewGaugeFunc(prometheus.GaugeOpts{
794 Namespace: "infercore",
795 Name: "scaling_recent_fallback_rate",
796 Help: "Fraction of recent completed requests that recorded fallback (in-memory SLO window)",
797 }, func() float64 { return s.CurrentSignals().RecentFallbackRate })
798 timeoutGauge := prometheus.NewGaugeFunc(prometheus.GaugeOpts{
799 Namespace: "infercore",
800 Name: "scaling_timeout_spike",
801 Help: "1 if infer timeouts in the last rolling minute exceeded threshold, else 0",
802 }, func() float64 {
803 if s.timeoutSpikeActive() {
804 return 1
805 }
806 return 0
807 })
808 reg.MustRegister(s.inferReqCounter, s.httpReqCounter, inflightGauge, ttftGauge, fallbackGauge, timeoutGauge)
809 s.promReg = reg
810}
811
812// CurrentSignals implements interfaces.ScalingSignalProvider for autoscaler-facing hints.
813func (s *Server) CurrentSignals() types.ScalingSignals {

Callers 1

NewWithDependenciesFunction · 0.95

Calls 2

CurrentSignalsMethod · 0.95
timeoutSpikeActiveMethod · 0.95

Tested by

no test coverage detected