@ms-cloudpack/telemetry 0.12.2 → 0.12.4

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.
@@ -8,7 +8,7 @@ const __filename = topLevelUrl.fileURLToPath(import.meta.url);
8
8
  const __dirname = topLevelPath.dirname(__filename);
9
9
  import {
10
10
  AzureMonitorStatsbeatExporter
11
- } from "./chunk-KMOWBBY7.js";
11
+ } from "./chunk-WOBLKGKV.js";
12
12
  import "./chunk-UQTA3BJ6.js";
13
13
  export {
14
14
  AzureMonitorStatsbeatExporter
@@ -0,0 +1,39 @@
1
+ import { type Attributes, SpanStatusCode } from '@opentelemetry/api';
2
+ import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
3
+ /** Usually `cloudpack-telemetry@<clientId>` (outside tests, `clientId` is a random GUID) */
4
+ type SpanScope = `${string}@${string}`;
5
+ /**
6
+ * Simplified span format for testing only.
7
+ */
8
+ export interface SimpleSpan {
9
+ /** Span name */
10
+ name: string;
11
+ /** Span attributes (auto and custom) */
12
+ attributes: Attributes | undefined;
13
+ /** Scope info, probably `cloudpack-telemetry@<clientId>` (outside tests, `clientId` is a random GUID) */
14
+ scope: SpanScope;
15
+ /** Status if not `UNSET` */
16
+ status?: keyof typeof SpanStatusCode;
17
+ /** Span parents formatted as `<name> (<scope>)` */
18
+ parents?: {
19
+ name: string;
20
+ scope: SpanScope;
21
+ }[];
22
+ events?: {
23
+ name: string;
24
+ attributes: Attributes | undefined;
25
+ }[];
26
+ }
27
+ /**
28
+ * Processor that saves spans in memory and can return original or formatted versions.
29
+ */
30
+ export declare class InMemoryProcessor extends SimpleSpanProcessor {
31
+ #private;
32
+ constructor();
33
+ /**
34
+ * Return spans in a simplified format for testing telemetry.
35
+ */
36
+ getSimpleSpans(): SimpleSpan[];
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=InMemoryProcessor.d.ts.map
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { SpanStatusCode, type Span } from '@opentelemetry/api';
2
2
  export { createNoOpTelemetryClient } from './createNoOpTelemetryClient.js';
3
+ export { InMemoryProcessor } from './InMemoryProcessor.js';
3
4
  export { startTelemetry } from './startTelemetry.js';
4
5
  export type { AsyncTracer } from './types/AsyncTracer.js';
5
6
  export type { LogLevel } from './types/LogLevel.js';
@@ -1,5 +1,7 @@
1
1
  import type { TelemetryApi } from './types/TelemetryApi.js';
2
2
  import type { TelemetryOptions } from './types/TelemetryOptions.js';
3
+ export declare const _tracerName = "cloudpack-telemetry";
4
+ export declare const _entryName = "CLOUDPACK-TELEMETRY-CLIENT-ENTRY";
3
5
  /**
4
6
  * Initialize the telemetry infrastructure: set up OpenTelemetry, configure the tracer provider, and
5
7
  * add processors for each app (including one to send telemetry if a connection string is provided
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=startTelemetry.test.d.ts.map
@@ -1,3 +1,5 @@
1
+ import type { AzureMonitorExporterOptions } from '@azure/monitor-opentelemetry-exporter';
2
+ import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
1
3
  import type { LogLevel } from './LogLevel.js';
2
4
  export interface TelemetryOptions {
3
5
  /**
@@ -17,5 +19,18 @@ export interface TelemetryOptions {
17
19
  * `undefined` means no telemetry will be sent for that app.
18
20
  */
19
21
  connectionStrings: Record<string, string | undefined>;
22
+ /**
23
+ * Mainly for testing: mapping from app path to client/tracer ID.
24
+ */
25
+ clientIds?: Record<string, string>;
26
+ /**
27
+ * Extra processors for testing. Usually this would be an `InMemoryProcessor` for testing.
28
+ * (In this case you may also want to provide `clientIds`.)
29
+ */
30
+ extraProcessors?: SpanProcessor[];
31
+ /**
32
+ * Mock HTTP client for testing.
33
+ */
34
+ httpClient?: AzureMonitorExporterOptions['httpClient'];
20
35
  }
21
36
  //# sourceMappingURL=TelemetryOptions.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/telemetry",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "Helpers for reporting telemetry in Cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,17 +24,18 @@
24
24
  "test": "cloudpack-scripts test"
25
25
  },
26
26
  "devDependencies": {
27
- "@azure/monitor-opentelemetry-exporter": "1.0.0-beta.39",
28
- "@ms-cloudpack/environment": "^0.1.5",
27
+ "@azure/monitor-opentelemetry-exporter": "1.0.0-beta.41",
28
+ "@ms-cloudpack/environment": "^0.1.6",
29
29
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
30
- "@ms-cloudpack/package-utilities": "^13.8.5",
30
+ "@ms-cloudpack/package-utilities": "^13.8.6",
31
31
  "@ms-cloudpack/scripts": "^0.0.1",
32
32
  "@opentelemetry/api": "1.9.1",
33
- "@opentelemetry/context-async-hooks": "2.1.0",
34
- "@opentelemetry/resources": "2.1.0",
35
- "@opentelemetry/sdk-trace-base": "2.1.0",
36
- "@opentelemetry/sdk-trace-node": "2.1.0",
37
- "@opentelemetry/semantic-conventions": "1.40.0"
33
+ "@opentelemetry/context-async-hooks": "2.7.1",
34
+ "@opentelemetry/core": "2.7.1",
35
+ "@opentelemetry/resources": "2.7.1",
36
+ "@opentelemetry/sdk-trace-base": "2.7.1",
37
+ "@opentelemetry/sdk-trace-node": "2.7.1",
38
+ "@opentelemetry/semantic-conventions": "1.41.1"
38
39
  },
39
40
  "rationale": {
40
41
  "devDependencies": {