first commit
This commit is contained in:
52
node_modules/matrix-bot-sdk/lib/metrics/IMetricListener.d.ts
generated
vendored
Normal file
52
node_modules/matrix-bot-sdk/lib/metrics/IMetricListener.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { IMetricContext } from "./contexts";
|
||||
/**
|
||||
* A simple interface for listening for Metric updates. Should be plugged into
|
||||
* something like Prometheus for recording.
|
||||
*
|
||||
* Metric names are defined in metric_names.ts - see documentation on the name
|
||||
* for what the context object contains. All metrics have a context object,
|
||||
* with applicable interface. See the IMetricContext interface for more
|
||||
* information.
|
||||
* @category Metrics
|
||||
*/
|
||||
export interface IMetricListener {
|
||||
/**
|
||||
* Called when the given metric should start being tracked. Will be
|
||||
* paired with a matching onEndMetric() call.
|
||||
* @param {string} metricName The metric being called.
|
||||
* @param {IMetricContext} context Context for the metric. Never null.
|
||||
*/
|
||||
onStartMetric(metricName: string, context: IMetricContext): void;
|
||||
/**
|
||||
* Called when the given metric should stop being tracked. Will have
|
||||
* started with a matching onStartMetric() call.
|
||||
* @param {string} metricName The metric being called.
|
||||
* @param {any} context Context for the metric. Never null.
|
||||
* @param {number} timeMs The measured time in milliseconds between
|
||||
* the start and end.
|
||||
*/
|
||||
onEndMetric(metricName: string, context: IMetricContext, timeMs: number): void;
|
||||
/**
|
||||
* Called when a linear metric (increasing/decreasing number) should
|
||||
* be incremented.
|
||||
* @param {string} metricName The metric being called.
|
||||
* @param {IMetricContext} context Context for the metric. Never null.
|
||||
* @param {number} amount The amount to add. Never negative or zero.
|
||||
*/
|
||||
onIncrement(metricName: string, context: IMetricContext, amount: number): any;
|
||||
/**
|
||||
* Called when a linear metric (increasing/decreasing number) should
|
||||
* be decremented.
|
||||
* @param {string} metricName The metric being called.
|
||||
* @param {IMetricContext} context Context for the metric. Never null.
|
||||
* @param {number} amount The amount to subtract. Never negative or zero.
|
||||
*/
|
||||
onDecrement(metricName: string, context: IMetricContext, amount: number): any;
|
||||
/**
|
||||
* Called when a linear metric (increasing/decreasing number) should
|
||||
* be reset to zero.
|
||||
* @param {string} metricName The metric being called.
|
||||
* @param {IMetricContext} context Context for the metric. Never null.
|
||||
*/
|
||||
onReset(metricName: string, context: IMetricContext): any;
|
||||
}
|
3
node_modules/matrix-bot-sdk/lib/metrics/IMetricListener.js
generated
vendored
Normal file
3
node_modules/matrix-bot-sdk/lib/metrics/IMetricListener.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IMetricListener.js.map
|
1
node_modules/matrix-bot-sdk/lib/metrics/IMetricListener.js.map
generated
vendored
Normal file
1
node_modules/matrix-bot-sdk/lib/metrics/IMetricListener.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"IMetricListener.js","sourceRoot":"","sources":["../../src/metrics/IMetricListener.ts"],"names":[],"mappings":""}
|
66
node_modules/matrix-bot-sdk/lib/metrics/Metrics.d.ts
generated
vendored
Normal file
66
node_modules/matrix-bot-sdk/lib/metrics/Metrics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { IMetricListener } from "./IMetricListener";
|
||||
import { IMetricContext } from "./contexts";
|
||||
/**
|
||||
* Tracks metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare class Metrics {
|
||||
private listeners;
|
||||
private requestStartTimes;
|
||||
private uid;
|
||||
/**
|
||||
* Creates a new Metrics handler with optional parent handler. When
|
||||
* a parent handler is defined, metrics will be automatically published
|
||||
* upwards to the parent.
|
||||
* @param {Metrics} parent Optional parent for upstream metrics.
|
||||
*/
|
||||
constructor(parent?: Metrics);
|
||||
/**
|
||||
* Registers a metric listener.
|
||||
* @param {IMetricListener} listener The listener.
|
||||
*/
|
||||
registerListener(listener: IMetricListener): void;
|
||||
/**
|
||||
* De-registers a metric listener.
|
||||
* @param {IMetricListener} listener The listener.
|
||||
*/
|
||||
unregisterListener(listener: IMetricListener): void;
|
||||
/**
|
||||
* Starts a timer on a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
*/
|
||||
start(metricName: string, context: IMetricContext): void;
|
||||
/**
|
||||
* Ends a timer on a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
*/
|
||||
end(metricName: string, context: IMetricContext): void;
|
||||
/**
|
||||
* Increments a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
* @param {number} amount The amount.
|
||||
*/
|
||||
increment(metricName: string, context: IMetricContext, amount: number): void;
|
||||
/**
|
||||
* Decrements a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
* @param {number} amount The amount.
|
||||
*/
|
||||
decrement(metricName: string, context: IMetricContext, amount: number): void;
|
||||
/**
|
||||
* Resets a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
*/
|
||||
reset(metricName: string, context: IMetricContext): void;
|
||||
/**
|
||||
* Assigns a unique ID to the context object, returning it back.
|
||||
* @param {IMetricContext} context The context to modify.
|
||||
* @returns {IMetricContext} The provided context.
|
||||
*/
|
||||
assignUniqueContextId(context: IMetricContext): IMetricContext;
|
||||
}
|
128
node_modules/matrix-bot-sdk/lib/metrics/Metrics.js
generated
vendored
Normal file
128
node_modules/matrix-bot-sdk/lib/metrics/Metrics.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Metrics = void 0;
|
||||
const __1 = require("..");
|
||||
/**
|
||||
* Tracks metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
class Metrics {
|
||||
/**
|
||||
* Creates a new Metrics handler with optional parent handler. When
|
||||
* a parent handler is defined, metrics will be automatically published
|
||||
* upwards to the parent.
|
||||
* @param {Metrics} parent Optional parent for upstream metrics.
|
||||
*/
|
||||
constructor(parent = null) {
|
||||
this.listeners = [];
|
||||
this.requestStartTimes = {};
|
||||
this.uid = 0;
|
||||
if (parent !== null) {
|
||||
this.registerListener({
|
||||
onIncrement(metricName, context, amount) {
|
||||
parent.listeners.forEach(h => h.onIncrement(metricName, context, amount));
|
||||
},
|
||||
onDecrement(metricName, context, amount) {
|
||||
parent.listeners.forEach(h => h.onDecrement(metricName, context, amount));
|
||||
},
|
||||
onReset(metricName, context) {
|
||||
parent.listeners.forEach(h => h.onReset(metricName, context));
|
||||
},
|
||||
onStartMetric(metricName, context) {
|
||||
parent.listeners.forEach(h => h.onStartMetric(metricName, context));
|
||||
},
|
||||
onEndMetric(metricName, context, timeMs) {
|
||||
parent.listeners.forEach(h => h.onEndMetric(metricName, context, timeMs));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Registers a metric listener.
|
||||
* @param {IMetricListener} listener The listener.
|
||||
*/
|
||||
registerListener(listener) {
|
||||
this.listeners.push(listener);
|
||||
}
|
||||
/**
|
||||
* De-registers a metric listener.
|
||||
* @param {IMetricListener} listener The listener.
|
||||
*/
|
||||
unregisterListener(listener) {
|
||||
const idx = this.listeners.indexOf(listener);
|
||||
if (idx !== -1)
|
||||
this.listeners.splice(idx, 1);
|
||||
}
|
||||
/**
|
||||
* Starts a timer on a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
*/
|
||||
start(metricName, context) {
|
||||
this.requestStartTimes[context.uniqueId] = new Date().getTime();
|
||||
this.listeners.forEach(h => h.onStartMetric(metricName, context));
|
||||
}
|
||||
/**
|
||||
* Ends a timer on a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
*/
|
||||
end(metricName, context) {
|
||||
const timeMs = (new Date().getTime()) - this.requestStartTimes[context.uniqueId];
|
||||
delete this.requestStartTimes[context.uniqueId];
|
||||
this.listeners.forEach(h => h.onEndMetric(metricName, context, timeMs));
|
||||
// Trim the context for logging
|
||||
const trimmedContext = {};
|
||||
for (const key of Object.keys(context)) {
|
||||
if (key === 'client') {
|
||||
const client = context[key];
|
||||
trimmedContext[key] = `<MatrixClient ${client['userId'] || 'NoCachedUserID'}>`;
|
||||
}
|
||||
else if (key === 'intent') {
|
||||
const intent = context[key];
|
||||
trimmedContext[key] = `<Intent ${intent['userId'] || 'NoImpersonatedUserID'}>`;
|
||||
}
|
||||
else {
|
||||
trimmedContext[key] = context[key];
|
||||
}
|
||||
}
|
||||
__1.LogService.trace("Metrics", metricName, trimmedContext, timeMs);
|
||||
}
|
||||
/**
|
||||
* Increments a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
* @param {number} amount The amount.
|
||||
*/
|
||||
increment(metricName, context, amount) {
|
||||
this.listeners.forEach(h => h.onIncrement(metricName, context, amount));
|
||||
}
|
||||
/**
|
||||
* Decrements a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
* @param {number} amount The amount.
|
||||
*/
|
||||
decrement(metricName, context, amount) {
|
||||
this.listeners.forEach(h => h.onDecrement(metricName, context, amount));
|
||||
}
|
||||
/**
|
||||
* Resets a metric.
|
||||
* @param {string} metricName The metric name.
|
||||
* @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
||||
*/
|
||||
reset(metricName, context) {
|
||||
this.listeners.forEach(h => h.onReset(metricName, context));
|
||||
}
|
||||
/**
|
||||
* Assigns a unique ID to the context object, returning it back.
|
||||
* @param {IMetricContext} context The context to modify.
|
||||
* @returns {IMetricContext} The provided context.
|
||||
*/
|
||||
assignUniqueContextId(context) {
|
||||
context.uniqueId = `${new Date().getTime()}-${this.uid++}`;
|
||||
return context;
|
||||
}
|
||||
}
|
||||
exports.Metrics = Metrics;
|
||||
//# sourceMappingURL=Metrics.js.map
|
1
node_modules/matrix-bot-sdk/lib/metrics/Metrics.js.map
generated
vendored
Normal file
1
node_modules/matrix-bot-sdk/lib/metrics/Metrics.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Metrics.js","sourceRoot":"","sources":["../../src/metrics/Metrics.ts"],"names":[],"mappings":";;;AAEA,0BAAgC;AAEhC;;;GAGG;AACH,MAAa,OAAO;IAKhB;;;;;OAKG;IACH,YAAY,SAAkB,IAAI;QAV1B,cAAS,GAAsB,EAAE,CAAC;QAClC,sBAAiB,GAAoC,EAAE,CAAC;QACxD,QAAG,GAAG,CAAC,CAAC;QASZ,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,gBAAgB,CAAC;gBAClB,WAAW,CAAC,UAAkB,EAAE,OAAuB,EAAE,MAAc;oBACnE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC9E,CAAC;gBACD,WAAW,CAAC,UAAkB,EAAE,OAAuB,EAAE,MAAc;oBACnE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC9E,CAAC;gBACD,OAAO,CAAC,UAAkB,EAAE,OAAuB;oBAC/C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;gBAClE,CAAC;gBACD,aAAa,CAAC,UAAkB,EAAE,OAAuB;oBACrD,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE,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OAIG;IACI,KAAK,CAAC,UAAkB,EAAE,OAAuB;QACpD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,OAAuB;QAChD,OAAO,CAAC,QAAQ,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAC3D,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7HD,0BA6HC"}
|
51
node_modules/matrix-bot-sdk/lib/metrics/contexts.d.ts
generated
vendored
Normal file
51
node_modules/matrix-bot-sdk/lib/metrics/contexts.d.ts
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Default context for all metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
import { MatrixClient } from "../MatrixClient";
|
||||
import { Intent } from "../appservice/Intent";
|
||||
import { IdentityClient } from "../identity/IdentityClient";
|
||||
export interface IMetricContext {
|
||||
/**
|
||||
* Unique identifier for the context object. Used to differentiate
|
||||
* contexts over a start/end event.
|
||||
*/
|
||||
uniqueId: string;
|
||||
}
|
||||
/**
|
||||
* Metric context for function call metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
export interface FunctionCallContext extends IMetricContext {
|
||||
/**
|
||||
* The function name being called
|
||||
*/
|
||||
functionName: string;
|
||||
}
|
||||
/**
|
||||
* Metric context for metrics from a MatrixClient
|
||||
* @category Metrics
|
||||
*/
|
||||
export interface MatrixClientCallContext extends FunctionCallContext {
|
||||
/**
|
||||
* The client that raised the metric.
|
||||
*/
|
||||
client: MatrixClient;
|
||||
}
|
||||
/**
|
||||
* Metric context for metrics from an IdentityClient
|
||||
* @category Metrics
|
||||
*/
|
||||
export interface IdentityClientCallContext extends FunctionCallContext {
|
||||
client: IdentityClient;
|
||||
}
|
||||
/**
|
||||
* Metric context for metrics from an Intent
|
||||
* @category Metrics
|
||||
*/
|
||||
export interface IntentCallContext extends MatrixClientCallContext {
|
||||
/**
|
||||
* The intent that is raising the metric.
|
||||
*/
|
||||
intent: Intent;
|
||||
}
|
3
node_modules/matrix-bot-sdk/lib/metrics/contexts.js
generated
vendored
Normal file
3
node_modules/matrix-bot-sdk/lib/metrics/contexts.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=contexts.js.map
|
1
node_modules/matrix-bot-sdk/lib/metrics/contexts.js.map
generated
vendored
Normal file
1
node_modules/matrix-bot-sdk/lib/metrics/contexts.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"contexts.js","sourceRoot":"","sources":["../../src/metrics/contexts.ts"],"names":[],"mappings":""}
|
15
node_modules/matrix-bot-sdk/lib/metrics/decorators.d.ts
generated
vendored
Normal file
15
node_modules/matrix-bot-sdk/lib/metrics/decorators.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Times a MatrixClient function call for metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare function timedMatrixClientFunctionCall(): (_target: unknown, functionName: string, descriptor: PropertyDescriptor) => void;
|
||||
/**
|
||||
* Times an IdentityClient function call for metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare function timedIdentityClientFunctionCall(): (_target: unknown, functionName: string, descriptor: PropertyDescriptor) => void;
|
||||
/**
|
||||
* Times an Intent function call for metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare function timedIntentFunctionCall(): (_target: unknown, functionName: string, descriptor: PropertyDescriptor) => void;
|
93
node_modules/matrix-bot-sdk/lib/metrics/decorators.js
generated
vendored
Normal file
93
node_modules/matrix-bot-sdk/lib/metrics/decorators.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.timedIntentFunctionCall = exports.timedIdentityClientFunctionCall = exports.timedMatrixClientFunctionCall = void 0;
|
||||
const names_1 = require("./names");
|
||||
/**
|
||||
* Times a MatrixClient function call for metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
function timedMatrixClientFunctionCall() {
|
||||
return function (_target, functionName, descriptor) {
|
||||
const originalMethod = descriptor.value;
|
||||
descriptor.value = async function (...args) {
|
||||
const context = this.metrics.assignUniqueContextId({
|
||||
functionName,
|
||||
client: this,
|
||||
});
|
||||
this.metrics.start(names_1.METRIC_MATRIX_CLIENT_FUNCTION_CALL, context);
|
||||
try {
|
||||
const result = await originalMethod.apply(this, args);
|
||||
this.metrics.increment(names_1.METRIC_MATRIX_CLIENT_SUCCESSFUL_FUNCTION_CALL, context, 1);
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
this.metrics.increment(names_1.METRIC_MATRIX_CLIENT_FAILED_FUNCTION_CALL, context, 1);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this.metrics.end(names_1.METRIC_MATRIX_CLIENT_FUNCTION_CALL, context);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.timedMatrixClientFunctionCall = timedMatrixClientFunctionCall;
|
||||
/**
|
||||
* Times an IdentityClient function call for metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
function timedIdentityClientFunctionCall() {
|
||||
return function (_target, functionName, descriptor) {
|
||||
const originalMethod = descriptor.value;
|
||||
descriptor.value = async function (...args) {
|
||||
const context = this.metrics.assignUniqueContextId({
|
||||
functionName,
|
||||
client: this,
|
||||
});
|
||||
this.metrics.start(names_1.METRIC_IDENTITY_CLIENT_FUNCTION_CALL, context);
|
||||
try {
|
||||
const result = await originalMethod.apply(this, args);
|
||||
this.metrics.increment(names_1.METRIC_IDENTITY_CLIENT_SUCCESSFUL_FUNCTION_CALL, context, 1);
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
this.metrics.increment(names_1.METRIC_IDENTITY_CLIENT_FAILED_FUNCTION_CALL, context, 1);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this.metrics.end(names_1.METRIC_IDENTITY_CLIENT_FUNCTION_CALL, context);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.timedIdentityClientFunctionCall = timedIdentityClientFunctionCall;
|
||||
/**
|
||||
* Times an Intent function call for metrics.
|
||||
* @category Metrics
|
||||
*/
|
||||
function timedIntentFunctionCall() {
|
||||
return function (_target, functionName, descriptor) {
|
||||
const originalMethod = descriptor.value;
|
||||
descriptor.value = async function (...args) {
|
||||
const context = this.metrics.assignUniqueContextId({
|
||||
functionName,
|
||||
client: this.client,
|
||||
intent: this,
|
||||
});
|
||||
this.metrics.start(names_1.METRIC_INTENT_FUNCTION_CALL, context);
|
||||
try {
|
||||
const result = await originalMethod.apply(this, args);
|
||||
this.metrics.increment(names_1.METRIC_INTENT_SUCCESSFUL_FUNCTION_CALL, context, 1);
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
this.metrics.increment(names_1.METRIC_INTENT_FAILED_FUNCTION_CALL, context, 1);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this.metrics.end(names_1.METRIC_INTENT_FUNCTION_CALL, context);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.timedIntentFunctionCall = timedIntentFunctionCall;
|
||||
//# sourceMappingURL=decorators.js.map
|
1
node_modules/matrix-bot-sdk/lib/metrics/decorators.js.map
generated
vendored
Normal file
1
node_modules/matrix-bot-sdk/lib/metrics/decorators.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/metrics/decorators.ts"],"names":[],"mappings":";;;AAAA,mCAUiB;AAGjB;;;GAGG;AACH,SAAgB,6BAA6B;IACzC,OAAO,UAAS,OAAgB,EAAE,YAAoB,EAAE,UAA8B;QAClF,MAAM,cAAc,GAAG,UAAU,CAAC,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AAG,CAAC,mCAA2B,EAAE,OAAO,CAAC,CAAC;aAC1D;QACL,CAAC,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AAtBD,0DAsBC"}
|
45
node_modules/matrix-bot-sdk/lib/metrics/names.d.ts
generated
vendored
Normal file
45
node_modules/matrix-bot-sdk/lib/metrics/names.d.ts
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Time-series metric for how long a function call takes on MatrixClient. Uses a MatrixClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_MATRIX_CLIENT_FUNCTION_CALL = "matrix_client_function_call";
|
||||
/**
|
||||
* Counter metric for failed function calls on a MatrixClient. Uses a MatrixClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_MATRIX_CLIENT_FAILED_FUNCTION_CALL = "matrix_client_failed_function_call";
|
||||
/**
|
||||
* Counter metric for successful function calls on a MatrixClient. Uses a MatrixClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_MATRIX_CLIENT_SUCCESSFUL_FUNCTION_CALL = "matrix_client_successful_function_call";
|
||||
/**
|
||||
* Time-series metric for how long a function call takes on an IdentityClient. Uses an IdentityClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_IDENTITY_CLIENT_FUNCTION_CALL = "identity_client_function_call";
|
||||
/**
|
||||
* Counter metric for failed function calls on an IdentityClient. Uses an IdentityClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_IDENTITY_CLIENT_FAILED_FUNCTION_CALL = "identity_client_failed_function_call";
|
||||
/**
|
||||
* Counter metric for successful function calls on an IdentityClient. Uses an IdentityClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_IDENTITY_CLIENT_SUCCESSFUL_FUNCTION_CALL = "identity_client_successful_function_call";
|
||||
/**
|
||||
* Time-series metric for how long a function call takes on an Intent. Uses a IntentCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_INTENT_FUNCTION_CALL = "intent_function_call";
|
||||
/**
|
||||
* Counter metric for failed function calls on an Intent. Uses a IntentCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_INTENT_FAILED_FUNCTION_CALL = "intent_failed_function_call";
|
||||
/**
|
||||
* Counter metric for successful function calls on an Intent. Uses a IntentCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
export declare const METRIC_INTENT_SUCCESSFUL_FUNCTION_CALL = "intent_successful_function_call";
|
49
node_modules/matrix-bot-sdk/lib/metrics/names.js
generated
vendored
Normal file
49
node_modules/matrix-bot-sdk/lib/metrics/names.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.METRIC_INTENT_SUCCESSFUL_FUNCTION_CALL = exports.METRIC_INTENT_FAILED_FUNCTION_CALL = exports.METRIC_INTENT_FUNCTION_CALL = exports.METRIC_IDENTITY_CLIENT_SUCCESSFUL_FUNCTION_CALL = exports.METRIC_IDENTITY_CLIENT_FAILED_FUNCTION_CALL = exports.METRIC_IDENTITY_CLIENT_FUNCTION_CALL = exports.METRIC_MATRIX_CLIENT_SUCCESSFUL_FUNCTION_CALL = exports.METRIC_MATRIX_CLIENT_FAILED_FUNCTION_CALL = exports.METRIC_MATRIX_CLIENT_FUNCTION_CALL = void 0;
|
||||
/**
|
||||
* Time-series metric for how long a function call takes on MatrixClient. Uses a MatrixClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_MATRIX_CLIENT_FUNCTION_CALL = "matrix_client_function_call";
|
||||
/**
|
||||
* Counter metric for failed function calls on a MatrixClient. Uses a MatrixClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_MATRIX_CLIENT_FAILED_FUNCTION_CALL = "matrix_client_failed_function_call";
|
||||
/**
|
||||
* Counter metric for successful function calls on a MatrixClient. Uses a MatrixClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_MATRIX_CLIENT_SUCCESSFUL_FUNCTION_CALL = "matrix_client_successful_function_call";
|
||||
/**
|
||||
* Time-series metric for how long a function call takes on an IdentityClient. Uses an IdentityClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_IDENTITY_CLIENT_FUNCTION_CALL = "identity_client_function_call";
|
||||
/**
|
||||
* Counter metric for failed function calls on an IdentityClient. Uses an IdentityClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_IDENTITY_CLIENT_FAILED_FUNCTION_CALL = "identity_client_failed_function_call";
|
||||
/**
|
||||
* Counter metric for successful function calls on an IdentityClient. Uses an IdentityClientCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_IDENTITY_CLIENT_SUCCESSFUL_FUNCTION_CALL = "identity_client_successful_function_call";
|
||||
/**
|
||||
* Time-series metric for how long a function call takes on an Intent. Uses a IntentCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_INTENT_FUNCTION_CALL = "intent_function_call";
|
||||
/**
|
||||
* Counter metric for failed function calls on an Intent. Uses a IntentCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_INTENT_FAILED_FUNCTION_CALL = "intent_failed_function_call";
|
||||
/**
|
||||
* Counter metric for successful function calls on an Intent. Uses a IntentCallContext.
|
||||
* @category Metrics
|
||||
*/
|
||||
exports.METRIC_INTENT_SUCCESSFUL_FUNCTION_CALL = "intent_successful_function_call";
|
||||
//# sourceMappingURL=names.js.map
|
1
node_modules/matrix-bot-sdk/lib/metrics/names.js.map
generated
vendored
Normal file
1
node_modules/matrix-bot-sdk/lib/metrics/names.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/metrics/names.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AAEhF;;;GAGG;AACU,QAAA,yCAAyC,GAAG,oCAAoC,CAAC;AAE9F;;;GAGG;AACU,QAAA,6CAA6C,GAAG,wCAAwC,CAAC;AAEtG;;;GAGG;AACU,QAAA,oCAAoC,GAAG,+BAA+B,CAAC;AAEpF;;;GAGG;AACU,QAAA,2CAA2C,GAAG,sCAAsC,CAAC;AAElG;;;GAGG;AACU,QAAA,+CAA+C,GAAG,0CAA0C,CAAC;AAE1G;;;GAGG;AACU,QAAA,2BAA2B,GAAG,sBAAsB,CAAC;AAElE;;;GAGG;AACU,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AAEhF;;;GAGG;AACU,QAAA,sCAAsC,GAAG,iCAAiC,CAAC"}
|
Reference in New Issue
Block a user