Skip to content

Commit 8af5761

Browse files
authored
add observability interface (#1100)
1 parent a3f4334 commit 8af5761

File tree

10 files changed

+607
-0
lines changed

10 files changed

+607
-0
lines changed

livekit/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ type JobID string
4545
type DispatchID string
4646
type AgentName string
4747

48+
func (s TrackID) String() string { return string(s) }
49+
func (s ParticipantID) String() string { return string(s) }
50+
func (s ParticipantIdentity) String() string { return string(s) }
51+
func (s ParticipantName) String() string { return string(s) }
52+
func (s RoomID) String() string { return string(s) }
53+
func (s RoomName) String() string { return string(s) }
54+
func (s ConnectionID) String() string { return string(s) }
55+
func (s NodeID) String() string { return string(s) }
56+
func (s JobID) String() string { return string(s) }
57+
func (s DispatchID) String() string { return string(s) }
58+
func (s AgentName) String() string { return string(s) }
59+
4860
type stringTypes interface {
4961
ParticipantID | RoomID | TrackID | ParticipantIdentity | ParticipantName | RoomName | ConnectionID | NodeID
5062
}

observability/reporter.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package observability
2+
3+
import "github.com/livekit/protocol/observability/roomobs"
4+
5+
const Project = "livekit"
6+
7+
type Reporter interface {
8+
Room() roomobs.Reporter
9+
}
10+
11+
func NewReporter() Reporter {
12+
return reporter{}
13+
}
14+
15+
type reporter struct{}
16+
17+
func (reporter) Room() roomobs.Reporter {
18+
return roomobs.NewNoopReporter()
19+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Code generated; DO NOT EDIT.
2+
3+
package roomobs
4+
5+
import (
6+
"time"
7+
)
8+
9+
const Version_KRKF8G0 = true
10+
11+
type KeyResolver interface {
12+
Resolve(string)
13+
Reset()
14+
}
15+
16+
type Reporter interface {
17+
WithProject(id string) ProjectReporter
18+
WithDeferredProject() (ProjectReporter, KeyResolver)
19+
}
20+
21+
type ProjectReporter interface {
22+
RegisterFunc(func(ts time.Time, tx ProjectTx) bool)
23+
Tx(func(tx ProjectTx))
24+
TxAt(time.Time, func(tx ProjectTx))
25+
WithRoom(name string) RoomReporter
26+
WithDeferredRoom() (RoomReporter, KeyResolver)
27+
}
28+
29+
type ProjectTx interface{}
30+
31+
type RoomReporter interface {
32+
RegisterFunc(func(ts time.Time, tx RoomTx) bool)
33+
Tx(func(tx RoomTx))
34+
TxAt(time.Time, func(tx RoomTx))
35+
WithRoomSession(id string) RoomSessionReporter
36+
WithDeferredRoomSession() (RoomSessionReporter, KeyResolver)
37+
}
38+
39+
type RoomTx interface{}
40+
41+
type RoomSessionReporter interface {
42+
RegisterFunc(func(ts time.Time, tx RoomSessionTx) bool)
43+
Tx(func(tx RoomSessionTx))
44+
TxAt(time.Time, func(tx RoomSessionTx))
45+
WithParticipant(identity string) ParticipantReporter
46+
WithDeferredParticipant() (ParticipantReporter, KeyResolver)
47+
ReportStartTime(v time.Time)
48+
ReportEndTime(v time.Time)
49+
}
50+
51+
type RoomSessionTx interface {
52+
ReportStartTime(v time.Time)
53+
ReportEndTime(v time.Time)
54+
}
55+
56+
type ParticipantReporter interface {
57+
RegisterFunc(func(ts time.Time, tx ParticipantTx) bool)
58+
Tx(func(tx ParticipantTx))
59+
TxAt(time.Time, func(tx ParticipantTx))
60+
WithParticipantSession(id string) ParticipantSessionReporter
61+
WithDeferredParticipantSession() (ParticipantSessionReporter, KeyResolver)
62+
}
63+
64+
type ParticipantTx interface{}
65+
66+
type ParticipantSessionReporter interface {
67+
RegisterFunc(func(ts time.Time, tx ParticipantSessionTx) bool)
68+
Tx(func(tx ParticipantSessionTx))
69+
TxAt(time.Time, func(tx ParticipantSessionTx))
70+
WithTrack(id string) TrackReporter
71+
WithDeferredTrack() (TrackReporter, KeyResolver)
72+
ReportRegion(v string)
73+
ReportClientConnectTime(v uint16)
74+
ReportConnectResult(v ConnectionResult)
75+
ReportConnectionType(v ConnectionType)
76+
ReportOs(v ClientOS)
77+
ReportDeviceModel(v string)
78+
ReportBrowser(v string)
79+
ReportSdkVersion(v string)
80+
ReportCountry(v uint16)
81+
ReportIspAsn(v uint32)
82+
ReportStartTime(v time.Time)
83+
ReportEndTime(v time.Time)
84+
ReportDuration(v uint16)
85+
ReportDurationMinutes(v uint8)
86+
}
87+
88+
type ParticipantSessionTx interface {
89+
ReportRegion(v string)
90+
ReportClientConnectTime(v uint16)
91+
ReportConnectResult(v ConnectionResult)
92+
ReportConnectionType(v ConnectionType)
93+
ReportOs(v ClientOS)
94+
ReportDeviceModel(v string)
95+
ReportBrowser(v string)
96+
ReportSdkVersion(v string)
97+
ReportCountry(v uint16)
98+
ReportIspAsn(v uint32)
99+
ReportStartTime(v time.Time)
100+
ReportEndTime(v time.Time)
101+
ReportDuration(v uint16)
102+
ReportDurationMinutes(v uint8)
103+
}
104+
105+
type TrackReporter interface {
106+
RegisterFunc(func(ts time.Time, tx TrackTx) bool)
107+
Tx(func(tx TrackTx))
108+
TxAt(time.Time, func(tx TrackTx))
109+
ReportName(v string)
110+
ReportKind(v TrackKind)
111+
ReportType(v TrackType)
112+
ReportSource(v TrackSource)
113+
ReportMime(v MimeType)
114+
ReportLayer(v uint32)
115+
ReportDuration(v uint16)
116+
ReportFrames(v uint16)
117+
ReportSendBytes(v uint32)
118+
ReportRecvBytes(v uint32)
119+
ReportSendPackets(v uint32)
120+
ReportRecvPackets(v uint32)
121+
ReportPacketsLost(v uint32)
122+
ReportScore(v float32)
123+
}
124+
125+
type TrackTx interface {
126+
ReportName(v string)
127+
ReportKind(v TrackKind)
128+
ReportType(v TrackType)
129+
ReportSource(v TrackSource)
130+
ReportMime(v MimeType)
131+
ReportLayer(v uint32)
132+
ReportDuration(v uint16)
133+
ReportFrames(v uint16)
134+
ReportSendBytes(v uint32)
135+
ReportRecvBytes(v uint32)
136+
ReportSendPackets(v uint32)
137+
ReportRecvPackets(v uint32)
138+
ReportPacketsLost(v uint32)
139+
ReportScore(v float32)
140+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// Code generated; DO NOT EDIT.
2+
3+
package roomobs
4+
5+
import (
6+
"time"
7+
)
8+
9+
var (
10+
_ Reporter = (*noopReporter)(nil)
11+
_ ProjectReporter = (*noopProjectReporter)(nil)
12+
_ RoomReporter = (*noopRoomReporter)(nil)
13+
_ RoomSessionReporter = (*noopRoomSessionReporter)(nil)
14+
_ ParticipantReporter = (*noopParticipantReporter)(nil)
15+
_ ParticipantSessionReporter = (*noopParticipantSessionReporter)(nil)
16+
_ TrackReporter = (*noopTrackReporter)(nil)
17+
)
18+
19+
type noopKeyResolver struct{}
20+
21+
func (noopKeyResolver) Resolve(string) {}
22+
func (noopKeyResolver) Reset() {}
23+
24+
type noopReporter struct{}
25+
26+
func NewNoopReporter() Reporter {
27+
return &noopReporter{}
28+
}
29+
30+
func (r *noopReporter) WithProject(id string) ProjectReporter {
31+
return &noopProjectReporter{}
32+
}
33+
34+
func (r *noopReporter) WithDeferredProject() (ProjectReporter, KeyResolver) {
35+
return &noopProjectReporter{}, noopKeyResolver{}
36+
}
37+
38+
type noopProjectReporter struct{}
39+
40+
func NewNoopProjectReporter() ProjectReporter {
41+
return &noopProjectReporter{}
42+
}
43+
44+
func (r *noopProjectReporter) RegisterFunc(f func(ts time.Time, tx ProjectTx) bool) {}
45+
func (r *noopProjectReporter) Tx(f func(ProjectTx)) {}
46+
func (r *noopProjectReporter) TxAt(ts time.Time, f func(ProjectTx)) {}
47+
func (r *noopProjectReporter) WithRoom(name string) RoomReporter {
48+
return &noopRoomReporter{}
49+
}
50+
func (r *noopProjectReporter) WithDeferredRoom() (RoomReporter, KeyResolver) {
51+
return &noopRoomReporter{}, noopKeyResolver{}
52+
}
53+
54+
type noopRoomReporter struct{}
55+
56+
func NewNoopRoomReporter() RoomReporter {
57+
return &noopRoomReporter{}
58+
}
59+
60+
func (r *noopRoomReporter) RegisterFunc(f func(ts time.Time, tx RoomTx) bool) {}
61+
func (r *noopRoomReporter) Tx(f func(RoomTx)) {}
62+
func (r *noopRoomReporter) TxAt(ts time.Time, f func(RoomTx)) {}
63+
func (r *noopRoomReporter) WithRoomSession(id string) RoomSessionReporter {
64+
return &noopRoomSessionReporter{}
65+
}
66+
func (r *noopRoomReporter) WithDeferredRoomSession() (RoomSessionReporter, KeyResolver) {
67+
return &noopRoomSessionReporter{}, noopKeyResolver{}
68+
}
69+
70+
type noopRoomSessionReporter struct{}
71+
72+
func NewNoopRoomSessionReporter() RoomSessionReporter {
73+
return &noopRoomSessionReporter{}
74+
}
75+
76+
func (r *noopRoomSessionReporter) RegisterFunc(f func(ts time.Time, tx RoomSessionTx) bool) {}
77+
func (r *noopRoomSessionReporter) Tx(f func(RoomSessionTx)) {}
78+
func (r *noopRoomSessionReporter) TxAt(ts time.Time, f func(RoomSessionTx)) {}
79+
func (r *noopRoomSessionReporter) ReportStartTime(v time.Time) {}
80+
func (r *noopRoomSessionReporter) ReportEndTime(v time.Time) {}
81+
func (r *noopRoomSessionReporter) WithParticipant(identity string) ParticipantReporter {
82+
return &noopParticipantReporter{}
83+
}
84+
func (r *noopRoomSessionReporter) WithDeferredParticipant() (ParticipantReporter, KeyResolver) {
85+
return &noopParticipantReporter{}, noopKeyResolver{}
86+
}
87+
88+
type noopParticipantReporter struct{}
89+
90+
func NewNoopParticipantReporter() ParticipantReporter {
91+
return &noopParticipantReporter{}
92+
}
93+
94+
func (r *noopParticipantReporter) RegisterFunc(f func(ts time.Time, tx ParticipantTx) bool) {}
95+
func (r *noopParticipantReporter) Tx(f func(ParticipantTx)) {}
96+
func (r *noopParticipantReporter) TxAt(ts time.Time, f func(ParticipantTx)) {}
97+
func (r *noopParticipantReporter) WithParticipantSession(id string) ParticipantSessionReporter {
98+
return &noopParticipantSessionReporter{}
99+
}
100+
func (r *noopParticipantReporter) WithDeferredParticipantSession() (ParticipantSessionReporter, KeyResolver) {
101+
return &noopParticipantSessionReporter{}, noopKeyResolver{}
102+
}
103+
104+
type noopParticipantSessionReporter struct{}
105+
106+
func NewNoopParticipantSessionReporter() ParticipantSessionReporter {
107+
return &noopParticipantSessionReporter{}
108+
}
109+
110+
func (r *noopParticipantSessionReporter) RegisterFunc(f func(ts time.Time, tx ParticipantSessionTx) bool) {
111+
}
112+
func (r *noopParticipantSessionReporter) Tx(f func(ParticipantSessionTx)) {}
113+
func (r *noopParticipantSessionReporter) TxAt(ts time.Time, f func(ParticipantSessionTx)) {}
114+
func (r *noopParticipantSessionReporter) ReportRegion(v string) {}
115+
func (r *noopParticipantSessionReporter) ReportClientConnectTime(v uint16) {}
116+
func (r *noopParticipantSessionReporter) ReportConnectResult(v ConnectionResult) {}
117+
func (r *noopParticipantSessionReporter) ReportConnectionType(v ConnectionType) {}
118+
func (r *noopParticipantSessionReporter) ReportOs(v ClientOS) {}
119+
func (r *noopParticipantSessionReporter) ReportDeviceModel(v string) {}
120+
func (r *noopParticipantSessionReporter) ReportBrowser(v string) {}
121+
func (r *noopParticipantSessionReporter) ReportSdkVersion(v string) {}
122+
func (r *noopParticipantSessionReporter) ReportCountry(v uint16) {}
123+
func (r *noopParticipantSessionReporter) ReportIspAsn(v uint32) {}
124+
func (r *noopParticipantSessionReporter) ReportStartTime(v time.Time) {}
125+
func (r *noopParticipantSessionReporter) ReportEndTime(v time.Time) {}
126+
func (r *noopParticipantSessionReporter) ReportDuration(v uint16) {}
127+
func (r *noopParticipantSessionReporter) ReportDurationMinutes(v uint8) {}
128+
func (r *noopParticipantSessionReporter) WithTrack(id string) TrackReporter {
129+
return &noopTrackReporter{}
130+
}
131+
func (r *noopParticipantSessionReporter) WithDeferredTrack() (TrackReporter, KeyResolver) {
132+
return &noopTrackReporter{}, noopKeyResolver{}
133+
}
134+
135+
type noopTrackReporter struct{}
136+
137+
func NewNoopTrackReporter() TrackReporter {
138+
return &noopTrackReporter{}
139+
}
140+
141+
func (r *noopTrackReporter) RegisterFunc(f func(ts time.Time, tx TrackTx) bool) {}
142+
func (r *noopTrackReporter) Tx(f func(TrackTx)) {}
143+
func (r *noopTrackReporter) TxAt(ts time.Time, f func(TrackTx)) {}
144+
func (r *noopTrackReporter) ReportName(v string) {}
145+
func (r *noopTrackReporter) ReportKind(v TrackKind) {}
146+
func (r *noopTrackReporter) ReportType(v TrackType) {}
147+
func (r *noopTrackReporter) ReportSource(v TrackSource) {}
148+
func (r *noopTrackReporter) ReportMime(v MimeType) {}
149+
func (r *noopTrackReporter) ReportLayer(v uint32) {}
150+
func (r *noopTrackReporter) ReportDuration(v uint16) {}
151+
func (r *noopTrackReporter) ReportFrames(v uint16) {}
152+
func (r *noopTrackReporter) ReportSendBytes(v uint32) {}
153+
func (r *noopTrackReporter) ReportRecvBytes(v uint32) {}
154+
func (r *noopTrackReporter) ReportSendPackets(v uint32) {}
155+
func (r *noopTrackReporter) ReportRecvPackets(v uint32) {}
156+
func (r *noopTrackReporter) ReportPacketsLost(v uint32) {}
157+
func (r *noopTrackReporter) ReportScore(v float32) {}

0 commit comments

Comments
 (0)