@ms-cloudpack/telemetry 0.10.16 → 0.10.17
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/{AppInsightsTelemetryClient-HUHFWAH4.js → AppInsightsTelemetryClient-6AO2QMZD.js} +1 -1
- package/dist/{NoOpTelemetryClient-4JVVCGXK.js → NoOpTelemetryClient-NKBITIHB.js} +2 -2
- package/dist/{chunk-N4UPDAIW.js → chunk-4GU6YOQQ.js} +41 -33
- package/dist/{chunk-V6OZVGOS.js → chunk-U6WCYKJW.js} +1 -1
- package/dist/index.js +9 -4
- package/lib/index.d.ts +1 -0
- package/lib/proxies/createProxiedSpan.d.ts +13 -0
- package/lib/proxies/createProxiedSpan.test.d.ts +2 -0
- package/package.json +1 -1
- package/lib/proxies/createEndGuardedSpan.d.ts +0 -12
- package/lib/proxies/createEndGuardedSpan.test.d.ts +0 -2
package/dist/{AppInsightsTelemetryClient-HUHFWAH4.js → AppInsightsTelemetryClient-6AO2QMZD.js}
RENAMED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
require_src2,
|
|
22
22
|
require_src3,
|
|
23
23
|
require_src4
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-4GU6YOQQ.js";
|
|
25
25
|
|
|
26
26
|
// ../../node_modules/.store/@azure-core-rest-pipeline-npm-1.17.0-aa1ea9ace7/package/dist/commonjs/pipeline.js
|
|
27
27
|
var require_pipeline = __commonJS({
|
|
@@ -6,8 +6,8 @@ const __filename = topLevelUrl.fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = topLevelPath.dirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
NoOpTelemetryClient
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-U6WCYKJW.js";
|
|
10
|
+
import "./chunk-4GU6YOQQ.js";
|
|
11
11
|
export {
|
|
12
12
|
NoOpTelemetryClient
|
|
13
13
|
};
|
|
@@ -45,6 +45,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
45
45
|
));
|
|
46
46
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
47
47
|
|
|
48
|
+
// ../../node_modules/.store/@opentelemetry-api-npm-1.9.0-7d0560d0dd/package/build/esm/trace/status.js
|
|
49
|
+
var SpanStatusCode;
|
|
50
|
+
var init_status = __esm({
|
|
51
|
+
"../../node_modules/.store/@opentelemetry-api-npm-1.9.0-7d0560d0dd/package/build/esm/trace/status.js"() {
|
|
52
|
+
(function(SpanStatusCode2) {
|
|
53
|
+
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
54
|
+
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
55
|
+
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
56
|
+
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
48
60
|
// ../../node_modules/.store/@opentelemetry-api-npm-1.9.0-7d0560d0dd/package/build/esm/platform/node/globalThis.js
|
|
49
61
|
var _globalThis;
|
|
50
62
|
var init_globalThis = __esm({
|
|
@@ -1293,18 +1305,6 @@ var init_span_kind = __esm({
|
|
|
1293
1305
|
}
|
|
1294
1306
|
});
|
|
1295
1307
|
|
|
1296
|
-
// ../../node_modules/.store/@opentelemetry-api-npm-1.9.0-7d0560d0dd/package/build/esm/trace/status.js
|
|
1297
|
-
var SpanStatusCode;
|
|
1298
|
-
var init_status = __esm({
|
|
1299
|
-
"../../node_modules/.store/@opentelemetry-api-npm-1.9.0-7d0560d0dd/package/build/esm/trace/status.js"() {
|
|
1300
|
-
(function(SpanStatusCode2) {
|
|
1301
|
-
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
1302
|
-
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
1303
|
-
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
1304
|
-
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
|
|
1308
1308
|
// ../../node_modules/.store/@opentelemetry-api-npm-1.9.0-7d0560d0dd/package/build/esm/trace/internal/tracestate-validators.js
|
|
1309
1309
|
function validateKey(key) {
|
|
1310
1310
|
return VALID_KEY_REGEX.test(key);
|
|
@@ -12335,49 +12335,56 @@ var _ConsoleSpanExporter = class _ConsoleSpanExporter {
|
|
|
12335
12335
|
__name(_ConsoleSpanExporter, "ConsoleSpanExporter");
|
|
12336
12336
|
var ConsoleSpanExporter = _ConsoleSpanExporter;
|
|
12337
12337
|
|
|
12338
|
-
// src/proxies/
|
|
12338
|
+
// src/proxies/createProxiedSpan.ts
|
|
12339
|
+
init_esm();
|
|
12339
12340
|
var hasEnded = Symbol("hasEnded");
|
|
12340
|
-
function
|
|
12341
|
+
function createProxiedSpan(span) {
|
|
12341
12342
|
return new Proxy(span, {
|
|
12342
12343
|
get(target, prop) {
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
12344
|
+
switch (prop) {
|
|
12345
|
+
case "hasEnded":
|
|
12346
|
+
return () => !!Reflect.get(target, hasEnded);
|
|
12347
|
+
case "end":
|
|
12348
|
+
return () => {
|
|
12349
|
+
if (!Reflect.get(target, hasEnded)) {
|
|
12350
|
+
target.end();
|
|
12351
|
+
Reflect.set(target, hasEnded, true);
|
|
12352
|
+
}
|
|
12353
|
+
};
|
|
12354
|
+
case "recordException":
|
|
12355
|
+
return (...args) => {
|
|
12356
|
+
target.recordException(...args);
|
|
12357
|
+
target.setStatus({ code: SpanStatusCode.ERROR });
|
|
12358
|
+
};
|
|
12359
|
+
default:
|
|
12360
|
+
return Reflect.get(target, prop);
|
|
12353
12361
|
}
|
|
12354
|
-
return Reflect.get(target, prop);
|
|
12355
12362
|
},
|
|
12356
12363
|
set(target, prop, value) {
|
|
12357
|
-
if (prop === "end") {
|
|
12358
|
-
throw new Error(
|
|
12364
|
+
if (prop === "end" || prop === "recordException") {
|
|
12365
|
+
throw new Error(`Cannot overwrite '${prop}' method on Span.`);
|
|
12359
12366
|
}
|
|
12360
12367
|
return Reflect.set(target, prop, value);
|
|
12361
12368
|
}
|
|
12362
12369
|
});
|
|
12363
12370
|
}
|
|
12364
|
-
__name(
|
|
12371
|
+
__name(createProxiedSpan, "createProxiedSpan");
|
|
12365
12372
|
|
|
12366
12373
|
// src/proxies/createSpanFunctionWrapper.ts
|
|
12367
12374
|
function createSpanFunctionWrapper(fn) {
|
|
12368
12375
|
return async (span) => {
|
|
12369
|
-
const
|
|
12376
|
+
const proxiedSpan = createProxiedSpan(span);
|
|
12370
12377
|
try {
|
|
12371
|
-
return await Promise.resolve(fn(
|
|
12378
|
+
return await Promise.resolve(fn(proxiedSpan));
|
|
12372
12379
|
} catch (error) {
|
|
12373
|
-
if (!
|
|
12374
|
-
|
|
12380
|
+
if (!proxiedSpan.hasEnded()) {
|
|
12381
|
+
proxiedSpan.recordException(error instanceof Error || typeof error === "string" ? error : String(error));
|
|
12375
12382
|
} else {
|
|
12376
12383
|
console.info("OpenTelemetry:startActiveSpan: span has already ended, skipping recording exception.");
|
|
12377
12384
|
}
|
|
12378
12385
|
throw error instanceof Error ? error : new Error(String(error));
|
|
12379
12386
|
} finally {
|
|
12380
|
-
|
|
12387
|
+
proxiedSpan.end();
|
|
12381
12388
|
}
|
|
12382
12389
|
};
|
|
12383
12390
|
}
|
|
@@ -12570,6 +12577,7 @@ export {
|
|
|
12570
12577
|
__toCommonJS,
|
|
12571
12578
|
DiagLogLevel,
|
|
12572
12579
|
DiagConsoleLogger,
|
|
12580
|
+
SpanStatusCode,
|
|
12573
12581
|
diag2 as diag,
|
|
12574
12582
|
esm_exports,
|
|
12575
12583
|
init_esm,
|
|
@@ -7,7 +7,7 @@ const __dirname = topLevelPath.dirname(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
BaseTelemetryClient,
|
|
9
9
|
__name
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4GU6YOQQ.js";
|
|
11
11
|
|
|
12
12
|
// src/NoOpTelemetryClient.ts
|
|
13
13
|
var _NoOpTelemetryClient = class _NoOpTelemetryClient extends BaseTelemetryClient {
|
package/dist/index.js
CHANGED
|
@@ -6,28 +6,32 @@ const __filename = topLevelUrl.fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = topLevelPath.dirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
NoOpTelemetryClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-U6WCYKJW.js";
|
|
10
10
|
import {
|
|
11
11
|
DiagConsoleLogger,
|
|
12
12
|
DiagLogLevel,
|
|
13
|
+
SpanStatusCode,
|
|
13
14
|
__name,
|
|
14
15
|
diag,
|
|
15
16
|
init_esm
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-4GU6YOQQ.js";
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
init_esm();
|
|
17
21
|
|
|
18
22
|
// src/createTelemetryClient.ts
|
|
19
23
|
init_esm();
|
|
20
24
|
async function createTelemetryClient(options) {
|
|
21
25
|
if (!options.connectionString) {
|
|
22
26
|
console.debug("No connection string found. Telemetry will not be sent.");
|
|
23
|
-
const { NoOpTelemetryClient: NoOpTelemetryClient2 } = await import("./NoOpTelemetryClient-
|
|
27
|
+
const { NoOpTelemetryClient: NoOpTelemetryClient2 } = await import("./NoOpTelemetryClient-NKBITIHB.js");
|
|
24
28
|
return new NoOpTelemetryClient2();
|
|
25
29
|
}
|
|
26
30
|
diag.setLogger(new DiagConsoleLogger(), {
|
|
27
31
|
logLevel: (options.logLevel && DiagLogLevel[options.logLevel]) ?? DiagLogLevel.WARN,
|
|
28
32
|
suppressOverrideMessage: true
|
|
29
33
|
});
|
|
30
|
-
const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-
|
|
34
|
+
const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-6AO2QMZD.js");
|
|
31
35
|
return new AppInsightsTelemetryClient(options);
|
|
32
36
|
}
|
|
33
37
|
__name(createTelemetryClient, "createTelemetryClient");
|
|
@@ -38,6 +42,7 @@ function createNoOpTelemetryClient() {
|
|
|
38
42
|
}
|
|
39
43
|
__name(createNoOpTelemetryClient, "createNoOpTelemetryClient");
|
|
40
44
|
export {
|
|
45
|
+
SpanStatusCode,
|
|
41
46
|
createNoOpTelemetryClient,
|
|
42
47
|
createTelemetryClient
|
|
43
48
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { Span } from '@opentelemetry/api';
|
|
2
|
+
export { SpanStatusCode } from '@opentelemetry/api';
|
|
2
3
|
export { createTelemetryClient } from './createTelemetryClient.js';
|
|
3
4
|
export type { LogLevel } from './types/LogLevel.js';
|
|
4
5
|
export type { TelemetryClient } from './types/TelemetryClient.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Span } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* A span that can be ended only once
|
|
4
|
+
*/
|
|
5
|
+
export type EndGuardedSpan = Span & {
|
|
6
|
+
hasEnded: () => boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a Span in a Proxy to intercept calls to `end` and ensure it’s only called once.
|
|
10
|
+
* Also sets the status to `ERROR` when an exception is recorded.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createProxiedSpan(span: Span): EndGuardedSpan;
|
|
13
|
+
//# sourceMappingURL=createProxiedSpan.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Span } from '@opentelemetry/api';
|
|
2
|
-
/**
|
|
3
|
-
* A span that can be ended only once
|
|
4
|
-
*/
|
|
5
|
-
export type EndGuardedSpan = Span & {
|
|
6
|
-
hasEnded: () => boolean;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Wraps a Span in a Proxy to intercept calls to `end` and ensure it’s only called once.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createEndGuardedSpan(span: Span): EndGuardedSpan;
|
|
12
|
-
//# sourceMappingURL=createEndGuardedSpan.d.ts.map
|