Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion observability/roomobs/gen_reporter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions observability/roomobs/gen_reporter_noop.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions observability/roomobs/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package roomobs
import (
"fmt"
"strings"
"time"
"unsafe"

"github.com/livekit/protocol/livekit"
Expand Down Expand Up @@ -180,3 +181,44 @@ func ParticipantKindCode(k livekit.ParticipantInfo_Kind) int32 {
func ParticipantKindDetailsCodes(d []livekit.ParticipantInfo_KindDetail) []int32 {
return *(*[]int32)(unsafe.Pointer(&d))
}

// GetFeatureNameFromFeature returns the canonical name used to identify a
// feature usage in the feature_usages rollup. It returns "" when info is nil or
// the feature is not recognized, so callers can skip reporting.
func GetFeatureNameFromFeature(info *livekit.FeatureUsageInfo) string {
if info == nil {
return ""
}
switch info.GetFeature() {
case livekit.FeatureUsageInfo_KRISP_NOISE_CANCELLATION:
return "krisp_noise_cancellation"
case livekit.FeatureUsageInfo_KRISP_BACKGROUND_VOICE_CANCELLATION:
return "krisp_background_voice_cancellation"
case livekit.FeatureUsageInfo_KRISP_VIVA:
return "krisp_viva"
case livekit.FeatureUsageInfo_AIC_AUDIO_ENHANCEMENT:
// AIC enhancement is keyed by the specific feature metadata (<key>_<value>).
for k, v := range info.GetFeatureInfo() {
return fmt.Sprintf("%s_%s", k, v)
}
return "aic_audio_enhancement"
default:
return ""
}
}

// GetFeatureDurationFromFeature returns the total active duration of a feature
// usage, summed across its (non-negative) time ranges.
func GetFeatureDurationFromFeature(info *livekit.FeatureUsageInfo) time.Duration {
if info == nil {
return 0
}
var d time.Duration
for _, tr := range info.GetTimeRanges() {
start, end := tr.GetStartedAt().AsTime(), tr.GetEndedAt().AsTime()
if end.After(start) {
d += end.Sub(start)
}
}
return d
}
Loading