Sélectionner une révision Git
dialog_styling_assistant.cpp
-
Thomas Goyne a rédigéThomas Goyne a rédigé
metrics.ts 8,03 Kio
/*
Copyright 2019 matrix-appservice-discord
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* eslint-disable max-classes-per-file, @typescript-eslint/no-empty-function */
import { Gauge, Counter, Histogram, collectDefaultMetrics, register } from "prom-client";
import { Log } from "./log";
import { Appservice,
IMetricContext,
METRIC_MATRIX_CLIENT_FAILED_FUNCTION_CALL,
METRIC_MATRIX_CLIENT_SUCCESSFUL_FUNCTION_CALL,
FunctionCallContext,
METRIC_MATRIX_CLIENT_FUNCTION_CALL} from "matrix-bot-sdk";
import { DiscordBridgeConfigMetrics } from "./config";
import * as http from "http";
const log = new Log("BridgeMetrics");
const REQUEST_EXPIRE_TIME_MS = 30000;
export interface IBridgeMetrics {
registerRequest(id: string);
requestOutcome(id: string, isRemote: boolean, outcome: string);
remoteCall(method: string);
setPresenceCount(count: number);
storeCall(method: string, cached: boolean);
setRemoteMonthlyActiveUsers(rmau: number);
setBridgeBlocked(isBlocked: boolean);
}
export class DummyBridgeMetrics implements IBridgeMetrics {
public registerRequest() {}
public requestOutcome() {}
public remoteCall() {}
public setPresenceCount() {}
public storeCall() {}
public setRemoteMonthlyActiveUsers() {}
public setBridgeBlocked() {}
}
export class MetricPeg {
public static get get(): IBridgeMetrics {
return this.metrics;
}
public static set(metrics: IBridgeMetrics) {
this.metrics = metrics;
}
private static metrics: IBridgeMetrics = new DummyBridgeMetrics();
}
export class PrometheusBridgeMetrics implements IBridgeMetrics {
private matrixCallCounter: Counter<string>;
private remoteCallCounter: Counter<string>;
private storeCallCounter: Counter<string>;
private presenceGauge: Gauge<string>;
private remoteRequest: Histogram<string>;
private matrixRequest: Histogram<string>;