mirror of
https://github.com/hanzoai/livekit.git
synced 2026-10-30 18:29:34 +00:00
This repo did not compile, and had not before any of the KV work: at the commit prior to it, `go build ./...` failed identically in pkg/telemetry/prometheus. That failure masked every package downstream of it, which is why the KV rename could only be type-checked in isolation. The telemetry code was written against an older luxfi/metric API: metric.CounterVec/HistogramVec/GaugeVec are INTERFACES, but 28 declarations said *metric.X — a pointer to an interface, which nothing satisfies. metric.MustRegister does not exist, and is not needed: NewHistogramVec and friends already register into DefaultRegistry at construction. 36 calls removed. metric.ExponentialBucketsRange does not exist; the bucket helper comes from prometheus/client_golang. rpc.InitPSRPCStats / webhook.InitWebhookStats come from livekit/protocol and take prometheus.Labels, not metric.Labels. Those two call sites now pass the type the upstream signature actually declares. metric.DefaultGatherer does not exist. Replaced with metric.DefaultRegistry, which satisfies Gatherer (Registry embeds it). NOT metric.Handler() — that wraps a FRESH NewRegistry(), so the endpoint would have served zero metrics while looking healthy. `go build ./...` and `go vet ./pkg/...` now pass.
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
// Copyright 2023 LiveKit, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package prometheus
|
|
|
|
import (
|
|
metric "github.com/luxfi/metric"
|
|
|
|
"github.com/livekit/protocol/livekit"
|
|
)
|
|
|
|
var (
|
|
qualityRating metric.Histogram
|
|
qualityScore metric.Histogram
|
|
)
|
|
|
|
func initQualityStats(nodeID string, nodeType livekit.NodeType) {
|
|
qualityRating = metric.NewHistogram(metric.HistogramOpts{
|
|
Namespace: livekitNamespace,
|
|
Subsystem: "quality",
|
|
Name: "rating",
|
|
ConstLabels: metric.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
|
Buckets: []float64{0, 1, 2},
|
|
})
|
|
qualityScore = metric.NewHistogram(metric.HistogramOpts{
|
|
Namespace: livekitNamespace,
|
|
Subsystem: "quality",
|
|
Name: "score",
|
|
ConstLabels: metric.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
|
Buckets: []float64{1.0, 2.0, 2.5, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5},
|
|
})
|
|
}
|
|
|
|
func RecordQuality(rating livekit.ConnectionQuality, score float32) {
|
|
qualityRating.Observe(float64(rating))
|
|
qualityScore.Observe(float64(score))
|
|
}
|