@ms-cloudpack/telemetry 0.8.0 → 0.8.1
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-VHBDVKM4.js → AppInsightsTelemetryClient-R4KUMXIS.js} +1 -1
- package/dist/{NoOpTelemetryClient-M2CYNHPI.js → NoOpTelemetryClient-TTBAN54Z.js} +2 -2
- package/dist/{chunk-6ZXUGFN2.js → chunk-BNPQM6Z3.js} +1 -1
- package/dist/{chunk-NCK3Y7B7.js → chunk-NJ4KSOZ3.js} +60 -11
- package/dist/index.js +4 -4
- package/lib/ConsoleSpanExporter.d.ts +37 -0
- package/package.json +3 -2
package/dist/{AppInsightsTelemetryClient-VHBDVKM4.js → AppInsightsTelemetryClient-R4KUMXIS.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-NJ4KSOZ3.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-BNPQM6Z3.js";
|
|
10
|
+
import "./chunk-NJ4KSOZ3.js";
|
|
11
11
|
export {
|
|
12
12
|
NoOpTelemetryClient
|
|
13
13
|
};
|
|
@@ -7,7 +7,7 @@ const __dirname = topLevelPath.dirname(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
BaseTelemetryClient,
|
|
9
9
|
__name
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NJ4KSOZ3.js";
|
|
11
11
|
|
|
12
12
|
// src/NoOpTelemetryClient.ts
|
|
13
13
|
var _NoOpTelemetryClient = class _NoOpTelemetryClient extends BaseTelemetryClient {
|
|
@@ -4965,11 +4965,11 @@ var require_ExportResult = __commonJS({
|
|
|
4965
4965
|
"use strict";
|
|
4966
4966
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4967
4967
|
exports.ExportResultCode = void 0;
|
|
4968
|
-
var
|
|
4969
|
-
(function(
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
})(
|
|
4968
|
+
var ExportResultCode2;
|
|
4969
|
+
(function(ExportResultCode3) {
|
|
4970
|
+
ExportResultCode3[ExportResultCode3["SUCCESS"] = 0] = "SUCCESS";
|
|
4971
|
+
ExportResultCode3[ExportResultCode3["FAILED"] = 1] = "FAILED";
|
|
4972
|
+
})(ExportResultCode2 = exports.ExportResultCode || (exports.ExportResultCode = {}));
|
|
4973
4973
|
}
|
|
4974
4974
|
});
|
|
4975
4975
|
|
|
@@ -6988,8 +6988,8 @@ var require_BatchSpanProcessor = __commonJS({
|
|
|
6988
6988
|
}
|
|
6989
6989
|
};
|
|
6990
6990
|
__name(_BatchSpanProcessor, "BatchSpanProcessor");
|
|
6991
|
-
var
|
|
6992
|
-
exports.BatchSpanProcessor =
|
|
6991
|
+
var BatchSpanProcessor2 = _BatchSpanProcessor;
|
|
6992
|
+
exports.BatchSpanProcessor = BatchSpanProcessor2;
|
|
6993
6993
|
}
|
|
6994
6994
|
});
|
|
6995
6995
|
|
|
@@ -8418,7 +8418,7 @@ var require_ConsoleSpanExporter = __commonJS({
|
|
|
8418
8418
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8419
8419
|
exports.ConsoleSpanExporter = void 0;
|
|
8420
8420
|
var core_1 = require_src2();
|
|
8421
|
-
var
|
|
8421
|
+
var _ConsoleSpanExporter2 = class _ConsoleSpanExporter2 {
|
|
8422
8422
|
/**
|
|
8423
8423
|
* Export spans.
|
|
8424
8424
|
* @param spans
|
|
@@ -8479,9 +8479,9 @@ var require_ConsoleSpanExporter = __commonJS({
|
|
|
8479
8479
|
}
|
|
8480
8480
|
}
|
|
8481
8481
|
};
|
|
8482
|
-
__name(
|
|
8483
|
-
var
|
|
8484
|
-
exports.ConsoleSpanExporter =
|
|
8482
|
+
__name(_ConsoleSpanExporter2, "ConsoleSpanExporter");
|
|
8483
|
+
var ConsoleSpanExporter2 = _ConsoleSpanExporter2;
|
|
8484
|
+
exports.ConsoleSpanExporter = ConsoleSpanExporter2;
|
|
8485
8485
|
}
|
|
8486
8486
|
});
|
|
8487
8487
|
|
|
@@ -12359,6 +12359,52 @@ function getVersion(importUrl) {
|
|
|
12359
12359
|
}
|
|
12360
12360
|
__name(getVersion, "getVersion");
|
|
12361
12361
|
|
|
12362
|
+
// src/ConsoleSpanExporter.ts
|
|
12363
|
+
var import_core = __toESM(require_src2(), 1);
|
|
12364
|
+
var _ConsoleSpanExporter = class _ConsoleSpanExporter {
|
|
12365
|
+
/**
|
|
12366
|
+
* Export spans.
|
|
12367
|
+
*/
|
|
12368
|
+
export(spans, resultCallback) {
|
|
12369
|
+
return this._sendSpans(spans, resultCallback);
|
|
12370
|
+
}
|
|
12371
|
+
/**
|
|
12372
|
+
* Shutdown the exporter.
|
|
12373
|
+
*/
|
|
12374
|
+
shutdown() {
|
|
12375
|
+
this._sendSpans([]);
|
|
12376
|
+
return this.forceFlush();
|
|
12377
|
+
}
|
|
12378
|
+
/**
|
|
12379
|
+
* Exports any pending spans in exporter
|
|
12380
|
+
*/
|
|
12381
|
+
forceFlush() {
|
|
12382
|
+
return Promise.resolve();
|
|
12383
|
+
}
|
|
12384
|
+
/**
|
|
12385
|
+
* converts span info into more readable format
|
|
12386
|
+
*/
|
|
12387
|
+
_exportInfo(span) {
|
|
12388
|
+
return [
|
|
12389
|
+
`Telemetry Span: ${span.name} in ${span.duration}ms`,
|
|
12390
|
+
span.events.length > 0 ? `with ${span.events.length} events` : void 0
|
|
12391
|
+
].filter((text) => !!text).join(" ");
|
|
12392
|
+
}
|
|
12393
|
+
/**
|
|
12394
|
+
* Showing spans in console
|
|
12395
|
+
*/
|
|
12396
|
+
_sendSpans(spans, done) {
|
|
12397
|
+
for (const span of spans) {
|
|
12398
|
+
console.debug(this._exportInfo(span));
|
|
12399
|
+
}
|
|
12400
|
+
if (done) {
|
|
12401
|
+
return done({ code: import_core.ExportResultCode.SUCCESS });
|
|
12402
|
+
}
|
|
12403
|
+
}
|
|
12404
|
+
};
|
|
12405
|
+
__name(_ConsoleSpanExporter, "ConsoleSpanExporter");
|
|
12406
|
+
var ConsoleSpanExporter = _ConsoleSpanExporter;
|
|
12407
|
+
|
|
12362
12408
|
// src/BaseTelemetryClient.ts
|
|
12363
12409
|
var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
12364
12410
|
constructor(options) {
|
|
@@ -12375,6 +12421,9 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
|
12375
12421
|
"cloudpack.telemetry.version": getVersion(import.meta.url)
|
|
12376
12422
|
})
|
|
12377
12423
|
);
|
|
12424
|
+
if (options.logLevel === "DEBUG") {
|
|
12425
|
+
this._tracerProvider.addSpanProcessor(new import_sdk_trace_node.BatchSpanProcessor(new ConsoleSpanExporter()));
|
|
12426
|
+
}
|
|
12378
12427
|
this._rootSpan = this.tracer.startSpan(options.rootSpanName || "root");
|
|
12379
12428
|
this._performance = new PerformanceRecorder(this._rootSpan);
|
|
12380
12429
|
diag2.info("TelemetryClient is initialized.");
|
package/dist/index.js
CHANGED
|
@@ -6,28 +6,28 @@ 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-BNPQM6Z3.js";
|
|
10
10
|
import {
|
|
11
11
|
DiagConsoleLogger,
|
|
12
12
|
DiagLogLevel,
|
|
13
13
|
__name,
|
|
14
14
|
diag,
|
|
15
15
|
init_esm
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NJ4KSOZ3.js";
|
|
17
17
|
|
|
18
18
|
// src/createTelemetryClient.ts
|
|
19
19
|
init_esm();
|
|
20
20
|
async function createTelemetryClient(options) {
|
|
21
21
|
if (!options.connectionString) {
|
|
22
22
|
console.debug("No connection string found. Telemetry will not be sent.");
|
|
23
|
-
const { NoOpTelemetryClient: NoOpTelemetryClient2 } = await import("./NoOpTelemetryClient-
|
|
23
|
+
const { NoOpTelemetryClient: NoOpTelemetryClient2 } = await import("./NoOpTelemetryClient-TTBAN54Z.js");
|
|
24
24
|
return new NoOpTelemetryClient2();
|
|
25
25
|
}
|
|
26
26
|
diag.setLogger(new DiagConsoleLogger(), {
|
|
27
27
|
logLevel: options.logLevel || DiagLogLevel.WARN,
|
|
28
28
|
suppressOverrideMessage: true
|
|
29
29
|
});
|
|
30
|
-
const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-
|
|
30
|
+
const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-R4KUMXIS.js");
|
|
31
31
|
return new AppInsightsTelemetryClient(options);
|
|
32
32
|
}
|
|
33
33
|
__name(createTelemetryClient, "createTelemetryClient");
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A customized version of the OpenTelemetry `ConsoleSpanExporter`.
|
|
3
|
+
* Original source: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts
|
|
4
|
+
*
|
|
5
|
+
* This modified exporter adjusts the format of the output for improved readability.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
8
|
+
import type { ExportResult } from '@opentelemetry/core';
|
|
9
|
+
/**
|
|
10
|
+
* This is implementation of {@link SpanExporter} that prints spans to the
|
|
11
|
+
* console. This class can be used for diagnostic purposes.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: This {@link SpanExporter} is intended for diagnostics use only, output rendered to the console may change at any time.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConsoleSpanExporter implements SpanExporter {
|
|
16
|
+
/**
|
|
17
|
+
* Export spans.
|
|
18
|
+
*/
|
|
19
|
+
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
20
|
+
/**
|
|
21
|
+
* Shutdown the exporter.
|
|
22
|
+
*/
|
|
23
|
+
shutdown(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Exports any pending spans in exporter
|
|
26
|
+
*/
|
|
27
|
+
forceFlush(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* converts span info into more readable format
|
|
30
|
+
*/
|
|
31
|
+
private _exportInfo;
|
|
32
|
+
/**
|
|
33
|
+
* Showing spans in console
|
|
34
|
+
*/
|
|
35
|
+
private _sendSpans;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ConsoleSpanExporter.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/telemetry",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Helpers for reporting telemetry in Cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@azure/monitor-opentelemetry-exporter": "1.0.0-beta.26",
|
|
18
18
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
19
|
-
"@ms-cloudpack/package-utilities": "^10.2.
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^10.2.7",
|
|
20
20
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
21
21
|
"@opentelemetry/api": "~1.9.0",
|
|
22
|
+
"@opentelemetry/core": "~1.26.0",
|
|
22
23
|
"@opentelemetry/resources": "~1.26.0",
|
|
23
24
|
"@opentelemetry/sdk-trace-base": "~1.26.0",
|
|
24
25
|
"@opentelemetry/sdk-trace-node": "~1.26.0",
|