@devopsplaybook.io/otel-utils 1.0.1-beta5 → 1.0.1-beta7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./src/models/ConfigOTelInterface";
2
+ export * from "./src/models/StandardLoggerInterface";
2
3
  export * from "./src/ModuleLogger";
3
4
  export * from "./src/StandardLogger";
4
5
  export * from "./src/StandardMeter";
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./src/models/ConfigOTelInterface"), exports);
18
+ __exportStar(require("./src/models/StandardLoggerInterface"), exports);
18
19
  __exportStar(require("./src/ModuleLogger"), exports);
19
20
  __exportStar(require("./src/StandardLogger"), exports);
20
21
  __exportStar(require("./src/StandardMeter"), exports);
@@ -1,8 +1,8 @@
1
- import type { Logger } from "@opentelemetry/api-logs";
1
+ import { StandardLoggerInterface } from "./models/StandardLoggerInterface";
2
2
  export declare class ModuleLogger {
3
3
  private module;
4
- private logger?;
5
- constructor(module: string, logger?: Logger);
4
+ private standardLogger?;
5
+ constructor(module: string, standardLogger: StandardLoggerInterface);
6
6
  info(message: Error | string | any): void;
7
7
  warn(message: Error | string | any): void;
8
8
  error(message: Error | string | any): void;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModuleLogger = void 0;
4
4
  const api_logs_1 = require("@opentelemetry/api-logs");
5
5
  class ModuleLogger {
6
- constructor(module, logger) {
6
+ constructor(module, standardLogger) {
7
7
  this.module = module;
8
- this.logger = logger;
8
+ this.standardLogger = standardLogger;
9
9
  }
10
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
11
  info(message) {
@@ -22,6 +22,7 @@ class ModuleLogger {
22
22
  display(level,
23
23
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
24
  message, severityNumber = api_logs_1.SeverityNumber.INFO) {
25
+ var _a, _b;
25
26
  if (typeof message === "string") {
26
27
  // eslint:disable-next-line:no-console
27
28
  console.log(`[${level}] [${this.module}] ${message}`);
@@ -36,10 +37,10 @@ class ModuleLogger {
36
37
  // eslint:disable-next-line:no-console
37
38
  console.log(`${level} [${this.module}] ${JSON.stringify(message)}`);
38
39
  }
39
- if (!this.logger) {
40
+ if (!((_a = this.standardLogger) === null || _a === void 0 ? void 0 : _a.getLogger())) {
40
41
  return;
41
42
  }
42
- this.logger.emit({
43
+ (_b = this.standardLogger.getLogger()) === null || _b === void 0 ? void 0 : _b.emit({
43
44
  severityNumber,
44
45
  severityText: level,
45
46
  body: message,
@@ -1,9 +1,11 @@
1
+ import type { Logger as OTelLogger } from "@opentelemetry/api-logs";
1
2
  import { ConfigOTelInterface } from "./models/ConfigOTelInterface";
2
3
  import { ModuleLogger } from "./ModuleLogger";
3
4
  export declare class StandardLogger {
4
5
  private logger?;
5
- private serviceVersion;
6
- private serviceName;
7
- constructor(config: ConfigOTelInterface);
6
+ private serviceVersion?;
7
+ private serviceName?;
8
+ initOTel(config: ConfigOTelInterface): void;
9
+ getLogger(): OTelLogger | undefined;
8
10
  createModuleLogger(moduleName: string): ModuleLogger;
9
11
  }
@@ -41,7 +41,7 @@ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
41
41
  const os = __importStar(require("os"));
42
42
  const ModuleLogger_1 = require("./ModuleLogger");
43
43
  class StandardLogger {
44
- constructor(config) {
44
+ initOTel(config) {
45
45
  this.serviceName = config.SERVICE_ID;
46
46
  this.serviceVersion = config.VERSION;
47
47
  if (config.OPENTELEMETRY_COLLECTOR_HTTP_LOGS) {
@@ -70,8 +70,11 @@ class StandardLogger {
70
70
  this.logger = loggerProvider.getLogger(`${this.serviceName}:${this.serviceVersion}`);
71
71
  }
72
72
  }
73
+ getLogger() {
74
+ return this.logger;
75
+ }
73
76
  createModuleLogger(moduleName) {
74
- return new ModuleLogger_1.ModuleLogger(moduleName, this.logger);
77
+ return new ModuleLogger_1.ModuleLogger(moduleName, this);
75
78
  }
76
79
  }
77
80
  exports.StandardLogger = StandardLogger;
@@ -0,0 +1,4 @@
1
+ import type { Logger } from "@opentelemetry/api-logs";
2
+ export interface StandardLoggerInterface {
3
+ getLogger(): Logger | undefined;
4
+ }
package/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./src/models/ConfigOTelInterface";
2
+ export * from "./src/models/StandardLoggerInterface";
2
3
  export * from "./src/ModuleLogger";
3
4
  export * from "./src/StandardLogger";
4
5
  export * from "./src/StandardMeter";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devopsplaybook.io/otel-utils",
3
- "version": "1.0.1-beta5",
3
+ "version": "1.0.1-beta7",
4
4
  "description": "Utility to simplify integration with Open Telemetry",
5
5
  "keywords": [
6
6
  "Open",
@@ -1,13 +1,13 @@
1
- import type { Logger } from "@opentelemetry/api-logs";
2
1
  import { SeverityNumber } from "@opentelemetry/api-logs";
2
+ import { StandardLoggerInterface } from "./models/StandardLoggerInterface";
3
3
 
4
4
  export class ModuleLogger {
5
5
  private module: string;
6
- private logger?: Logger;
6
+ private standardLogger?: StandardLoggerInterface;
7
7
 
8
- constructor(module: string, logger?: Logger) {
8
+ constructor(module: string, standardLogger: StandardLoggerInterface) {
9
9
  this.module = module;
10
- this.logger = logger;
10
+ this.standardLogger = standardLogger;
11
11
  }
12
12
 
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -41,10 +41,10 @@ export class ModuleLogger {
41
41
  // eslint:disable-next-line:no-console
42
42
  console.log(`${level} [${this.module}] ${JSON.stringify(message)}`);
43
43
  }
44
- if (!this.logger) {
44
+ if (!this.standardLogger?.getLogger()) {
45
45
  return;
46
46
  }
47
- this.logger.emit({
47
+ this.standardLogger.getLogger()?.emit({
48
48
  severityNumber,
49
49
  severityText: level,
50
50
  body: message,
@@ -1,12 +1,10 @@
1
1
  import type { Logger, Logger as OTelLogger } from "@opentelemetry/api-logs";
2
- import { SeverityNumber } from "@opentelemetry/api-logs";
3
2
  import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
4
3
  import { resourceFromAttributes } from "@opentelemetry/resources";
5
4
  import {
6
5
  BatchLogRecordProcessor,
7
6
  LoggerProvider,
8
7
  } from "@opentelemetry/sdk-logs";
9
- import { Span } from "@opentelemetry/sdk-trace-base";
10
8
  import {
11
9
  ATTR_NETWORK_LOCAL_ADDRESS,
12
10
  ATTR_SERVICE_NAME,
@@ -18,10 +16,10 @@ import { ModuleLogger } from "./ModuleLogger";
18
16
 
19
17
  export class StandardLogger {
20
18
  private logger?: Logger;
21
- private serviceVersion: string;
22
- private serviceName: string;
19
+ private serviceVersion?: string;
20
+ private serviceName?: string;
23
21
 
24
- constructor(config: ConfigOTelInterface) {
22
+ public initOTel(config: ConfigOTelInterface) {
25
23
  this.serviceName = config.SERVICE_ID;
26
24
  this.serviceVersion = config.VERSION;
27
25
 
@@ -59,7 +57,11 @@ export class StandardLogger {
59
57
  }
60
58
  }
61
59
 
60
+ public getLogger(): OTelLogger | undefined {
61
+ return this.logger;
62
+ }
63
+
62
64
  public createModuleLogger(moduleName: string): ModuleLogger {
63
- return new ModuleLogger(moduleName, this.logger);
65
+ return new ModuleLogger(moduleName, this);
64
66
  }
65
67
  }
@@ -0,0 +1,5 @@
1
+ import type { Logger } from "@opentelemetry/api-logs";
2
+
3
+ export interface StandardLoggerInterface {
4
+ getLogger(): Logger | undefined;
5
+ }
@@ -1,12 +0,0 @@
1
- import { Span } from "@opentelemetry/sdk-trace-base";
2
- import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
3
- export declare function LoggerInit(context: Span, config: ConfigInterfaceOTel): void;
4
- export declare class Logger {
5
- private module;
6
- constructor(module: string);
7
- debug(message: Error | string | any): void;
8
- info(message: Error | string | any): void;
9
- warn(message: Error | string | any): void;
10
- error(message: Error | string | any): void;
11
- private display;
12
- }
@@ -1,131 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Logger = void 0;
37
- exports.LoggerInit = LoggerInit;
38
- const api_logs_1 = require("@opentelemetry/api-logs");
39
- const exporter_logs_otlp_http_1 = require("@opentelemetry/exporter-logs-otlp-http");
40
- const resources_1 = require("@opentelemetry/resources");
41
- const sdk_logs_1 = require("@opentelemetry/sdk-logs");
42
- const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
43
- const os = __importStar(require("os"));
44
- const StandardTracer_1 = require("./StandardTracer");
45
- let loggerOTel;
46
- function LoggerInit(context, config) {
47
- const span = (0, StandardTracer_1.StandardTracerStartSpan)("LoggerInit", context);
48
- if (config.OPENTELEMETRY_COLLECTOR_HTTP_LOGS) {
49
- const exporterHeaders = {};
50
- if (config.OPENTELEMETRY_COLLECT_AUTHORIZATION_HEADER) {
51
- exporterHeaders["Authorization"] = `Bearer ${config.OPENTELEMETRY_COLLECT_AUTHORIZATION_HEADER}`;
52
- }
53
- const exporter = new exporter_logs_otlp_http_1.OTLPLogExporter({
54
- url: config.OPENTELEMETRY_COLLECTOR_HTTP_LOGS,
55
- headers: exporterHeaders,
56
- });
57
- const loggerProvider = new sdk_logs_1.LoggerProvider({
58
- processors: [
59
- new sdk_logs_1.BatchLogRecordProcessor(exporter, {
60
- maxQueueSize: 100,
61
- scheduledDelayMillis: config.OPENTELEMETRY_COLLECTOR_EXPORT_LOGS_INTERVAL_SECONDS * 1000,
62
- }),
63
- ],
64
- resource: (0, resources_1.resourceFromAttributes)({
65
- [semantic_conventions_1.ATTR_SERVICE_NAME]: `${config.SERVICE_ID}`,
66
- [semantic_conventions_1.ATTR_SERVICE_VERSION]: `${config.VERSION}`,
67
- [semantic_conventions_1.ATTR_NETWORK_LOCAL_ADDRESS]: os.hostname(),
68
- }),
69
- });
70
- loggerOTel = loggerProvider.getLogger(`${config.SERVICE_ID}:${config.VERSION}`);
71
- }
72
- span.end();
73
- }
74
- const DEV_MODE = (() => {
75
- if (process.env.NODE_ENV === "dev") {
76
- return true;
77
- }
78
- return false;
79
- })();
80
- class Logger {
81
- constructor(module) {
82
- this.module = `${module}`;
83
- }
84
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
- debug(message) {
86
- if (DEV_MODE) {
87
- this.display("debug", message, api_logs_1.SeverityNumber.DEBUG);
88
- }
89
- }
90
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
- info(message) {
92
- this.display("info", message, api_logs_1.SeverityNumber.WARN);
93
- }
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
- warn(message) {
96
- this.display("warn", message, api_logs_1.SeverityNumber.WARN);
97
- }
98
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
- error(message) {
100
- this.display("error", message, api_logs_1.SeverityNumber.ERROR);
101
- }
102
- display(level,
103
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
- message, severityNumber = api_logs_1.SeverityNumber.INFO) {
105
- if (typeof message === "string") {
106
- // eslint:disable-next-line:no-console
107
- console.log(`[${level}] [${this.module}] ${message}`);
108
- }
109
- else if (message instanceof Error) {
110
- // eslint:disable-next-line:no-console
111
- console.log(`${level} [${this.module}] ${message}`);
112
- // eslint:disable-next-line:no-console
113
- console.log(message.stack);
114
- }
115
- else if (typeof message === "object") {
116
- // eslint:disable-next-line:no-console
117
- console.log(`${level} [${this.module}] ${JSON.stringify(message)}`);
118
- }
119
- if (loggerOTel) {
120
- {
121
- loggerOTel.emit({
122
- severityNumber,
123
- severityText: level,
124
- body: message,
125
- attributes: { "log.type": "custom" },
126
- });
127
- }
128
- }
129
- }
130
- }
131
- exports.Logger = Logger;
@@ -1,9 +0,0 @@
1
- export declare class PromisePool {
2
- private maxConcurrency;
3
- private currentConcurrency;
4
- private queue;
5
- private timeout;
6
- constructor(maxConcurrency: any, timeout?: number);
7
- add(promiseGenerator: any): Promise<unknown>;
8
- private runNext;
9
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PromisePool = void 0;
4
- class PromisePool {
5
- constructor(maxConcurrency, timeout = 3600000) {
6
- this.maxConcurrency = maxConcurrency;
7
- this.currentConcurrency = 0;
8
- this.queue = [];
9
- this.timeout = timeout;
10
- }
11
- add(promiseGenerator) {
12
- return new Promise((resolve, reject) => {
13
- const controller = new AbortController();
14
- const signal = controller.signal;
15
- const wrappedPromise = () => {
16
- return new Promise((innerResolve, innerReject) => {
17
- const timeoutId = setTimeout(() => {
18
- controller.abort();
19
- innerReject(new Error("Promise cancelled due to timeout"));
20
- }, this.timeout);
21
- promiseGenerator(signal)
22
- .then((result) => {
23
- clearTimeout(timeoutId);
24
- innerResolve(result);
25
- })
26
- .catch((error) => {
27
- clearTimeout(timeoutId);
28
- innerReject(error);
29
- });
30
- });
31
- };
32
- this.queue.push({ wrappedPromise, resolve, reject });
33
- this.runNext();
34
- });
35
- }
36
- runNext() {
37
- if (this.currentConcurrency < this.maxConcurrency && this.queue.length > 0) {
38
- const { wrappedPromise, resolve, reject } = this.queue.shift();
39
- this.currentConcurrency++;
40
- wrappedPromise()
41
- .then((result) => {
42
- resolve(result);
43
- this.currentConcurrency--;
44
- this.runNext();
45
- })
46
- .catch((error) => {
47
- reject(error);
48
- this.currentConcurrency--;
49
- this.runNext();
50
- });
51
- }
52
- }
53
- }
54
- exports.PromisePool = PromisePool;
@@ -1,7 +0,0 @@
1
- import { Config } from "../Config";
2
- import { Span } from "@opentelemetry/sdk-trace-base";
3
- export declare function SqlDbUtilsInit(context: Span, config: Config): Promise<void>;
4
- export declare function SqlDbUtilsInitGetDatabase(): any;
5
- export declare function SqlDbUtilsExecSQL(context: Span, sql: string, params?: never[]): Promise<number>;
6
- export declare function SqlDbUtilsExecSQLFile(context: Span, filename: string): Promise<void>;
7
- export declare function SqlDbUtilsQuerySQL(context: Span, sql: string, params?: never[], debug?: boolean): Promise<any[]>;
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SqlDbUtilsInit = SqlDbUtilsInit;
37
- exports.SqlDbUtilsInitGetDatabase = SqlDbUtilsInitGetDatabase;
38
- exports.SqlDbUtilsExecSQL = SqlDbUtilsExecSQL;
39
- exports.SqlDbUtilsExecSQLFile = SqlDbUtilsExecSQLFile;
40
- exports.SqlDbUtilsQuerySQL = SqlDbUtilsQuerySQL;
41
- const sqlite3_1 = require("sqlite3");
42
- const fs = __importStar(require("fs-extra"));
43
- const Logger_1 = require("./Logger");
44
- const api_1 = require("@opentelemetry/api");
45
- const StandardTracer_1 = require("./StandardTracer");
46
- const logger = new Logger_1.Logger("SqlDbutils");
47
- const SQL_DIR = `${__dirname}/../../sql`;
48
- let database;
49
- async function SqlDbUtilsInit(context, config) {
50
- const span = (0, StandardTracer_1.StandardTracerStartSpan)("SqlDbUtilsInit", context);
51
- await fs.ensureDir(config.DATA_DIR);
52
- database = new sqlite3_1.Database(`${config.DATA_DIR}/database.db`);
53
- await SqlDbUtilsExecSQLFile(span, `${SQL_DIR}/init-0000.sql`);
54
- const initFiles = (await await fs.readdir(`${SQL_DIR}`)).sort();
55
- let dbVersionApplied = 0;
56
- const dbVersionQuery = await SqlDbUtilsQuerySQL(span, "SELECT MAX(value) as maxVerion FROM metadata WHERE type='db_version'");
57
- if (dbVersionQuery[0].maxVerion) {
58
- dbVersionApplied = Number(dbVersionQuery[0].maxVerion);
59
- }
60
- logger.info(`Current DB Version: ${dbVersionApplied}`);
61
- for (const initFile of initFiles) {
62
- const regex = /init-(\d+).sql/g;
63
- const match = regex.exec(initFile);
64
- if (match) {
65
- const dbVersionInitFile = Number(match[1]);
66
- if (dbVersionInitFile > dbVersionApplied) {
67
- logger.info(`Loading init file: ${initFile}`);
68
- await SqlDbUtilsExecSQLFile(span, `${SQL_DIR}/${initFile}`);
69
- await SqlDbUtilsQuerySQL(span, 'INSERT INTO metadata (type, value, dateCreated) VALUES ("db_version",?,?)', [dbVersionInitFile, new Date().toISOString()]);
70
- }
71
- }
72
- }
73
- span.end();
74
- }
75
- function SqlDbUtilsInitGetDatabase() {
76
- return database;
77
- }
78
- function SqlDbUtilsExecSQL(context, sql, params = []) {
79
- const span = (0, StandardTracer_1.StandardTracerStartSpan)("SqlDbUtilsExecSQL", context);
80
- return new Promise((resolve, reject) => {
81
- database.run(sql, params, function (error) {
82
- if (error) {
83
- span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error.message });
84
- span.end();
85
- reject(error);
86
- }
87
- else {
88
- span.addEvent(`Impacted Rows: ${this.changes}`);
89
- span.end();
90
- resolve(this.changes);
91
- }
92
- });
93
- });
94
- }
95
- async function SqlDbUtilsExecSQLFile(context, filename) {
96
- const span = (0, StandardTracer_1.StandardTracerStartSpan)("SqlDbUtilsExecSQLFile", context);
97
- const sql = (await fs.readFile(filename)).toString();
98
- return new Promise((resolve, reject) => {
99
- database.exec(sql, (error) => {
100
- if (error) {
101
- span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error.message });
102
- span.end();
103
- reject(error);
104
- }
105
- else {
106
- span.end();
107
- resolve();
108
- }
109
- });
110
- });
111
- }
112
- function SqlDbUtilsQuerySQL(context, sql, params = [], debug = false
113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
- ) {
115
- const span = (0, StandardTracer_1.StandardTracerStartSpan)("SqlDbUtilsQuerySQL", context);
116
- if (debug) {
117
- console.log(sql);
118
- }
119
- return new Promise((resolve, reject) => {
120
- database.all(sql, params, (error, rows) => {
121
- if (error) {
122
- span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error.message });
123
- span.end();
124
- reject(error);
125
- }
126
- else {
127
- span.end();
128
- resolve(rows);
129
- }
130
- });
131
- });
132
- }
@@ -1,2 +0,0 @@
1
- export declare function SqlDbUtilsNoTelemetryExecSQL(sql: string, params?: never[]): Promise<void>;
2
- export declare function SqlDbUtilsNoTelemetryQuerySQL(sql: string, params?: never[], debug?: boolean): Promise<any[]>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SqlDbUtilsNoTelemetryExecSQL = SqlDbUtilsNoTelemetryExecSQL;
4
- exports.SqlDbUtilsNoTelemetryQuerySQL = SqlDbUtilsNoTelemetryQuerySQL;
5
- const Logger_1 = require("./Logger");
6
- const SqlDbUtils_1 = require("./SqlDbUtils");
7
- const logger = new Logger_1.Logger("SqlDbUtilsNoTelemetry");
8
- function SqlDbUtilsNoTelemetryExecSQL(sql, params = []) {
9
- return new Promise((resolve, reject) => {
10
- (0, SqlDbUtils_1.SqlDbUtilsInitGetDatabase)().run(sql, params, (error) => {
11
- if (error) {
12
- reject(error);
13
- }
14
- else {
15
- resolve();
16
- }
17
- });
18
- });
19
- }
20
- function SqlDbUtilsNoTelemetryQuerySQL(sql, params = [], debug = false
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- ) {
23
- if (debug) {
24
- console.log(sql);
25
- }
26
- return new Promise((resolve, reject) => {
27
- (0, SqlDbUtils_1.SqlDbUtilsInitGetDatabase)().all(sql, params, (error, rows) => {
28
- if (error) {
29
- console.log(error);
30
- logger.error(`SQL ERROR: ${sql}`);
31
- reject(error);
32
- }
33
- else {
34
- resolve(rows);
35
- }
36
- });
37
- });
38
- }
@@ -1 +0,0 @@
1
- export declare function SystemCommandExecute(command: string, options?: {}): Promise<string>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SystemCommandExecute = SystemCommandExecute;
37
- const childProcess = __importStar(require("child_process"));
38
- function SystemCommandExecute(command, options = {}) {
39
- const exec = childProcess.exec;
40
- return new Promise((resolve, reject) => {
41
- exec(command, options, (error, stdout) => {
42
- if (error) {
43
- reject(error);
44
- }
45
- else {
46
- resolve(stdout);
47
- }
48
- });
49
- });
50
- }
@@ -1 +0,0 @@
1
- export declare function TimeoutWait(duration: number): Promise<void>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimeoutWait = TimeoutWait;
4
- function TimeoutWait(duration) {
5
- return new Promise((resolve) => {
6
- setTimeout(() => {
7
- resolve();
8
- }, duration);
9
- });
10
- }
@@ -1,11 +0,0 @@
1
- export interface ConfigInterface {
2
- SERVICE_ID: string;
3
- VERSION: number;
4
- OPENTELEMETRY_COLLECTOR_HTTP_TRACES: string;
5
- OPENTELEMETRY_COLLECTOR_HTTP_METRICS: string;
6
- OPENTELEMETRY_COLLECTOR_HTTP_LOGS: string;
7
- OPENTELEMETRY_COLLECTOR_EXPORT_LOGS_INTERVAL_SECONDS: number;
8
- OPENTELEMETRY_COLLECTOR_EXPORT_METRICS_INTERVAL_SECONDS: number;
9
- OPENTELEMETRY_COLLECTOR_AWS: boolean;
10
- OPENTELEMETRY_COLLECT_AUTHORIZATION_HEADER: string;
11
- }
@@ -1,11 +0,0 @@
1
- export interface ConfigInterfaceOTel {
2
- SERVICE_ID: string;
3
- VERSION: number;
4
- OPENTELEMETRY_COLLECTOR_HTTP_TRACES: string;
5
- OPENTELEMETRY_COLLECTOR_HTTP_METRICS: string;
6
- OPENTELEMETRY_COLLECTOR_HTTP_LOGS: string;
7
- OPENTELEMETRY_COLLECTOR_EXPORT_LOGS_INTERVAL_SECONDS: number;
8
- OPENTELEMETRY_COLLECTOR_EXPORT_METRICS_INTERVAL_SECONDS: number;
9
- OPENTELEMETRY_COLLECTOR_AWS: boolean;
10
- OPENTELEMETRY_COLLECT_AUTHORIZATION_HEADER: string;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });