Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-protocol/src/util/logging-node.ts
2500 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import * as prometheusClient from "prom-client";
8
import { LogHook } from "./logging";
9
10
const logsCounter = new prometheusClient.Counter({
11
name: "gitpod_logs_total",
12
help: "Total number of logs by level",
13
labelNames: ["level"],
14
registers: [prometheusClient.register],
15
});
16
17
export function reportLogCount(level: string) {
18
logsCounter.inc({ level });
19
}
20
21
export function installLogCountMetric() {
22
LogHook.setHook((item) => {
23
reportLogCount((item.severity || "").toLowerCase());
24
});
25
}
26
27