@ms-cloudpack/telemetry 0.10.7 → 0.10.8
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-ZKKOJCSN.js → AppInsightsTelemetryClient-52HZATD6.js} +1 -1
- package/dist/{NoOpTelemetryClient-H75ZBB4T.js → NoOpTelemetryClient-DJPDMTNS.js} +2 -2
- package/dist/{chunk-F3TAGUKV.js → chunk-AEUNAYUO.js} +87 -10
- package/dist/{chunk-KZSDB6J7.js → chunk-UPNW2UON.js} +1 -1
- package/dist/index.js +4 -4
- package/lib/BaseTelemetryClient.d.ts +11 -0
- package/lib/CustomContextManager.d.ts +41 -0
- package/lib/types/TelemetryClient.d.ts +10 -0
- package/package.json +2 -1
package/dist/{AppInsightsTelemetryClient-ZKKOJCSN.js → AppInsightsTelemetryClient-52HZATD6.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-AEUNAYUO.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-UPNW2UON.js";
|
|
10
|
+
import "./chunk-AEUNAYUO.js";
|
|
11
11
|
export {
|
|
12
12
|
NoOpTelemetryClient
|
|
13
13
|
};
|
|
@@ -1733,9 +1733,9 @@ var init_esm = __esm({
|
|
|
1733
1733
|
}
|
|
1734
1734
|
});
|
|
1735
1735
|
|
|
1736
|
-
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
1736
|
+
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/AbstractAsyncHooksContextManager.js
|
|
1737
1737
|
var require_AbstractAsyncHooksContextManager = __commonJS({
|
|
1738
|
-
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
1738
|
+
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/AbstractAsyncHooksContextManager.js"(exports) {
|
|
1739
1739
|
"use strict";
|
|
1740
1740
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1741
1741
|
exports.AbstractAsyncHooksContextManager = void 0;
|
|
@@ -1893,9 +1893,9 @@ var require_AbstractAsyncHooksContextManager = __commonJS({
|
|
|
1893
1893
|
}
|
|
1894
1894
|
});
|
|
1895
1895
|
|
|
1896
|
-
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
1896
|
+
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/AsyncHooksContextManager.js
|
|
1897
1897
|
var require_AsyncHooksContextManager = __commonJS({
|
|
1898
|
-
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
1898
|
+
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/AsyncHooksContextManager.js"(exports) {
|
|
1899
1899
|
"use strict";
|
|
1900
1900
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1901
1901
|
exports.AsyncHooksContextManager = void 0;
|
|
@@ -1989,14 +1989,14 @@ var require_AsyncHooksContextManager = __commonJS({
|
|
|
1989
1989
|
}
|
|
1990
1990
|
};
|
|
1991
1991
|
__name(_AsyncHooksContextManager, "AsyncHooksContextManager");
|
|
1992
|
-
var
|
|
1993
|
-
exports.AsyncHooksContextManager =
|
|
1992
|
+
var AsyncHooksContextManager2 = _AsyncHooksContextManager;
|
|
1993
|
+
exports.AsyncHooksContextManager = AsyncHooksContextManager2;
|
|
1994
1994
|
}
|
|
1995
1995
|
});
|
|
1996
1996
|
|
|
1997
|
-
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
1997
|
+
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/AsyncLocalStorageContextManager.js
|
|
1998
1998
|
var require_AsyncLocalStorageContextManager = __commonJS({
|
|
1999
|
-
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
1999
|
+
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/AsyncLocalStorageContextManager.js"(exports) {
|
|
2000
2000
|
"use strict";
|
|
2001
2001
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2002
2002
|
exports.AsyncLocalStorageContextManager = void 0;
|
|
@@ -2030,9 +2030,9 @@ var require_AsyncLocalStorageContextManager = __commonJS({
|
|
|
2030
2030
|
}
|
|
2031
2031
|
});
|
|
2032
2032
|
|
|
2033
|
-
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
2033
|
+
// ../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/index.js
|
|
2034
2034
|
var require_src = __commonJS({
|
|
2035
|
-
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-
|
|
2035
|
+
"../../node_modules/.store/@opentelemetry-context-async-hooks-virtual-6b60acf600/package/build/src/index.js"(exports) {
|
|
2036
2036
|
"use strict";
|
|
2037
2037
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2038
2038
|
exports.AsyncLocalStorageContextManager = exports.AsyncHooksContextManager = void 0;
|
|
@@ -12471,13 +12471,77 @@ function createProxiedTracer(tracer) {
|
|
|
12471
12471
|
}
|
|
12472
12472
|
__name(createProxiedTracer, "createProxiedTracer");
|
|
12473
12473
|
|
|
12474
|
+
// src/CustomContextManager.ts
|
|
12475
|
+
init_esm();
|
|
12476
|
+
var import_context_async_hooks = __toESM(require_src(), 1);
|
|
12477
|
+
var _CustomContextManager = class _CustomContextManager {
|
|
12478
|
+
constructor() {
|
|
12479
|
+
this._contextManager = new import_context_async_hooks.AsyncHooksContextManager();
|
|
12480
|
+
this._rootContext = void 0;
|
|
12481
|
+
}
|
|
12482
|
+
/**
|
|
12483
|
+
* This is used to set the root context. If no root context is set, ROOT_CONTEXT is used.
|
|
12484
|
+
* @param context - the root context for the telemetry client
|
|
12485
|
+
*/
|
|
12486
|
+
setRootContext(context2) {
|
|
12487
|
+
this._rootContext = context2;
|
|
12488
|
+
}
|
|
12489
|
+
/**
|
|
12490
|
+
* @returns the active context
|
|
12491
|
+
*/
|
|
12492
|
+
active() {
|
|
12493
|
+
const activeContext = this._contextManager.active();
|
|
12494
|
+
if (activeContext === ROOT_CONTEXT) {
|
|
12495
|
+
return this._rootContext || ROOT_CONTEXT;
|
|
12496
|
+
}
|
|
12497
|
+
return activeContext;
|
|
12498
|
+
}
|
|
12499
|
+
/**
|
|
12500
|
+
* Run the fn callback with object set as the current active context
|
|
12501
|
+
* @param context Any object to set as the current active context
|
|
12502
|
+
* @param fn A callback to be immediately run within a specific context
|
|
12503
|
+
* @param thisArg optional receiver to be used for calling fn
|
|
12504
|
+
* @param args optional arguments forwarded to fn
|
|
12505
|
+
*/
|
|
12506
|
+
with(context2, fn, thisArg, ...args) {
|
|
12507
|
+
return this._contextManager.with(context2, fn, thisArg, ...args);
|
|
12508
|
+
}
|
|
12509
|
+
/**
|
|
12510
|
+
* Bind an object as the current context (or a specific one)
|
|
12511
|
+
* @param [context] Optionally specify the context which you want to assign
|
|
12512
|
+
* @param target Any object to which a context need to be set
|
|
12513
|
+
*/
|
|
12514
|
+
bind(context2, target) {
|
|
12515
|
+
return this._contextManager.bind(context2, target);
|
|
12516
|
+
}
|
|
12517
|
+
/**
|
|
12518
|
+
* Enable context management
|
|
12519
|
+
*/
|
|
12520
|
+
enable() {
|
|
12521
|
+
this._contextManager.enable();
|
|
12522
|
+
return this;
|
|
12523
|
+
}
|
|
12524
|
+
/**
|
|
12525
|
+
* Disable context management
|
|
12526
|
+
*/
|
|
12527
|
+
disable() {
|
|
12528
|
+
this._contextManager.disable();
|
|
12529
|
+
return this;
|
|
12530
|
+
}
|
|
12531
|
+
};
|
|
12532
|
+
__name(_CustomContextManager, "CustomContextManager");
|
|
12533
|
+
var CustomContextManager = _CustomContextManager;
|
|
12534
|
+
|
|
12474
12535
|
// src/BaseTelemetryClient.ts
|
|
12475
12536
|
var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
12476
12537
|
constructor(options) {
|
|
12477
12538
|
this._tracer = void 0;
|
|
12539
|
+
this._contextManager = new CustomContextManager();
|
|
12478
12540
|
diag2.debug("Initializing TelemetryClient with options:", options);
|
|
12479
12541
|
metrics.disable();
|
|
12480
12542
|
trace.disable();
|
|
12543
|
+
this._contextManager.enable();
|
|
12544
|
+
context.setGlobalContextManager(this._contextManager);
|
|
12481
12545
|
const resource = createResourceFromOptions(options);
|
|
12482
12546
|
this._tracerProvider = new import_sdk_trace_node.NodeTracerProvider({
|
|
12483
12547
|
resource
|
|
@@ -12513,6 +12577,19 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
|
|
|
12513
12577
|
}
|
|
12514
12578
|
return this._tracer;
|
|
12515
12579
|
}
|
|
12580
|
+
/**
|
|
12581
|
+
* Gets the OpenTelemetry context.
|
|
12582
|
+
*/
|
|
12583
|
+
get context() {
|
|
12584
|
+
return context;
|
|
12585
|
+
}
|
|
12586
|
+
/**
|
|
12587
|
+
* Sets the root context.
|
|
12588
|
+
* @param context - the root context for the telemetry client
|
|
12589
|
+
*/
|
|
12590
|
+
setRootContext(context2) {
|
|
12591
|
+
this._contextManager.setRootContext(context2);
|
|
12592
|
+
}
|
|
12516
12593
|
};
|
|
12517
12594
|
__name(_BaseTelemetryClient, "BaseTelemetryClient");
|
|
12518
12595
|
var BaseTelemetryClient = _BaseTelemetryClient;
|
|
@@ -7,7 +7,7 @@ const __dirname = topLevelPath.dirname(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
BaseTelemetryClient,
|
|
9
9
|
__name
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AEUNAYUO.js";
|
|
11
11
|
|
|
12
12
|
// src/NoOpTelemetryClient.ts
|
|
13
13
|
var _NoOpTelemetryClient = class _NoOpTelemetryClient extends 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-UPNW2UON.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-AEUNAYUO.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-DJPDMTNS.js");
|
|
24
24
|
return new NoOpTelemetryClient2();
|
|
25
25
|
}
|
|
26
26
|
diag.setLogger(new DiagConsoleLogger(), {
|
|
27
27
|
logLevel: (options.logLevel && DiagLogLevel[options.logLevel]) ?? DiagLogLevel.WARN,
|
|
28
28
|
suppressOverrideMessage: true
|
|
29
29
|
});
|
|
30
|
-
const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-
|
|
30
|
+
const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-52HZATD6.js");
|
|
31
31
|
return new AppInsightsTelemetryClient(options);
|
|
32
32
|
}
|
|
33
33
|
__name(createTelemetryClient, "createTelemetryClient");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ContextAPI, type Context } from '@opentelemetry/api';
|
|
1
2
|
import type { TelemetryOptions } from './types/TelemetryOptions.js';
|
|
2
3
|
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
3
4
|
import type { TelemetryClient } from './types/TelemetryClient.js';
|
|
@@ -5,6 +6,7 @@ import { type AsyncTracer } from './proxies/createProxiedTracer.js';
|
|
|
5
6
|
export declare class BaseTelemetryClient implements TelemetryClient {
|
|
6
7
|
protected readonly _tracerProvider: NodeTracerProvider;
|
|
7
8
|
private _tracer;
|
|
9
|
+
private _contextManager;
|
|
8
10
|
constructor(options: TelemetryOptions);
|
|
9
11
|
/**
|
|
10
12
|
* Flushes all telemetry and shuts down the telemetry client.
|
|
@@ -15,5 +17,14 @@ export declare class BaseTelemetryClient implements TelemetryClient {
|
|
|
15
17
|
* @returns the OpenTelemetry tracer
|
|
16
18
|
*/
|
|
17
19
|
get tracer(): AsyncTracer;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the OpenTelemetry context.
|
|
22
|
+
*/
|
|
23
|
+
get context(): ContextAPI;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the root context.
|
|
26
|
+
* @param context - the root context for the telemetry client
|
|
27
|
+
*/
|
|
28
|
+
setRootContext(context: Context | undefined): void;
|
|
18
29
|
}
|
|
19
30
|
//# sourceMappingURL=BaseTelemetryClient.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ContextManager, type Context } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* This is a wrapper around the AsyncHooksContextManager that allows for setting a root context
|
|
4
|
+
* which is being used if no context is available.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CustomContextManager implements ContextManager {
|
|
7
|
+
private _contextManager;
|
|
8
|
+
private _rootContext;
|
|
9
|
+
/**
|
|
10
|
+
* This is used to set the root context. If no root context is set, ROOT_CONTEXT is used.
|
|
11
|
+
* @param context - the root context for the telemetry client
|
|
12
|
+
*/
|
|
13
|
+
setRootContext(context: Context | undefined): void;
|
|
14
|
+
/**
|
|
15
|
+
* @returns the active context
|
|
16
|
+
*/
|
|
17
|
+
active(): Context;
|
|
18
|
+
/**
|
|
19
|
+
* Run the fn callback with object set as the current active context
|
|
20
|
+
* @param context Any object to set as the current active context
|
|
21
|
+
* @param fn A callback to be immediately run within a specific context
|
|
22
|
+
* @param thisArg optional receiver to be used for calling fn
|
|
23
|
+
* @param args optional arguments forwarded to fn
|
|
24
|
+
*/
|
|
25
|
+
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
26
|
+
/**
|
|
27
|
+
* Bind an object as the current context (or a specific one)
|
|
28
|
+
* @param [context] Optionally specify the context which you want to assign
|
|
29
|
+
* @param target Any object to which a context need to be set
|
|
30
|
+
*/
|
|
31
|
+
bind<T>(context: Context, target: T): T;
|
|
32
|
+
/**
|
|
33
|
+
* Enable context management
|
|
34
|
+
*/
|
|
35
|
+
enable(): this;
|
|
36
|
+
/**
|
|
37
|
+
* Disable context management
|
|
38
|
+
*/
|
|
39
|
+
disable(): this;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=CustomContextManager.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Context, ContextAPI } from '@opentelemetry/api';
|
|
1
2
|
import type { AsyncTracer } from '../proxies/createProxiedTracer.js';
|
|
2
3
|
export interface TelemetryClient {
|
|
3
4
|
/**
|
|
@@ -9,5 +10,14 @@ export interface TelemetryClient {
|
|
|
9
10
|
* @returns the OpenTelemetry tracer
|
|
10
11
|
*/
|
|
11
12
|
get tracer(): AsyncTracer;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the OpenTelemetry context.
|
|
15
|
+
*/
|
|
16
|
+
get context(): ContextAPI;
|
|
17
|
+
/**
|
|
18
|
+
* Sets the root context.
|
|
19
|
+
* @param context - the root context for the telemetry client
|
|
20
|
+
*/
|
|
21
|
+
setRootContext(context: Context | undefined): void;
|
|
12
22
|
}
|
|
13
23
|
//# sourceMappingURL=TelemetryClient.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/telemetry",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8",
|
|
4
4
|
"description": "Helpers for reporting telemetry in Cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@ms-cloudpack/package-utilities": "^11.1.2",
|
|
21
21
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
22
22
|
"@opentelemetry/api": "~1.9.0",
|
|
23
|
+
"@opentelemetry/context-async-hooks": "~1.26.0",
|
|
23
24
|
"@opentelemetry/core": "~1.26.0",
|
|
24
25
|
"@opentelemetry/resources": "~1.26.0",
|
|
25
26
|
"@opentelemetry/sdk-trace-base": "~1.26.0",
|