Skip to content
Snippets Groups Projects
Commit 419cb6a5 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] pilot Monitoring annotations using constants

parent 31b62d6a
No related branches found
No related tags found
No related merge requests found
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
import {NewLogger} from "../logger" import {NewLogger} from "../logger"
import {getMicrosecondsTime} from "../../ProcessCpuProfiler" import {getMicrosecondsTime} from "../../ProcessCpuProfiler"
import {OtherConstants} from "../other_constants"
const theLogger = NewLogger() const theLogger = NewLogger()
export const MonitorLokiExecutionTime = function (dumpFirstParam = false) { export const MonitorLokiExecutionTime = function (dumpFirstParam = false) {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
if (OtherConstants.ENABLE_LOKI_MONITORING) {
const original = descriptor.value const original = descriptor.value
if (original.__proto__.constructor.name === "AsyncFunction") { if (original.__proto__.constructor.name === "AsyncFunction") {
descriptor.value = async function (...args:any[]) { descriptor.value = async function (...args:any[]) {
...@@ -36,3 +38,4 @@ export const MonitorLokiExecutionTime = function (dumpFirstParam = false) { ...@@ -36,3 +38,4 @@ export const MonitorLokiExecutionTime = function (dumpFirstParam = false) {
} }
} }
} }
}
\ No newline at end of file
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
import {getDurationInMicroSeconds, getMicrosecondsTime} from "../../ProcessCpuProfiler" import {getDurationInMicroSeconds, getMicrosecondsTime} from "../../ProcessCpuProfiler"
import {NewLogger} from "../logger" import {NewLogger} from "../logger"
import {OtherConstants} from "../other_constants"
const theLogger = NewLogger() const theLogger = NewLogger()
export const MonitorSQLExecutionTime = function () { export const MonitorSQLExecutionTime = function () {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
if (OtherConstants.ENABLE_SQL_MONITORING) {
const original = descriptor.value const original = descriptor.value
if (original.__proto__.constructor.name === "AsyncFunction") { if (original.__proto__.constructor.name === "AsyncFunction") {
descriptor.value = async function (...args: any[]) { descriptor.value = async function (...args: any[]) {
...@@ -34,3 +36,4 @@ export const MonitorSQLExecutionTime = function () { ...@@ -34,3 +36,4 @@ export const MonitorSQLExecutionTime = function () {
} }
} }
} }
}
\ No newline at end of file
...@@ -20,5 +20,8 @@ export const OtherConstants = { ...@@ -20,5 +20,8 @@ export const OtherConstants = {
SWITCHED: 'switched', SWITCHED: 'switched',
HEAD_CHANGED: 'newHEAD', HEAD_CHANGED: 'newHEAD',
RESOLUTION_DONE: 'resolution_done' RESOLUTION_DONE: 'resolution_done'
} },
ENABLE_LOKI_MONITORING: false,
ENABLE_SQL_MONITORING: false,
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment