mirror of https://github.com/ollama/ollama.git
Add build version (and start date).
This commit is contained in:
parent
ce7853091c
commit
cf9abf5001
|
@ -1194,6 +1194,9 @@ func (s *Server) GenerateRoutes(rc *ollama.Registry) (http.Handler, error) {
|
|||
slog.Warn(fmt.Sprintf("Metrics initialization failed with %s", err))
|
||||
}
|
||||
s.metrics = m
|
||||
s.metrics.Start.Record(nil, time.Now().UnixMicro()/1e6, metric.WithAttributes(
|
||||
attribute.String("version", version.Version),
|
||||
))
|
||||
|
||||
r := gin.Default()
|
||||
r.HandleMethodNotAllowed = true
|
||||
|
|
|
@ -20,6 +20,7 @@ const (
|
|||
)
|
||||
|
||||
type Metrics struct {
|
||||
Start metric.Int64Gauge
|
||||
Requests metric.Int64Counter
|
||||
TotalDuration metric.Float64Counter
|
||||
LoadDuration metric.Float64Counter
|
||||
|
@ -30,6 +31,12 @@ type Metrics struct {
|
|||
}
|
||||
|
||||
func NewMetrics(meter metric.Meter) *Metrics {
|
||||
build, _ := meter.Int64Gauge(
|
||||
"ollama_build_info",
|
||||
metric.WithDescription("Ollama start date (as Unixtime) and build version."),
|
||||
metric.WithUnit("seconds"),
|
||||
)
|
||||
|
||||
req, _ := meter.Int64Counter(
|
||||
"http_requests_total",
|
||||
metric.WithDescription("The total number of requests on the endpoints."),
|
||||
|
@ -73,6 +80,7 @@ func NewMetrics(meter metric.Meter) *Metrics {
|
|||
)
|
||||
|
||||
return &Metrics{
|
||||
Start: build,
|
||||
Requests: req,
|
||||
TotalDuration: totalDuration,
|
||||
LoadDuration: loadDuration,
|
||||
|
|
Loading…
Reference in New Issue