decord/source/modules/monitoring/MonitoringAgent.tsx

157 lines
4.7 KiB
TypeScript
Raw Normal View History

// Module ID: 7653
// Function ID: 7654
// Name: MonitoringAgent
// Dependencies: [1074, 1115, 7654, 7655, 17, 7656, 7657, 1272, 2]
2026-07-20 16:05:17 +00:00
// Module 7653 (MonitoringAgent)
import Constants from "Constants" /* 1074 */;
import HTTPUtils from "HTTPUtils" /* 1272 */;
import NativeMetricMonitorModule from "NativeMetricMonitorModule" /* 7656 */;
import MonitoringAgentUtils from "MonitoringAgentUtils" /* 7657 */;
import get_ActivityIndicator from "module_17" /* 17 */;
import PlatformUtils from "PlatformUtils" /* 1115 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
const Endpoints = Constants.Endpoints;
const set = new Set(["darwin", "linux", "win32", "ios", "android"]);
const MetricType = { COUNT: "count", DISTRIBUTION: "distribution" };
2026-07-29 08:29:29 +00:00
class MonitoringAgent {
constructor() {
obj1 = Object.create(new.target.prototype);
closure_0 = obj1;
obj1._metrics = [];
obj1._intervalId = setInterval(() => {
obj2._flush();
2026-07-29 08:29:29 +00:00
}, 120000);
2026-08-24 06:08:38 +00:00
tmp2 = closure_0;
2026-07-29 08:29:29 +00:00
tmp3 = closure_1;
tmp4 = closure_0(closure_1[4]);
2026-07-29 08:29:29 +00:00
({ NativeModules, NativeEventEmitter } = tmp4);
obj = closure_0(closure_1[1]);
2026-07-29 08:29:29 +00:00
if (obj.isAndroid()) {
MetricMonitor = tmp2(tmp3[5]).default;
2026-07-29 08:29:29 +00:00
} else {
MetricMonitor = NativeModules.MetricMonitor;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
nativeEventEmitter = new NativeEventEmitter(MetricMonitor);
addListenerResult = nativeEventEmitter.addListener("logMetric", (arg0) => {
obj2.increment(arg0, false);
2026-07-29 08:29:29 +00:00
});
return obj1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
const prototype = MonitoringAgent.prototype;
prototype["_getMetricWithDefaults"] = function _getMetricWithDefaults(name, COUNT) {
let tags = name.tags;
obj = { name: name.name, type: COUNT, tags: MonitoringAgentUtils.getGlobalTagsArray() };
2026-07-29 08:29:29 +00:00
if (null != tags) {
const item = tags.forEach((item) => {
2026-07-29 08:29:29 +00:00
const tags = obj.tags;
tags.push(item);
2026-07-29 08:29:29 +00:00
});
}
let str = "web";
if (!tmpResult.isWeb()) {
const platformName = tmp(1115).getPlatformName();
2026-07-29 08:29:29 +00:00
let tmp6 = null;
if (set.has(platformName)) {
tmp6 = platformName;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
str = tmp6;
const tmpResult2 = tmp(1115);
2026-07-29 08:29:29 +00:00
}
if (null != str) {
const tags1 = obj.tags;
const _HermesInternal = HermesInternal;
tags1.push("platform:" + str);
}
const CurrentReleaseChannel = tmp(7654).CurrentReleaseChannel;
2026-07-29 08:29:29 +00:00
let tmp9 = null;
if (null != CurrentReleaseChannel) {
const ALL = tmp(7655).ReleaseChannelsSets.ALL;
2026-07-29 08:29:29 +00:00
tmp9 = null;
if (ALL.has(CurrentReleaseChannel)) {
tmp9 = CurrentReleaseChannel;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
if (null != tmp9) {
const tags2 = obj.tags;
const _HermesInternal2 = HermesInternal;
tags2.push("release_channel:" + tmp9);
}
return obj;
};
prototype["increment"] = function increment(name) {
let flag = arg1;
if (arg1 === undefined) {
flag = false;
}
const self = this;
const _metrics = this._metrics;
_metrics.push(this._getMetricWithDefaults(name, obj.COUNT));
if (!flag) {
flag = self._metrics.length >= 100;
}
if (flag) {
self._flush();
}
};
prototype["distribution"] = function distribution(name, value) {
let flag = arg2;
if (arg2 === undefined) {
flag = false;
}
const self = this;
2026-08-24 06:08:38 +00:00
obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(this._getMetricWithDefaults(name, obj.DISTRIBUTION));
obj.value = value;
const _metrics = this._metrics;
_metrics.push(obj);
if (!flag) {
flag = self._metrics.length >= 100;
}
if (flag) {
self._flush();
}
};
prototype["_flush"] = function _flush() {
const self = this;
2026-07-29 08:29:29 +00:00
if (this._metrics.length > 0) {
let items = [];
HermesBuiltin.arraySpread(self._metrics, 0);
const HTTP = HTTPUtils.HTTP;
const request = { url: Endpoints.METRICS_V2, body: null, retries: 1, rejectWithError: true };
const body = { metrics: items, client_info: { built_at: "1789017551964", build_number: "6393" } };
request.body = body;
HTTP.post(request).catch(() => {
2026-07-29 08:29:29 +00:00
if (self._metrics.length + items.length < 100) {
items = [];
HermesBuiltin.arraySpread(tmp2, HermesBuiltin.arraySpread(tmp._metrics, 0));
tmp._metrics = items;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
});
const postResult = HTTP.post(request);
2026-07-29 08:29:29 +00:00
}
self._metrics = [];
};
let obj2 = Object.create(MonitoringAgent.prototype);
let closure_129_0 = obj2;
obj2._metrics = [];
obj2._intervalId = setInterval(() => {
obj2._flush();
2026-07-29 08:29:29 +00:00
}, 120000);
({ NativeModules, NativeEventEmitter } = get_ActivityIndicator);
if (PlatformUtils.isAndroid()) {
let MetricMonitor = NativeMetricMonitorModule.default;
2026-07-29 08:29:29 +00:00
} else {
MetricMonitor = NativeModules.MetricMonitor;
}
let nativeEventEmitter = new NativeEventEmitter(MetricMonitor);
nativeEventEmitter.addListener("logMetric", (arg0) => {
obj2.increment(arg0, false);
2026-07-29 08:29:29 +00:00
});
const result = size.fileFinishedImporting("modules/monitoring/MonitoringAgent.tsx");
2026-07-20 16:05:17 +00:00
export default obj2;
export { MetricType };