Files
zeekay f143a420ac fix(telemetry): repair the luxfi/metric seam — the server now builds
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.
2026-07-26 08:52:20 -07:00

39 lines
1.1 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 (
refCounts metric.GaugeVec
)
func initDebugStats(nodeID string, nodeType livekit.NodeType) {
refCounts = metric.NewGaugeVec(metric.GaugeOpts{
Namespace: livekitNamespace,
Subsystem: "debug",
Name: "ref_count",
ConstLabels: metric.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, []string{"referrer"})
}
func AddRef(referrer string, n int) {
refCounts.WithLabelValues(referrer).Add(float64(n))
}