@devopsplaybook.io/otel-utils 1.0.1-beta1 → 1.0.1-beta3
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 +1 -1
- package/dist/index.js +1 -24
- package/dist/src/Logger.d.ts +2 -2
- package/dist/src/StandardMeter.d.ts +2 -2
- package/dist/src/StandardTracer.d.ts +2 -3
- package/dist/src/StandardTracer.js +0 -6
- package/dist/src/models/ConfigInterfaceOTel.d.ts +11 -0
- package/dist/src/models/ConfigInterfaceOTel.js +2 -0
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/Logger.ts +2 -2
- package/src/StandardMeter.ts +3 -3
- package/src/StandardTracer.ts +3 -9
- package/src/models/{ConfigInterface.ts → ConfigInterfaceOTel.ts} +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,34 +12,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
12
12
|
if (k2 === undefined) k2 = k;
|
|
13
13
|
o[k2] = m[k];
|
|
14
14
|
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
15
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
17
|
};
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.models = void 0;
|
|
42
19
|
__exportStar(require("./src/Logger"), exports);
|
|
43
20
|
__exportStar(require("./src/StandardMeter"), exports);
|
|
44
21
|
__exportStar(require("./src/StandardTracer"), exports);
|
|
45
|
-
|
|
22
|
+
__exportStar(require("./src/models/ConfigInterfaceOTel"), exports);
|
package/dist/src/Logger.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Span } from "@opentelemetry/sdk-trace-base";
|
|
2
|
-
import {
|
|
3
|
-
export declare function LoggerInit(context: Span, config:
|
|
2
|
+
import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
|
|
3
|
+
export declare function LoggerInit(context: Span, config: ConfigInterfaceOTel): void;
|
|
4
4
|
export declare class Logger {
|
|
5
5
|
private module;
|
|
6
6
|
constructor(module: string);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Counter, Histogram, ObservableGauge } from "@opentelemetry/api";
|
|
2
|
-
import {
|
|
3
|
-
export declare function StandardMeterInitTelemetry(initConfig:
|
|
2
|
+
import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
|
|
3
|
+
export declare function StandardMeterInitTelemetry(initConfig: ConfigInterfaceOTel): void;
|
|
4
4
|
export declare function StandardMeterCreateCounter(key: string): Counter;
|
|
5
5
|
export declare function StandardMeterCreateUpDownCounter(key: string): Counter;
|
|
6
6
|
export declare function StandardMeterCreateHistorgram(key: string): Histogram;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Span } from "@opentelemetry/sdk-trace-base";
|
|
2
|
-
import {
|
|
3
|
-
export declare function StandardTracerInitTelemetry(initConfig:
|
|
4
|
-
export declare function StandardTracerGetSpanFromRequest(req: any): Span;
|
|
2
|
+
import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
|
|
3
|
+
export declare function StandardTracerInitTelemetry(initConfig: ConfigInterfaceOTel): void;
|
|
5
4
|
export declare function StandardTracerStartSpan(name: string, parentSpan?: Span): Span;
|
|
6
5
|
export declare function StandardTracerGetTracer(): any;
|
|
7
6
|
export declare function StandardTracerAppendHeader(context: Span, headers?: {}): any;
|
|
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.StandardTracerInitTelemetry = StandardTracerInitTelemetry;
|
|
37
|
-
exports.StandardTracerGetSpanFromRequest = StandardTracerGetSpanFromRequest;
|
|
38
37
|
exports.StandardTracerStartSpan = StandardTracerStartSpan;
|
|
39
38
|
exports.StandardTracerGetTracer = StandardTracerGetTracer;
|
|
40
39
|
exports.StandardTracerAppendHeader = StandardTracerAppendHeader;
|
|
@@ -80,11 +79,6 @@ function StandardTracerInitTelemetry(initConfig) {
|
|
|
80
79
|
contextManager.enable();
|
|
81
80
|
api_1.default.context.setGlobalContextManager(contextManager);
|
|
82
81
|
}
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
function StandardTracerGetSpanFromRequest(req) {
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
return req.tracerSpanApi;
|
|
87
|
-
}
|
|
88
82
|
function StandardTracerStartSpan(name, parentSpan) {
|
|
89
83
|
const sanitizedName = String(name).replace(/[^a-zA-Z0-9-_/]/g, "_");
|
|
90
84
|
const tracer = StandardTracerGetTracer();
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/Logger.ts
CHANGED
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
ATTR_SERVICE_VERSION,
|
|
14
14
|
} from "@opentelemetry/semantic-conventions";
|
|
15
15
|
import * as os from "os";
|
|
16
|
-
import {
|
|
16
|
+
import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
|
|
17
17
|
import { StandardTracerStartSpan } from "./StandardTracer";
|
|
18
18
|
|
|
19
19
|
let loggerOTel: OTelLogger;
|
|
20
20
|
|
|
21
|
-
export function LoggerInit(context: Span, config:
|
|
21
|
+
export function LoggerInit(context: Span, config: ConfigInterfaceOTel) {
|
|
22
22
|
const span = StandardTracerStartSpan("LoggerInit", context);
|
|
23
23
|
|
|
24
24
|
if (config.OPENTELEMETRY_COLLECTOR_HTTP_LOGS) {
|
package/src/StandardMeter.ts
CHANGED
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
ATTR_SERVICE_VERSION,
|
|
12
12
|
} from "@opentelemetry/semantic-conventions";
|
|
13
13
|
import * as os from "os";
|
|
14
|
-
import {
|
|
14
|
+
import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
|
|
15
15
|
|
|
16
16
|
let meterProvider: MeterProvider;
|
|
17
|
-
let config:
|
|
17
|
+
let config: ConfigInterfaceOTel;
|
|
18
18
|
const METER_NAME = "default";
|
|
19
19
|
|
|
20
20
|
//
|
|
21
|
-
export function StandardMeterInitTelemetry(initConfig:
|
|
21
|
+
export function StandardMeterInitTelemetry(initConfig: ConfigInterfaceOTel) {
|
|
22
22
|
config = initConfig;
|
|
23
23
|
|
|
24
24
|
// Metrics
|
package/src/StandardTracer.ts
CHANGED
|
@@ -19,14 +19,14 @@ import {
|
|
|
19
19
|
ATTR_SERVICE_VERSION,
|
|
20
20
|
} from "@opentelemetry/semantic-conventions";
|
|
21
21
|
import * as os from "os";
|
|
22
|
-
import {
|
|
22
|
+
import { ConfigInterfaceOTel } from "./models/ConfigInterfaceOTel";
|
|
23
23
|
|
|
24
24
|
let tracerInstance: Tracer;
|
|
25
25
|
const propagator = new W3CTraceContextPropagator();
|
|
26
|
-
let config:
|
|
26
|
+
let config: ConfigInterfaceOTel;
|
|
27
27
|
|
|
28
28
|
//
|
|
29
|
-
export function StandardTracerInitTelemetry(initConfig:
|
|
29
|
+
export function StandardTracerInitTelemetry(initConfig: ConfigInterfaceOTel) {
|
|
30
30
|
config = initConfig;
|
|
31
31
|
const spanProcessors = [];
|
|
32
32
|
|
|
@@ -58,12 +58,6 @@ export function StandardTracerInitTelemetry(initConfig: ConfigInterface) {
|
|
|
58
58
|
opentelemetry.context.setGlobalContextManager(contextManager);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
export function StandardTracerGetSpanFromRequest(req: any): Span {
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
-
return (req as any).tracerSpanApi as Span;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
61
|
export function StandardTracerStartSpan(name: string, parentSpan?: Span): Span {
|
|
68
62
|
const sanitizedName = String(name).replace(/[^a-zA-Z0-9-_/]/g, "_");
|
|
69
63
|
const tracer = StandardTracerGetTracer();
|