Skip to content

Commit fa4bca1

Browse files
JeffLuoorlakhtakia
authored andcommitted
Add inference_extension_info metric for project metadata (#744)
Start with just commit, version information will be added in a follow-up change. Verified: ``` inference_extension_info{commit="60f8c57bb95b656a75d27564d5ff01c060bcdba5"} 1 ```
1 parent 572b562 commit fa4bca1

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ COPY cmd ./cmd
1919
COPY pkg ./pkg
2020
COPY internal ./internal
2121
COPY api ./api
22+
COPY .git ./.git
2223
WORKDIR /src/cmd/epp
23-
RUN go build -o /epp
24+
RUN go build -buildvcs=true -o /epp
2425

2526
## Multistage deploy
2627
FROM ${BASE_IMAGE}

cmd/epp/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ func registerHealthServer(mgr manager.Manager, logger logr.Logger, ds datastore.
250250
func registerMetricsHandler(mgr manager.Manager, port int, cfg *rest.Config) error {
251251
metrics.Register()
252252

253+
metrics.RecordInferenceExtensionInfo()
254+
253255
// Init HTTP server.
254256
h, err := metricsHandlerWithAuthenticationAndAuthorization(cfg)
255257
if err != nil {

pkg/epp/metrics/metrics.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package metrics
1818

1919
import (
2020
"context"
21+
"runtime/debug"
2122
"sync"
2223
"time"
2324

@@ -31,6 +32,12 @@ const (
3132
InferenceModelComponent = "inference_model"
3233
InferencePoolComponent = "inference_pool"
3334
EPPComponent = "endpoint_picker"
35+
InferenceExtension = "inference_extension"
36+
)
37+
38+
var (
39+
// The git hash of the latest commit in the build.
40+
CommitHash string
3441
)
3542

3643
var (
@@ -191,6 +198,17 @@ var (
191198
},
192199
[]string{"plugin_type", "plugin_name"},
193200
)
201+
202+
// Info Metrics
203+
InferenceExtensionInfo = compbasemetrics.NewGaugeVec(
204+
&compbasemetrics.GaugeOpts{
205+
Subsystem: InferenceExtension,
206+
Name: "info",
207+
Help: "General information of the current build of Inference Extension.",
208+
StabilityLevel: compbasemetrics.ALPHA,
209+
},
210+
[]string{"commit"},
211+
)
194212
)
195213

196214
var registerMetrics sync.Once
@@ -213,6 +231,8 @@ func Register() {
213231
legacyregistry.MustRegister(inferencePoolReadyPods)
214232

215233
legacyregistry.MustRegister(SchedulerPluginProcessingLatencies)
234+
235+
legacyregistry.MustRegister(InferenceExtensionInfo)
216236
})
217237
}
218238

@@ -315,3 +335,27 @@ func RecordinferencePoolReadyPods(name string, runningPods float64) {
315335
func RecordSchedulerPluginProcessingLatency(pluginType, pluginName string, duration time.Duration) {
316336
SchedulerPluginProcessingLatencies.WithLabelValues(pluginType, pluginName).Observe(duration.Seconds())
317337
}
338+
339+
func RecordInferenceExtensionInfo() {
340+
if CommitHash != "" {
341+
InferenceExtensionInfo.WithLabelValues(CommitHash).Set(1)
342+
}
343+
}
344+
345+
func init() {
346+
info, ok := debug.ReadBuildInfo()
347+
if !ok {
348+
return
349+
}
350+
351+
var Commit = func(i *debug.BuildInfo) string {
352+
for _, setting := range i.Settings {
353+
if setting.Key == "vcs.revision" {
354+
return setting.Value
355+
}
356+
}
357+
return ""
358+
}(info)
359+
360+
CommitHash = Commit
361+
}

site-src/guides/metrics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ curl -i ${IP}:${PORT}/v1/completions -H 'Content-Type: application/json' -d '{
3535
| inference_pool_average_kv_cache_utilization | Gauge | The average kv cache utilization for an inference server pool. | `name`=<inference-pool-name> | ALPHA |
3636
| inference_pool_average_queue_size | Gauge | The average number of requests pending in the model server queue. | `name`=<inference-pool-name> | ALPHA |
3737
| inference_pool_ready_pods | Gauge | The number of ready pods for an inference server pool. | `name`=<inference-pool-name> | ALPHA |
38+
| inference_extension_info | Gauge | The general information of the current build. | `commit`=<hash-of-the-build> | ALPHA |
39+
3840

3941
## Scrape Metrics
4042

0 commit comments

Comments
 (0)