@devopsplaybook.io/otel-utils 1.0.16 → 1.0.17-beta.17.7fb8dd0
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 +6 -0
- package/dist/index.js +22 -0
- package/dist/src/ModuleLogger.d.ts +11 -0
- package/dist/{ModuleLogger.js → src/ModuleLogger.js} +3 -2
- package/dist/src/StandardLogger.d.ts +11 -0
- package/dist/src/StandardMeter.d.ts +12 -0
- package/dist/src/StandardTracer.d.ts +10 -0
- package/dist/src/models/ConfigOTelInterface.d.ts +11 -0
- package/dist/src/models/StandardLoggerInterface.d.ts +4 -0
- package/package.json +1 -1
- package/tsconfig.json +6 -12
- /package/dist/{StandardLogger.js → src/StandardLogger.js} +0 -0
- /package/dist/{StandardMeter.js → src/StandardMeter.js} +0 -0
- /package/dist/{StandardTracer.js → src/StandardTracer.js} +0 -0
- /package/dist/{models → src/models}/ConfigOTelInterface.js +0 -0
- /package/dist/{models → src/models}/StandardLoggerInterface.js +0 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/models/ConfigOTelInterface"), exports);
|
|
18
|
+
__exportStar(require("./src/models/StandardLoggerInterface"), exports);
|
|
19
|
+
__exportStar(require("./src/ModuleLogger"), exports);
|
|
20
|
+
__exportStar(require("./src/StandardLogger"), exports);
|
|
21
|
+
__exportStar(require("./src/StandardMeter"), exports);
|
|
22
|
+
__exportStar(require("./src/StandardTracer"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StandardLoggerInterface } from "./models/StandardLoggerInterface";
|
|
2
|
+
import { Span } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
export declare class ModuleLogger {
|
|
4
|
+
private module;
|
|
5
|
+
private standardLogger?;
|
|
6
|
+
constructor(module: string, standardLogger: StandardLoggerInterface);
|
|
7
|
+
info(message: string, context?: Span): void;
|
|
8
|
+
warn(message: string, context?: Span): void;
|
|
9
|
+
error(message: string, error?: Error, context?: Span): void;
|
|
10
|
+
private display;
|
|
11
|
+
}
|
|
@@ -17,6 +17,7 @@ class ModuleLogger {
|
|
|
17
17
|
this.display("error", message, api_logs_1.SeverityNumber.ERROR, error, context);
|
|
18
18
|
}
|
|
19
19
|
display(level, message, severityNumber = api_logs_1.SeverityNumber.INFO, error, context) {
|
|
20
|
+
var _a, _b;
|
|
20
21
|
let formattedMessage = message;
|
|
21
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
23
|
const attributes = { "log.type": "custom" };
|
|
@@ -35,10 +36,10 @@ class ModuleLogger {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
console.log(`[${level}] [${this.module}] ${formattedMessage}`);
|
|
38
|
-
if (!this.standardLogger
|
|
39
|
+
if (!((_a = this.standardLogger) === null || _a === void 0 ? void 0 : _a.getLogger())) {
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
this.standardLogger.getLogger()
|
|
42
|
+
(_b = this.standardLogger.getLogger()) === null || _b === void 0 ? void 0 : _b.emit({
|
|
42
43
|
severityNumber,
|
|
43
44
|
severityText: level,
|
|
44
45
|
body: `[${this.module}] ${formattedMessage}`,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Logger as OTelLogger } from "@opentelemetry/api-logs";
|
|
2
|
+
import { ConfigOTelInterface } from "./models/ConfigOTelInterface";
|
|
3
|
+
import { ModuleLogger } from "./ModuleLogger";
|
|
4
|
+
export declare class StandardLogger {
|
|
5
|
+
private logger?;
|
|
6
|
+
private serviceVersion?;
|
|
7
|
+
private serviceName?;
|
|
8
|
+
initOTel(config: ConfigOTelInterface): void;
|
|
9
|
+
getLogger(): OTelLogger | undefined;
|
|
10
|
+
createModuleLogger(moduleName: string): ModuleLogger;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Counter, Histogram, ObservableGauge } from "@opentelemetry/api";
|
|
2
|
+
import { ConfigOTelInterface } from "./models/ConfigOTelInterface";
|
|
3
|
+
export declare class StandardMeter {
|
|
4
|
+
private meter;
|
|
5
|
+
private serviceVersion;
|
|
6
|
+
private serviceName;
|
|
7
|
+
constructor(config: ConfigOTelInterface);
|
|
8
|
+
createCounter(key: string): Counter;
|
|
9
|
+
createUpDownCounter(key: string): Counter;
|
|
10
|
+
createHistogram(key: string): Histogram;
|
|
11
|
+
createObservableGauge(key: string, callback: (observableResult: any) => void, description?: any): ObservableGauge;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Span } from "@opentelemetry/sdk-trace-base";
|
|
2
|
+
import { ConfigOTelInterface } from "./models/ConfigOTelInterface";
|
|
3
|
+
export declare class StandardTracer {
|
|
4
|
+
private tracer;
|
|
5
|
+
private serviceVersion;
|
|
6
|
+
private serviceName;
|
|
7
|
+
constructor(config: ConfigOTelInterface);
|
|
8
|
+
startSpan(name: string, parentSpan?: Span): Span;
|
|
9
|
+
static updateHttpHeader(context: Span, headers?: {}): any;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ConfigOTelInterface {
|
|
2
|
+
SERVICE_ID: string;
|
|
3
|
+
VERSION: string;
|
|
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
|
+
}
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2019",
|
|
4
4
|
"module": "commonjs",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"allowJs": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
9
8
|
"esModuleInterop": true,
|
|
10
9
|
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true
|
|
12
|
-
"strict": false,
|
|
13
|
-
"noImplicitAny": false,
|
|
14
|
-
"strictPropertyInitialization": false,
|
|
15
|
-
"strictNullChecks": false
|
|
10
|
+
"forceConsistentCasingInFileNames": true
|
|
16
11
|
},
|
|
17
|
-
"include": ["src/**/*"]
|
|
18
|
-
"exclude": ["node_modules", "coverage", "test", "dist", "src/**/*.spec.ts"]
|
|
12
|
+
"include": ["index.ts", "src/**/*"]
|
|
19
13
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|