@observertc/observer-js 0.9.1-beta → 0.9.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Evaluator.d.ts.map +1 -1
- package/lib/Evaluator.js +13 -2
- package/lib/Observer.d.ts +3 -1
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +19 -1
- package/lib/common/logger.d.ts +2 -2
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +49 -35
- package/lib/common/types.d.ts +22 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/middlewares/CommitTransactionMiddleware.d.ts.map +1 -1
- package/lib/middlewares/CommitTransactionMiddleware.js +25 -0
- package/lib/middlewares/TransactionContext.d.ts +4 -2
- package/lib/middlewares/TransactionContext.d.ts.map +1 -1
- package/lib/middlewares/TransactionContext.js +2 -1
- package/lib/middlewares/TransactoinProcessor.d.ts.map +1 -1
- package/lib/middlewares/TransactoinProcessor.js +3 -2
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts +1 -1
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts.map +1 -1
- package/lib/middlewares/VisitObservedCallsMiddleware.js +2 -2
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts +6 -0
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts.map +1 -0
- package/lib/middlewares/VisitObservedSfusMiddleware.js +142 -0
- package/lib/middlewares/visitors/visitClient.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitClient.js +13 -0
- package/lib/middlewares/visitors/{visitOutboundVideoTarcks.d.ts → visitOutboundVideoTarck.d.ts} +1 -1
- package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts.map +1 -0
- package/lib/middlewares/visitors/visitSfu.d.ts +5 -0
- package/lib/middlewares/visitors/visitSfu.d.ts.map +1 -0
- package/lib/middlewares/visitors/visitSfu.js +79 -0
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts +5 -0
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts.map +1 -0
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.js +60 -0
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts +5 -0
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts.map +1 -0
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.js +61 -0
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts +5 -0
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts.map +1 -0
- package/lib/middlewares/visitors/visitSfuSctpChannel.js +58 -0
- package/lib/middlewares/visitors/visitSfuTransport.d.ts +5 -0
- package/lib/middlewares/visitors/visitSfuTransport.d.ts.map +1 -0
- package/lib/middlewares/visitors/visitSfuTransport.js +59 -0
- package/lib/samples/ObservedSfu.d.ts +27 -0
- package/lib/samples/ObservedSfu.d.ts.map +1 -0
- package/lib/samples/ObservedSfu.js +72 -0
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts +15 -0
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts.map +1 -0
- package/lib/samples/ObservedSfuInboundRtpPad.js +21 -0
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts +15 -0
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts.map +1 -0
- package/lib/samples/ObservedSfuOutboundRtpPad.js +21 -0
- package/lib/samples/ObservedSfuSctpChannel.d.ts +15 -0
- package/lib/samples/ObservedSfuSctpChannel.d.ts.map +1 -0
- package/lib/samples/ObservedSfuSctpChannel.js +21 -0
- package/lib/samples/ObservedSfuTransport.d.ts +30 -0
- package/lib/samples/ObservedSfuTransport.d.ts.map +1 -0
- package/lib/samples/ObservedSfuTransport.js +93 -0
- package/lib/samples/ObservedSfus.d.ts +16 -0
- package/lib/samples/ObservedSfus.d.ts.map +1 -0
- package/lib/samples/ObservedSfus.js +66 -0
- package/lib/sinks/ObserverSink.d.ts +3 -3
- package/lib/sinks/ObserverSink.d.ts.map +1 -1
- package/lib/sources/ObservedSfuSource.d.ts +14 -0
- package/lib/sources/ObservedSfuSource.d.ts.map +1 -0
- package/lib/sources/ObservedSfuSource.js +2 -0
- package/lib/sources/Sources.d.ts +8 -0
- package/lib/sources/Sources.d.ts.map +1 -1
- package/lib/sources/Sources.js +47 -1
- package/lib/storages/StorageProvider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Evaluator.ts +14 -2
- package/src/Observer.ts +22 -1
- package/src/common/logger.ts +145 -127
- package/src/common/types.ts +27 -0
- package/src/middlewares/CommitTransactionMiddleware.ts +46 -6
- package/src/middlewares/TransactionContext.ts +7 -3
- package/src/middlewares/TransactoinProcessor.ts +3 -1
- package/src/middlewares/VisitObservedCallsMiddleware.ts +1 -1
- package/src/middlewares/VisitObservedSfusMiddleware.ts +202 -0
- package/src/middlewares/visitors/visitClient.ts +15 -0
- package/src/middlewares/visitors/visitSfu.ts +64 -0
- package/src/middlewares/visitors/visitSfuInboundRtpPad.ts +50 -0
- package/src/middlewares/visitors/visitSfuOutboundRtpPad.ts +51 -0
- package/src/middlewares/visitors/visitSfuSctpChannel.ts +48 -0
- package/src/middlewares/visitors/visitSfuTransport.ts +48 -0
- package/src/samples/ObservedSfu.ts +108 -0
- package/src/samples/ObservedSfuInboundRtpPad.ts +34 -0
- package/src/samples/ObservedSfuOutboundRtpPad.ts +34 -0
- package/src/samples/ObservedSfuSctpChannel.ts +35 -0
- package/src/samples/ObservedSfuTransport.ts +130 -0
- package/src/samples/ObservedSfus.ts +85 -0
- package/src/sinks/ObserverSink.ts +5 -3
- package/src/sources/ObservedSfuSource.ts +23 -0
- package/src/sources/Sources.ts +54 -3
- package/src/storages/StorageProvider.ts +1 -4
- package/lib/middlewares/visitors/visitOutboundVideoTarcks.d.ts.map +0 -1
- package/lib/storages/StorageFactory.d.ts +0 -27
- package/lib/storages/StorageFactory.d.ts.map +0 -1
- package/lib/storages/StorageFactory.js +0 -37
- package/src/storages/StorageFactory.ts +0 -58
- /package/lib/middlewares/visitors/{visitOutboundVideoTarcks.js → visitOutboundVideoTarck.js} +0 -0
- /package/src/middlewares/visitors/{visitOutboundVideoTarcks.ts → visitOutboundVideoTarck.ts} +0 -0
package/src/Evaluator.ts
CHANGED
|
@@ -103,10 +103,11 @@ export class Evaluator {
|
|
|
103
103
|
|
|
104
104
|
public addObservedSamples(samples: SourcesEvents['observed-samples']): void {
|
|
105
105
|
// this triggers the evaluation
|
|
106
|
-
const { observedCalls } = samples;
|
|
106
|
+
const { observedCalls, observedSfus } = samples;
|
|
107
107
|
|
|
108
108
|
const evaluatorContext: EvaluatorContext = {
|
|
109
109
|
observedCalls,
|
|
110
|
+
observedSfus,
|
|
110
111
|
reports: this._reportsCollector,
|
|
111
112
|
storages: this._storageProvider,
|
|
112
113
|
joinedClientIds: [],
|
|
@@ -123,6 +124,16 @@ export class Evaluator {
|
|
|
123
124
|
removedOutboundAudioTracks: [],
|
|
124
125
|
addedOutboundVideoTrackIds: [],
|
|
125
126
|
removedOutboundVideoTracks: [],
|
|
127
|
+
joinedSfuIds: [],
|
|
128
|
+
detachedSfus: [],
|
|
129
|
+
openedSfuTransportIds: [],
|
|
130
|
+
closedSfuTransports: [],
|
|
131
|
+
addedSfuInbounRtpPadIds: [],
|
|
132
|
+
removedSfuInbounRtpPadIds: [],
|
|
133
|
+
addedSfuOutbounRtpPadIds: [],
|
|
134
|
+
removedSfuOutbounRtpPadIds: [],
|
|
135
|
+
openedSfuSctpChannelIds: [],
|
|
136
|
+
closedSfuSctpChannels: [],
|
|
126
137
|
};
|
|
127
138
|
|
|
128
139
|
const callOperations = createCallOperationContext(this._clientOperations, evaluatorContext);
|
|
@@ -178,7 +189,8 @@ export class Evaluator {
|
|
|
178
189
|
const transactionContext = await createTransactionContext(
|
|
179
190
|
evaluatorContext,
|
|
180
191
|
this._storageProvider,
|
|
181
|
-
evaluatorContext.observedCalls
|
|
192
|
+
evaluatorContext.observedCalls,
|
|
193
|
+
evaluatorContext.observedSfus,
|
|
182
194
|
);
|
|
183
195
|
|
|
184
196
|
await this._transactionProcessor.use(transactionContext);
|
package/src/Observer.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ObservedCallSourceConfig, ObservedCallSource } from './sources/Observed
|
|
|
8
8
|
import { ObservedClientSource, ObservedClientSourceConfig } from './sources/ObservedClientSource';
|
|
9
9
|
import { PartialBy } from './common/utils';
|
|
10
10
|
import { createLogger, LogLevel } from './common/logger';
|
|
11
|
+
import { ObservedSfuSource, ObservedSfuSourceConfig } from './sources/ObservedSfuSource';
|
|
11
12
|
|
|
12
13
|
const logger = createLogger('Observer');
|
|
13
14
|
|
|
@@ -90,6 +91,7 @@ export class Observer {
|
|
|
90
91
|
this._evaluator.on('ready', () => {
|
|
91
92
|
this._sink.emit();
|
|
92
93
|
});
|
|
94
|
+
logger.debug(`Observer is created with config`, this.config);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
public createCallSource(
|
|
@@ -137,17 +139,36 @@ export class Observer {
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
public createClientSource(
|
|
140
|
-
config: PartialBy<ObservedClientSourceConfig, 'serviceId' | 'mediaUnitId'>
|
|
142
|
+
config: PartialBy<ObservedClientSourceConfig, 'serviceId' | 'mediaUnitId' | 'joined'>
|
|
141
143
|
): ObservedClientSource {
|
|
142
144
|
if (this._closed) {
|
|
143
145
|
throw new Error(`Attempted to create a client source on a closed observer`);
|
|
144
146
|
}
|
|
145
147
|
const serviceId = config.serviceId ?? this.config.defaultServiceId;
|
|
146
148
|
const mediaUnitId = config.mediaUnitId ?? this.config.defaultMediaUnitId;
|
|
149
|
+
const joined = config.joined ?? Date.now();
|
|
147
150
|
return this._sources.createClientSource({
|
|
148
151
|
...config,
|
|
149
152
|
serviceId,
|
|
150
153
|
mediaUnitId,
|
|
154
|
+
joined,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public createSfuSource(
|
|
159
|
+
config: PartialBy<ObservedSfuSourceConfig, 'serviceId' | 'mediaUnitId' | 'joined'>
|
|
160
|
+
): ObservedSfuSource {
|
|
161
|
+
if (this._closed) {
|
|
162
|
+
throw new Error(`Attempted to create a sfu source on a closed observer`);
|
|
163
|
+
}
|
|
164
|
+
const serviceId = config.serviceId ?? this.config.defaultServiceId;
|
|
165
|
+
const mediaUnitId = config.mediaUnitId ?? this.config.defaultMediaUnitId;
|
|
166
|
+
const joined = config.joined ?? Date.now();
|
|
167
|
+
return this._sources.createSfuSource({
|
|
168
|
+
...config,
|
|
169
|
+
serviceId,
|
|
170
|
+
mediaUnitId,
|
|
171
|
+
joined,
|
|
151
172
|
});
|
|
152
173
|
}
|
|
153
174
|
|
package/src/common/logger.ts
CHANGED
|
@@ -1,168 +1,186 @@
|
|
|
1
1
|
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
2
2
|
|
|
3
3
|
export interface Logger {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
trace(...args: any[]): void;
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
debug(...args: any[]): void;
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
|
+
info(...args: any[]): void;
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
warn(...args: any[]): void;
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
|
+
error(...args: any[]): void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface WrappedLogger extends Logger {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
init(): void;
|
|
18
|
+
level: LogLevel | undefined,
|
|
19
19
|
logger: Logger;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export type LoggerFactory = () => Logger;
|
|
23
23
|
|
|
24
24
|
const COLORS = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
black: "\x1b[30m",
|
|
26
|
+
red: "\x1b[31m",
|
|
27
|
+
green: "\x1b[32m",
|
|
28
|
+
yellow: "\x1b[33m",
|
|
29
|
+
blue: "\x1b[34m",
|
|
30
|
+
magenta: "\x1b[35m",
|
|
31
|
+
cyan: "\x1b[36m",
|
|
32
|
+
white: "\x1b[37m",
|
|
33
|
+
default: "\x1b[39m",
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
let defaultLevel: LogLevel =
|
|
36
|
+
let defaultLevel: LogLevel = "error";
|
|
37
|
+
const created = Date.now();
|
|
37
38
|
|
|
38
39
|
function createDefaultLoggerFactory(): LoggerFactory {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
return () => {
|
|
41
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
42
|
+
const trace = (...args: any[]) => {
|
|
43
|
+
/* eslint-disable no-debugger, no-console */
|
|
44
|
+
console.trace(...args);
|
|
45
|
+
};
|
|
46
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
47
|
+
const debug = (...args: any[]) => {
|
|
48
|
+
/* eslint-disable no-debugger, no-console */
|
|
49
|
+
console.debug(...args);
|
|
50
|
+
};
|
|
51
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
52
|
+
const info = (...args: any[]) => {
|
|
53
|
+
/* eslint-disable no-debugger, no-console */
|
|
54
|
+
console.info(...args);
|
|
55
|
+
};
|
|
56
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
57
|
+
const warn = (...args: any[]) => {
|
|
58
|
+
/* eslint-disable no-debugger, no-console */
|
|
59
|
+
console.warn(...args);
|
|
60
|
+
};
|
|
61
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
62
|
+
const error = (...args: any[]) => {
|
|
63
|
+
/* eslint-disable no-debugger, no-console */
|
|
64
|
+
console.error(...args);
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
trace,
|
|
68
|
+
debug,
|
|
69
|
+
info,
|
|
70
|
+
warn,
|
|
71
|
+
error,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
const wrapLogger = (logger: Logger,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
const wrapLogger = (logger: Logger, moduleName: string, logLevel?: LogLevel) => {
|
|
77
|
+
|
|
78
|
+
let isTrace = false;
|
|
79
|
+
let isDebug = false
|
|
80
|
+
let isInfo = false
|
|
81
|
+
let isWarning = false;
|
|
82
|
+
let isError = false;
|
|
83
|
+
|
|
84
|
+
let _level = logLevel;
|
|
85
|
+
let _logger = logger;
|
|
86
|
+
const tracePrefix = `${COLORS.magenta}[TRACE]${COLORS.default} ${moduleName}`;
|
|
87
|
+
const debugPrefix = `${COLORS.cyan}[DEBUG]${COLORS.default} ${moduleName}`;
|
|
88
|
+
const infoPrefix = `${COLORS.green}[INFO]${COLORS.default} ${moduleName}`;
|
|
89
|
+
const warnPrefix = `${COLORS.yellow}[WARN]${COLORS.default} ${moduleName}`;
|
|
90
|
+
const errorPrefix = `${COLORS.red}[ERROR]${COLORS.default} ${moduleName}`;
|
|
91
|
+
|
|
92
|
+
const result = new class implements WrappedLogger {
|
|
93
|
+
public init() {
|
|
94
|
+
isTrace = ["trace"].includes(_level ?? defaultLevel);
|
|
95
|
+
isDebug = ["trace", "debug"].includes(_level ?? defaultLevel);
|
|
96
|
+
isInfo = ["trace", "debug", "info"].includes(_level ?? defaultLevel);
|
|
97
|
+
isWarning = ["trace", "debug", "info", "warn"].includes(_level ?? defaultLevel);
|
|
98
|
+
isError = ["trace", "debug", "info", "warn", "error"].includes(_level ?? defaultLevel);
|
|
99
|
+
}
|
|
88
100
|
public get logger() {
|
|
89
101
|
return _logger;
|
|
90
102
|
}
|
|
91
103
|
public set logger(value: Logger) {
|
|
92
104
|
_logger = value;
|
|
93
105
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
106
|
+
public get level(): LogLevel | undefined {
|
|
107
|
+
return _level;
|
|
108
|
+
}
|
|
109
|
+
public set level(value: LogLevel | undefined) {
|
|
110
|
+
_level = value;
|
|
111
|
+
}
|
|
112
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
113
|
+
trace(...args: any[]): void {
|
|
114
|
+
if (isTrace) {
|
|
115
|
+
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`
|
|
116
|
+
logger.trace(tracePrefix, ...args, elapsedInMs);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
120
|
+
debug(...args: any[]): void {
|
|
121
|
+
if (isDebug) {
|
|
122
|
+
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`
|
|
123
|
+
logger.debug(debugPrefix, ...args, elapsedInMs);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
127
|
+
info(...args: any[]): void {
|
|
128
|
+
if (isInfo) {
|
|
129
|
+
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`
|
|
130
|
+
logger.info(infoPrefix, ...args, elapsedInMs);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
134
|
+
warn(...args: any[]): void {
|
|
135
|
+
if (isWarning) {
|
|
136
|
+
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`
|
|
137
|
+
logger.warn(warnPrefix, ...args, elapsedInMs);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
141
|
+
error(...args: any[]): void {
|
|
142
|
+
if (isError) {
|
|
143
|
+
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`
|
|
144
|
+
logger.error(errorPrefix, ...args, elapsedInMs);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
|
|
133
152
|
|
|
134
153
|
let actualLoggerFactory: LoggerFactory = createDefaultLoggerFactory();
|
|
135
154
|
const loggers = new Map<string, WrappedLogger>();
|
|
136
155
|
|
|
137
|
-
export const createLogger = (moduleName: string, logLevel?: LogLevel)
|
|
156
|
+
export const createLogger = (moduleName: string, logLevel?: LogLevel) => {
|
|
138
157
|
let wrappedLogger = loggers.get(moduleName);
|
|
139
158
|
if (!wrappedLogger) {
|
|
140
|
-
|
|
141
|
-
wrappedLogger = wrapLogger(logger, logLevel ?? defaultLevel);
|
|
159
|
+
const logger = actualLoggerFactory();
|
|
160
|
+
wrappedLogger = wrapLogger(logger, moduleName, logLevel ?? defaultLevel);
|
|
142
161
|
loggers.set(moduleName, wrappedLogger);
|
|
143
162
|
} else {
|
|
144
163
|
wrappedLogger.level = logLevel ?? defaultLevel;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
164
|
+
}
|
|
165
|
+
wrappedLogger.init();
|
|
166
|
+
return wrappedLogger;
|
|
167
|
+
}
|
|
149
168
|
|
|
150
169
|
export const setLogLevel = (level: LogLevel) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
170
|
+
defaultLevel = level;
|
|
171
|
+
for (const [moduleName] of Array.from(loggers.entries())) {
|
|
172
|
+
loggers.set(moduleName, createLogger(moduleName, level));
|
|
173
|
+
}
|
|
156
174
|
};
|
|
157
175
|
|
|
158
176
|
export const setLoggerFactory = (loggerFactory: LoggerFactory) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
177
|
+
actualLoggerFactory = loggerFactory;
|
|
178
|
+
for (const [moduleName, logger] of Array.from(loggers.entries())) {
|
|
179
|
+
loggers.set(moduleName, createLogger(moduleName, logger.level));
|
|
180
|
+
}
|
|
164
181
|
};
|
|
165
182
|
|
|
166
183
|
export const getLogLevel = () => {
|
|
167
|
-
|
|
168
|
-
}
|
|
184
|
+
return defaultLevel;
|
|
185
|
+
}
|
|
186
|
+
|
package/src/common/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import * as Models from '../models/Models';
|
|
|
14
14
|
import { StorageProvider } from '../storages/StorageProvider';
|
|
15
15
|
import { Message } from '@bufbuild/protobuf';
|
|
16
16
|
import { Middleware } from '../middlewares/Middleware';
|
|
17
|
+
import { ObservedSfus } from '../samples/ObservedSfus';
|
|
17
18
|
|
|
18
19
|
export type ObserverReport =
|
|
19
20
|
| CallEventReport
|
|
@@ -61,7 +62,33 @@ export interface EvaluatorContext {
|
|
|
61
62
|
removed: number;
|
|
62
63
|
})[];
|
|
63
64
|
|
|
65
|
+
readonly joinedSfuIds: string[];
|
|
66
|
+
readonly detachedSfus: (Omit<Models.Sfu, keyof Message> & {
|
|
67
|
+
detached: number;
|
|
68
|
+
})[];
|
|
69
|
+
|
|
70
|
+
readonly openedSfuTransportIds: string[];
|
|
71
|
+
readonly closedSfuTransports: (Omit<Models.SfuTransport, keyof Message> & {
|
|
72
|
+
closed: number;
|
|
73
|
+
})[];
|
|
74
|
+
|
|
75
|
+
readonly addedSfuInbounRtpPadIds: string[];
|
|
76
|
+
readonly removedSfuInbounRtpPadIds: (Omit<Models.SfuInboundRtpPad, keyof Message> & {
|
|
77
|
+
removed: number;
|
|
78
|
+
})[];
|
|
79
|
+
|
|
80
|
+
readonly addedSfuOutbounRtpPadIds: string[];
|
|
81
|
+
readonly removedSfuOutbounRtpPadIds: (Omit<Models.SfuOutboundRtpPad, keyof Message> & {
|
|
82
|
+
removed: number;
|
|
83
|
+
})[];
|
|
84
|
+
|
|
85
|
+
readonly openedSfuSctpChannelIds: string[];
|
|
86
|
+
readonly closedSfuSctpChannels: (Omit<Models.SfuSctpChannel, keyof Message> & {
|
|
87
|
+
closed: number;
|
|
88
|
+
})[];
|
|
89
|
+
|
|
64
90
|
readonly observedCalls: ObservedCalls;
|
|
91
|
+
readonly observedSfus: ObservedSfus;
|
|
65
92
|
readonly storages: StorageProvider;
|
|
66
93
|
readonly reports: ReportsCollector;
|
|
67
94
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { createLogger } from '../common/logger';
|
|
2
|
-
import { EvaluatorContext } from '../common/types';
|
|
3
|
-
import { ObservedCall } from '../samples/ObservedCall';
|
|
4
|
-
import { ObservedCalls } from '../samples/ObservedCalls';
|
|
5
|
-
import { ObservedClient } from '../samples/ObservedClient';
|
|
6
|
-
import { ObservedPeerConnection } from '../samples/ObservedPeerConnection';
|
|
7
|
-
import { createPeerConnectionOpenedEventReport } from '../sinks/callEventReports';
|
|
8
2
|
import { ObserverStorage } from '../storages/ObserverStorage';
|
|
9
3
|
import { StorageProvider } from '../storages/StorageProvider';
|
|
10
4
|
import { Middleware } from './Middleware';
|
|
@@ -267,6 +261,52 @@ export function createCommitTransactionMiddleware(storageProvider: StorageProvid
|
|
|
267
261
|
evaluatorContext.addedOutboundVideoTrackIds.push(
|
|
268
262
|
...addedUnits(oldOutboundVideoTrackModels, updatedOutboundVideoTracks)
|
|
269
263
|
);
|
|
264
|
+
|
|
265
|
+
evaluatorContext.joinedSfuIds.push(
|
|
266
|
+
...addedUnits(oldSfuModels, updatedSfus)
|
|
267
|
+
);
|
|
268
|
+
evaluatorContext.detachedSfus.push(
|
|
269
|
+
...Array.from(removedSfuModels.values()).map((o) => {
|
|
270
|
+
return {
|
|
271
|
+
...o,
|
|
272
|
+
detached: Date.now(),
|
|
273
|
+
};
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
evaluatorContext.openedSfuTransportIds.push(
|
|
278
|
+
...addedUnits(oldSfuTransportModels, updatedSfuTransports)
|
|
279
|
+
);
|
|
280
|
+
evaluatorContext.closedSfuTransports.push(
|
|
281
|
+
...Array.from(removedSfuTransportModels.values()).map((o) => {
|
|
282
|
+
return {
|
|
283
|
+
...o,
|
|
284
|
+
closed: Date.now(),
|
|
285
|
+
};
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
evaluatorContext.removedSfuInbounRtpPadIds.push(...removedUnits(removedSfuInboundRtpPadModels));
|
|
290
|
+
evaluatorContext.addedSfuInbounRtpPadIds.push(
|
|
291
|
+
...addedUnits(oldSfuInboundRtpPadModels, updatedSfuInboundRtpPads)
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
evaluatorContext.removedSfuOutbounRtpPadIds.push(...removedUnits(removedSfuOutboundRtpPadModels));
|
|
295
|
+
evaluatorContext.addedSfuOutbounRtpPadIds.push(
|
|
296
|
+
...addedUnits(oldSfuOutboundRtpPadModels, updatedSfuOutboundRtpPads)
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
evaluatorContext.openedSfuSctpChannelIds.push(
|
|
300
|
+
...addedUnits(oldSfuSctpChannelModels, updatedSfuSctpChannels)
|
|
301
|
+
);
|
|
302
|
+
evaluatorContext.closedSfuSctpChannels.push(
|
|
303
|
+
...Array.from(removedSfuSctpChannelModels.values()).map((o) => {
|
|
304
|
+
return {
|
|
305
|
+
...o,
|
|
306
|
+
closed: Date.now(),
|
|
307
|
+
};
|
|
308
|
+
})
|
|
309
|
+
);
|
|
270
310
|
};
|
|
271
311
|
|
|
272
312
|
const result = async (context: TransactionContext, next?: Middleware<TransactionContext>) => {
|
|
@@ -6,10 +6,12 @@ import { ReportsCollector } from '../common/ReportsCollector';
|
|
|
6
6
|
import { v4 as uuid } from 'uuid';
|
|
7
7
|
import { EvaluatorContext } from '../common/types';
|
|
8
8
|
import { Writable } from '../common/utils';
|
|
9
|
+
import { ObservedSfus } from '../samples/ObservedSfus';
|
|
9
10
|
|
|
10
11
|
export type TransactionContext = {
|
|
11
12
|
id: string;
|
|
12
13
|
observedCalls: ObservedCalls;
|
|
14
|
+
observedSfus: ObservedSfus;
|
|
13
15
|
|
|
14
16
|
clients: ReadonlyMap<string, Models.Client>;
|
|
15
17
|
|
|
@@ -44,13 +46,14 @@ export type TransactionContext = {
|
|
|
44
46
|
deletedSfuSctpChannels: Set<string>;
|
|
45
47
|
|
|
46
48
|
// build for another middleware
|
|
47
|
-
evaluatorContext: Writable<Omit<EvaluatorContext, 'observedCalls'>>;
|
|
49
|
+
evaluatorContext: Writable<Omit<EvaluatorContext, 'observedCalls' | 'observedSfus'>>;
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
export async function createTransactionContext(
|
|
51
53
|
evaluatorContext: EvaluatorContext,
|
|
52
54
|
storageProvider: StorageProvider,
|
|
53
|
-
observedCalls: ObservedCalls
|
|
55
|
+
observedCalls: ObservedCalls,
|
|
56
|
+
observedSfus: ObservedSfus,
|
|
54
57
|
): Promise<TransactionContext> {
|
|
55
58
|
const {
|
|
56
59
|
clientStorage,
|
|
@@ -103,7 +106,8 @@ export async function createTransactionContext(
|
|
|
103
106
|
const transactionContext: TransactionContext = {
|
|
104
107
|
id: uuid(),
|
|
105
108
|
observedCalls,
|
|
106
|
-
|
|
109
|
+
observedSfus,
|
|
110
|
+
|
|
107
111
|
clients,
|
|
108
112
|
updatedPeerConnections: new Map<string, Models.PeerConnection>(peerConnections.entries()),
|
|
109
113
|
deletedPeerConnections: new Set<string>(),
|
|
@@ -4,6 +4,7 @@ import { createCommitTransactionMiddleware } from './CommitTransactionMiddleware
|
|
|
4
4
|
import { Processor, createProcessor } from './Processor';
|
|
5
5
|
import { TransactionContext } from './TransactionContext';
|
|
6
6
|
import { createVisitObservedCallsMiddleware } from './VisitObservedCallsMiddleware';
|
|
7
|
+
import { createVisitObservedSfusMiddleware } from './VisitObservedSfusMiddleware';
|
|
7
8
|
|
|
8
9
|
export function createTransactionProcessor(
|
|
9
10
|
storageProvider: StorageProvider,
|
|
@@ -11,8 +12,9 @@ export function createTransactionProcessor(
|
|
|
11
12
|
fetchSamples: boolean
|
|
12
13
|
): Processor<TransactionContext> {
|
|
13
14
|
return createProcessor(
|
|
14
|
-
// all of these
|
|
15
|
+
// all of these middlewares must execute sequentially!
|
|
15
16
|
createVisitObservedCallsMiddleware(reportsCollector, fetchSamples),
|
|
17
|
+
createVisitObservedSfusMiddleware(reportsCollector, fetchSamples),
|
|
16
18
|
|
|
17
19
|
// must be the last one!
|
|
18
20
|
createCommitTransactionMiddleware(storageProvider)
|
|
@@ -6,7 +6,7 @@ import { visitPeerConnection } from './visitors/visitPeerConnection';
|
|
|
6
6
|
import { createLogger } from '../common/logger';
|
|
7
7
|
import { visitInboundAudioTrack } from './visitors/visitInboundAudioTrack';
|
|
8
8
|
import { visitOutboundAudioTrack } from './visitors/visitOutboundAudioTrack';
|
|
9
|
-
import { visitOutboundVideoTrack } from './visitors/
|
|
9
|
+
import { visitOutboundVideoTrack } from './visitors/visitOutboundVideoTarck';
|
|
10
10
|
|
|
11
11
|
export const logger = createLogger('VisitObservedCallsMiddleware');
|
|
12
12
|
|