@ms-cloudpack/telemetry 0.8.2 → 0.9.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-DIN7NSX7.js → AppInsightsTelemetryClient-U3TW3MST.js} +1 -1
- package/dist/{NoOpTelemetryClient-IZOMUV4R.js → NoOpTelemetryClient-W2RWEMCF.js} +2 -2
- package/dist/{chunk-7OGMQ6JV.js → chunk-J5XDHDQP.js} +1 -2
- package/dist/{chunk-6K6C2B4T.js → chunk-NUFLYJEX.js} +0 -99
- package/dist/index.js +4 -4
- package/lib/BaseTelemetryClient.d.ts +1 -6
- package/lib/index.d.ts +1 -5
- package/lib/types/TelemetryClient.d.ts +1 -10
- package/lib/types/TelemetryOptions.d.ts +0 -4
- package/package.json +2 -2
- package/lib/MetricEventAggregatorRegistry.d.ts +0 -18
- package/lib/PerformanceRecorder.d.ts +0 -41
- package/lib/types/MetricEvent.d.ts +0 -7
- package/lib/types/MetricEventAggregator.d.ts +0 -6
- package/lib/types/PerformanceTracker.d.ts +0 -7
package/dist/{AppInsightsTelemetryClient-DIN7NSX7.js → AppInsightsTelemetryClient-U3TW3MST.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-NUFLYJEX.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-J5XDHDQP.js";
|
|
10
|
+
import "./chunk-NUFLYJEX.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-NUFLYJEX.js";
|
|
11
11
|
|
|
12
12
|
// src/NoOpTelemetryClient.ts
|
|
13
13
|
var _NoOpTelemetryClient = class _NoOpTelemetryClient extends BaseTelemetryClient {
|
|
@@ -15,7 +15,6 @@ var _NoOpTelemetryClient = class _NoOpTelemetryClient extends BaseTelemetryClien
|
|
|
15
15
|
super({
|
|
16
16
|
productVersion: "no-op",
|
|
17
17
|
serviceName: "no-op",
|
|
18
|
-
rootSpanName: "no-op",
|
|
19
18
|
serviceNamespace: "no-op",
|
|
20
19
|
logLevel: "NONE"
|
|
21
20
|
});
|
|
@@ -12129,95 +12129,6 @@ var _SpanEnrichingProcessor = class _SpanEnrichingProcessor {
|
|
|
12129
12129
|
__name(_SpanEnrichingProcessor, "SpanEnrichingProcessor");
|
|
12130
12130
|
var SpanEnrichingProcessor = _SpanEnrichingProcessor;
|
|
12131
12131
|
|
|
12132
|
-
// src/PerformanceRecorder.ts
|
|
12133
|
-
import { performance } from "perf_hooks";
|
|
12134
|
-
|
|
12135
|
-
// src/MetricEventAggregatorRegistry.ts
|
|
12136
|
-
var _MetricEventAggregatorRegistry = class _MetricEventAggregatorRegistry {
|
|
12137
|
-
constructor() {
|
|
12138
|
-
this._aggregators = /* @__PURE__ */ new Set();
|
|
12139
|
-
}
|
|
12140
|
-
/**
|
|
12141
|
-
* Registers a new aggregator. If an aggregator already exists, it will be return the aggregator.
|
|
12142
|
-
* @param name - The name of the metric.
|
|
12143
|
-
* @param aggregate - The aggregator function.
|
|
12144
|
-
* @returns The aggregator that is passed in.
|
|
12145
|
-
*/
|
|
12146
|
-
register(aggregator) {
|
|
12147
|
-
if (!this._aggregators.has(aggregator)) {
|
|
12148
|
-
this._aggregators.add(aggregator);
|
|
12149
|
-
}
|
|
12150
|
-
return aggregator;
|
|
12151
|
-
}
|
|
12152
|
-
/**
|
|
12153
|
-
* Gets all the aggregated events from all the registered aggregators.
|
|
12154
|
-
* @returns The aggregated events.
|
|
12155
|
-
*/
|
|
12156
|
-
getAggregatedEvents() {
|
|
12157
|
-
const events = [];
|
|
12158
|
-
for (const aggregator of this._aggregators) {
|
|
12159
|
-
events.push(...aggregator.getAggregatedEvents());
|
|
12160
|
-
}
|
|
12161
|
-
return events;
|
|
12162
|
-
}
|
|
12163
|
-
};
|
|
12164
|
-
__name(_MetricEventAggregatorRegistry, "MetricEventAggregatorRegistry");
|
|
12165
|
-
var MetricEventAggregatorRegistry = _MetricEventAggregatorRegistry;
|
|
12166
|
-
|
|
12167
|
-
// src/PerformanceRecorder.ts
|
|
12168
|
-
var _PerformanceRecorder = class _PerformanceRecorder {
|
|
12169
|
-
constructor(span) {
|
|
12170
|
-
this.span = span;
|
|
12171
|
-
this._metricEventAggregatorRegistry = new MetricEventAggregatorRegistry();
|
|
12172
|
-
}
|
|
12173
|
-
/**
|
|
12174
|
-
* Registers a new aggregator for a given metric.
|
|
12175
|
-
* If an aggregator already exists, it will be skipped.
|
|
12176
|
-
* @param name - The name of the metric.
|
|
12177
|
-
* @param aggregator - The aggregator function.
|
|
12178
|
-
*/
|
|
12179
|
-
registerAggregator(aggregator) {
|
|
12180
|
-
return this._metricEventAggregatorRegistry.register(aggregator);
|
|
12181
|
-
}
|
|
12182
|
-
/**
|
|
12183
|
-
* Records a performance metric into telemetry. The metric will be recorded as an event on the span and logged to the console.
|
|
12184
|
-
* It can be used for any situation where a performance metric (ie: how long does it take run something, or any other purpose) is needed.
|
|
12185
|
-
* @param attributes
|
|
12186
|
-
*/
|
|
12187
|
-
record(attributes) {
|
|
12188
|
-
const { name, value, additionalProperties = {} } = attributes;
|
|
12189
|
-
this.span.addEvent("Performance-Metric", { ...additionalProperties, name, value });
|
|
12190
|
-
console.debug(`Performance-Metric: ${name} ${value}`);
|
|
12191
|
-
}
|
|
12192
|
-
async track(name, execute) {
|
|
12193
|
-
const additionalProperties = {};
|
|
12194
|
-
const startTime = performance.now();
|
|
12195
|
-
const tracker = {
|
|
12196
|
-
name,
|
|
12197
|
-
startTime,
|
|
12198
|
-
setProperties: /* @__PURE__ */ __name((properties) => {
|
|
12199
|
-
Object.assign(additionalProperties, properties);
|
|
12200
|
-
}, "setProperties")
|
|
12201
|
-
};
|
|
12202
|
-
const result = execute(tracker);
|
|
12203
|
-
if (result instanceof Promise) {
|
|
12204
|
-
await result;
|
|
12205
|
-
}
|
|
12206
|
-
this.record({ name, value: performance.now() - startTime, additionalProperties });
|
|
12207
|
-
return result;
|
|
12208
|
-
}
|
|
12209
|
-
/**
|
|
12210
|
-
* Shuts down the performance recorder and records any aggregated events.
|
|
12211
|
-
*/
|
|
12212
|
-
shutdown() {
|
|
12213
|
-
for (const { name, value, attributes } of this._metricEventAggregatorRegistry.getAggregatedEvents()) {
|
|
12214
|
-
this.record({ name, value, additionalProperties: attributes });
|
|
12215
|
-
}
|
|
12216
|
-
}
|
|
12217
|
-
};
|
|
12218
|
-
__name(_PerformanceRecorder, "PerformanceRecorder");
|
|
12219
|
-
var PerformanceRecorder = _PerformanceRecorder;
|
|
12220
|
-
|
|
12221
12132
|
// ../../node_modules/.store/uuid-npm-10.0.0-4872b46ff8/package/dist/esm-node/stringify.js
|
|
12222
12133
|
var byteToHex = [];
|
|
12223
12134
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -12526,8 +12437,6 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
|
12526
12437
|
if (options.logLevel === "DEBUG") {
|
|
12527
12438
|
this._tracerProvider.addSpanProcessor(new import_sdk_trace_node.BatchSpanProcessor(new ConsoleSpanExporter()));
|
|
12528
12439
|
}
|
|
12529
|
-
this._rootSpan = this.tracer.startSpan(options.rootSpanName || "root");
|
|
12530
|
-
this._performance = new PerformanceRecorder(this._rootSpan);
|
|
12531
12440
|
diag2.info("TelemetryClient is initialized.");
|
|
12532
12441
|
}
|
|
12533
12442
|
/**
|
|
@@ -12535,8 +12444,6 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
|
12535
12444
|
*/
|
|
12536
12445
|
async shutdown() {
|
|
12537
12446
|
diag2.debug("TelemetryClient is shuting down.");
|
|
12538
|
-
this._performance.shutdown();
|
|
12539
|
-
this.rootSpan.end();
|
|
12540
12447
|
await this._tracerProvider.forceFlush();
|
|
12541
12448
|
await this._tracerProvider.shutdown();
|
|
12542
12449
|
diag2.debug("TelemetryClient has shutdown.");
|
|
@@ -12548,12 +12455,6 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
|
12548
12455
|
get tracer() {
|
|
12549
12456
|
return createProxiedTracer(this._tracerProvider.getTracer("cloudpack-tracer"));
|
|
12550
12457
|
}
|
|
12551
|
-
get performance() {
|
|
12552
|
-
return this._performance;
|
|
12553
|
-
}
|
|
12554
|
-
get rootSpan() {
|
|
12555
|
-
return this._rootSpan;
|
|
12556
|
-
}
|
|
12557
12458
|
};
|
|
12558
12459
|
__name(_BaseTelemetryClient, "BaseTelemetryClient");
|
|
12559
12460
|
var BaseTelemetryClient = _BaseTelemetryClient;
|
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-J5XDHDQP.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-NUFLYJEX.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-W2RWEMCF.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-U3TW3MST.js");
|
|
31
31
|
return new AppInsightsTelemetryClient(options);
|
|
32
32
|
}
|
|
33
33
|
__name(createTelemetryClient, "createTelemetryClient");
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Tracer } from '@opentelemetry/api';
|
|
2
2
|
import type { TelemetryOptions } from './types/TelemetryOptions.js';
|
|
3
3
|
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
4
4
|
import type { TelemetryClient } from './types/TelemetryClient.js';
|
|
5
|
-
import { PerformanceRecorder } from './PerformanceRecorder.js';
|
|
6
5
|
export declare class BaseTelemetryClient implements TelemetryClient {
|
|
7
|
-
private readonly _performance;
|
|
8
|
-
private readonly _rootSpan;
|
|
9
6
|
protected readonly _tracerProvider: NodeTracerProvider;
|
|
10
7
|
constructor(options: TelemetryOptions);
|
|
11
8
|
/**
|
|
@@ -17,7 +14,5 @@ export declare class BaseTelemetryClient implements TelemetryClient {
|
|
|
17
14
|
* @returns the OpenTelemetry tracer
|
|
18
15
|
*/
|
|
19
16
|
get tracer(): Tracer;
|
|
20
|
-
get performance(): PerformanceRecorder;
|
|
21
|
-
get rootSpan(): Span;
|
|
22
17
|
}
|
|
23
18
|
//# sourceMappingURL=BaseTelemetryClient.d.ts.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
export type { Span, Tracer
|
|
1
|
+
export type { Span, Tracer } from '@opentelemetry/api';
|
|
2
2
|
export { createTelemetryClient } from './createTelemetryClient.js';
|
|
3
3
|
export type { LogLevel } from './types/LogLevel.js';
|
|
4
4
|
export type { TelemetryClient } from './types/TelemetryClient.js';
|
|
5
5
|
export type { TelemetryOptions } from './types/TelemetryOptions.js';
|
|
6
6
|
export { createNoOpTelemetryClient } from './createNoOpTelemetryClient.js';
|
|
7
|
-
export type { PerformanceTracker } from './types/PerformanceTracker.js';
|
|
8
|
-
export type { PerformanceRecorder } from './PerformanceRecorder.js';
|
|
9
|
-
export type { MetricEvent } from './types/MetricEvent.js';
|
|
10
|
-
export type { MetricEventAggregator } from './types/MetricEventAggregator.js';
|
|
11
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PerformanceRecorder } from '../PerformanceRecorder.js';
|
|
1
|
+
import type { Tracer } from '@opentelemetry/api';
|
|
3
2
|
export interface TelemetryClient {
|
|
4
|
-
/**
|
|
5
|
-
* Root span which measures the duration of the highest level application (ie: CLI)
|
|
6
|
-
*/
|
|
7
|
-
rootSpan: Span;
|
|
8
3
|
/**
|
|
9
4
|
* Flushes all telemetry and shuts down the telemetry client.
|
|
10
5
|
*/
|
|
@@ -14,9 +9,5 @@ export interface TelemetryClient {
|
|
|
14
9
|
* @returns the OpenTelemetry tracer
|
|
15
10
|
*/
|
|
16
11
|
get tracer(): Tracer;
|
|
17
|
-
/**
|
|
18
|
-
* Gets the performance recorder.
|
|
19
|
-
*/
|
|
20
|
-
performance: PerformanceRecorder;
|
|
21
12
|
}
|
|
22
13
|
//# sourceMappingURL=TelemetryClient.d.ts.map
|
|
@@ -22,9 +22,5 @@ export interface TelemetryOptions {
|
|
|
22
22
|
* Possible values: cli, bundler-service, etc.
|
|
23
23
|
*/
|
|
24
24
|
serviceName: string;
|
|
25
|
-
/**
|
|
26
|
-
* Name of the root span, 'root' will be used as a span name if this property is not set.
|
|
27
|
-
*/
|
|
28
|
-
rootSpanName?: string;
|
|
29
25
|
}
|
|
30
26
|
//# sourceMappingURL=TelemetryOptions.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/telemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Helpers for reporting telemetry in Cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
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.9",
|
|
20
20
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
21
21
|
"@opentelemetry/api": "~1.9.0",
|
|
22
22
|
"@opentelemetry/core": "~1.26.0",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { MetricEvent } from './types/MetricEvent.js';
|
|
2
|
-
import type { MetricEventAggregator } from './types/MetricEventAggregator.js';
|
|
3
|
-
export declare class MetricEventAggregatorRegistry {
|
|
4
|
-
private readonly _aggregators;
|
|
5
|
-
/**
|
|
6
|
-
* Registers a new aggregator. If an aggregator already exists, it will be return the aggregator.
|
|
7
|
-
* @param name - The name of the metric.
|
|
8
|
-
* @param aggregate - The aggregator function.
|
|
9
|
-
* @returns The aggregator that is passed in.
|
|
10
|
-
*/
|
|
11
|
-
register<T>(aggregator: MetricEventAggregator<T>): MetricEventAggregator<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Gets all the aggregated events from all the registered aggregators.
|
|
14
|
-
* @returns The aggregated events.
|
|
15
|
-
*/
|
|
16
|
-
getAggregatedEvents(): MetricEvent[];
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=MetricEventAggregatorRegistry.d.ts.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Attributes, Span } from '@opentelemetry/api';
|
|
2
|
-
import type { PerformanceTracker } from './types/PerformanceTracker.js';
|
|
3
|
-
import type { MetricEventAggregator } from './types/MetricEventAggregator.js';
|
|
4
|
-
/**
|
|
5
|
-
* PerformanceRecorder is a utility class for recording performance metrics into telemetry.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PerformanceRecorder {
|
|
8
|
-
private readonly span;
|
|
9
|
-
private readonly _metricEventAggregatorRegistry;
|
|
10
|
-
constructor(span: Span);
|
|
11
|
-
/**
|
|
12
|
-
* Registers a new aggregator for a given metric.
|
|
13
|
-
* If an aggregator already exists, it will be skipped.
|
|
14
|
-
* @param name - The name of the metric.
|
|
15
|
-
* @param aggregator - The aggregator function.
|
|
16
|
-
*/
|
|
17
|
-
registerAggregator<T>(aggregator: MetricEventAggregator<T>): MetricEventAggregator<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Records a performance metric into telemetry. The metric will be recorded as an event on the span and logged to the console.
|
|
20
|
-
* It can be used for any situation where a performance metric (ie: how long does it take run something, or any other purpose) is needed.
|
|
21
|
-
* @param attributes
|
|
22
|
-
*/
|
|
23
|
-
record(attributes: {
|
|
24
|
-
name: string;
|
|
25
|
-
value: number;
|
|
26
|
-
additionalProperties?: Attributes;
|
|
27
|
-
}): void;
|
|
28
|
-
/**
|
|
29
|
-
* Tracks the execution time of a given `execute` function and report it to telemetry.
|
|
30
|
-
* @param name - The name of the performance metric.
|
|
31
|
-
* @param execute - The function to execute and track.
|
|
32
|
-
* @returns - The result of the `execute` function.
|
|
33
|
-
*/
|
|
34
|
-
track<T>(name: string, execute: (tracker: PerformanceTracker) => T): T;
|
|
35
|
-
track<T>(name: string, execute: (tracker: PerformanceTracker) => Promise<T>): Promise<T>;
|
|
36
|
-
/**
|
|
37
|
-
* Shuts down the performance recorder and records any aggregated events.
|
|
38
|
-
*/
|
|
39
|
-
shutdown(): void;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=PerformanceRecorder.d.ts.map
|