@ms-cloudpack/telemetry 0.7.0 → 0.8.0

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.
@@ -21,7 +21,7 @@ import {
21
21
  require_src2,
22
22
  require_src3,
23
23
  require_src4
24
- } from "./chunk-ITZ7GKLO.js";
24
+ } from "./chunk-NCK3Y7B7.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-MZUZAXPV.js";
10
- import "./chunk-ITZ7GKLO.js";
9
+ } from "./chunk-6ZXUGFN2.js";
10
+ import "./chunk-NCK3Y7B7.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-ITZ7GKLO.js";
10
+ } from "./chunk-NCK3Y7B7.js";
11
11
 
12
12
  // src/NoOpTelemetryClient.ts
13
13
  var _NoOpTelemetryClient = class _NoOpTelemetryClient extends BaseTelemetryClient {
@@ -12109,8 +12109,8 @@ var import_sdk_trace_node = __toESM(require_src7(), 1);
12109
12109
 
12110
12110
  // src/SpanEnrichingProcessor.ts
12111
12111
  var _SpanEnrichingProcessor = class _SpanEnrichingProcessor {
12112
- constructor(getSharedSpanAttributes) {
12113
- this.getSharedSpanAttributes = getSharedSpanAttributes;
12112
+ constructor(sharedSpanAttributes) {
12113
+ this.sharedSpanAttributes = sharedSpanAttributes;
12114
12114
  }
12115
12115
  forceFlush() {
12116
12116
  return Promise.resolve();
@@ -12121,7 +12121,7 @@ var _SpanEnrichingProcessor = class _SpanEnrichingProcessor {
12121
12121
  onStart() {
12122
12122
  }
12123
12123
  onEnd(span) {
12124
- for (const [key, value] of Object.entries(this.getSharedSpanAttributes())) {
12124
+ for (const [key, value] of Object.entries(this.sharedSpanAttributes)) {
12125
12125
  span.attributes[key] = value;
12126
12126
  }
12127
12127
  }
@@ -12365,15 +12365,16 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
12365
12365
  diag2.debug("Initializing TelemetryClient with options:", options);
12366
12366
  metrics.disable();
12367
12367
  trace.disable();
12368
- this.sharedSpanAttributes = {
12369
- "cloudpack.telemetry.id": v4_default(),
12370
- "cloudpack.telemetry.version": getVersion(import.meta.url)
12371
- };
12372
12368
  const resource = createResourceFromOptions(options);
12373
12369
  this._tracerProvider = new import_sdk_trace_node.NodeTracerProvider({
12374
12370
  resource
12375
12371
  });
12376
- this._tracerProvider.addSpanProcessor(new SpanEnrichingProcessor(() => this.sharedSpanAttributes));
12372
+ this._tracerProvider.addSpanProcessor(
12373
+ new SpanEnrichingProcessor({
12374
+ "cloudpack.telemetry.id": v4_default(),
12375
+ "cloudpack.telemetry.version": getVersion(import.meta.url)
12376
+ })
12377
+ );
12377
12378
  this._rootSpan = this.tracer.startSpan(options.rootSpanName || "root");
12378
12379
  this._performance = new PerformanceRecorder(this._rootSpan);
12379
12380
  diag2.info("TelemetryClient is initialized.");
@@ -12389,14 +12390,6 @@ var _BaseTelemetryClient = class _BaseTelemetryClient {
12389
12390
  await this._tracerProvider.shutdown();
12390
12391
  diag2.debug("TelemetryClient has shutdown.");
12391
12392
  }
12392
- /**
12393
- * Sets a shared attribute that will be added to all spans.
12394
- * @param key - key of the attribute
12395
- * @param value - value of the attribute
12396
- */
12397
- setSharedSpanAttribute(key, value) {
12398
- this.sharedSpanAttributes[key] = value;
12399
- }
12400
12393
  /**
12401
12394
  * Gets the OpenTelemetry tracer.
12402
12395
  * @returns the OpenTelemetry tracer
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-MZUZAXPV.js";
9
+ } from "./chunk-6ZXUGFN2.js";
10
10
  import {
11
11
  DiagConsoleLogger,
12
12
  DiagLogLevel,
13
13
  __name,
14
14
  diag,
15
15
  init_esm
16
- } from "./chunk-ITZ7GKLO.js";
16
+ } from "./chunk-NCK3Y7B7.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-AODPEX3O.js");
23
+ const { NoOpTelemetryClient: NoOpTelemetryClient2 } = await import("./NoOpTelemetryClient-M2CYNHPI.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-ETNBIAWP.js");
30
+ const { AppInsightsTelemetryClient } = await import("./AppInsightsTelemetryClient-VHBDVKM4.js");
31
31
  return new AppInsightsTelemetryClient(options);
32
32
  }
33
33
  __name(createTelemetryClient, "createTelemetryClient");
@@ -1,4 +1,4 @@
1
- import { type AttributeValue, type Span, type Tracer } from '@opentelemetry/api';
1
+ import { type Span, 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';
@@ -6,19 +6,12 @@ import { PerformanceRecorder } from './PerformanceRecorder.js';
6
6
  export declare class BaseTelemetryClient implements TelemetryClient {
7
7
  private readonly _performance;
8
8
  private readonly _rootSpan;
9
- private readonly sharedSpanAttributes;
10
9
  protected readonly _tracerProvider: NodeTracerProvider;
11
10
  constructor(options: TelemetryOptions);
12
11
  /**
13
12
  * Flushes all telemetry and shuts down the telemetry client.
14
13
  */
15
14
  shutdown(): Promise<void>;
16
- /**
17
- * Sets a shared attribute that will be added to all spans.
18
- * @param key - key of the attribute
19
- * @param value - value of the attribute
20
- */
21
- setSharedSpanAttribute(key: string, value: AttributeValue): void;
22
15
  /**
23
16
  * Gets the OpenTelemetry tracer.
24
17
  * @returns the OpenTelemetry tracer
@@ -4,8 +4,8 @@ import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'
4
4
  * Span processor that adds shared attributes to all spans.
5
5
  */
6
6
  export declare class SpanEnrichingProcessor implements SpanProcessor {
7
- private getSharedSpanAttributes;
8
- constructor(getSharedSpanAttributes: () => Attributes);
7
+ private sharedSpanAttributes;
8
+ constructor(sharedSpanAttributes: Attributes);
9
9
  forceFlush(): Promise<void>;
10
10
  shutdown(): Promise<void>;
11
11
  onStart(): void;
@@ -1,16 +1,10 @@
1
- import type { AttributeValue, Span, Tracer } from '@opentelemetry/api';
1
+ import type { Span, Tracer } from '@opentelemetry/api';
2
2
  import type { PerformanceRecorder } from '../PerformanceRecorder.js';
3
3
  export interface TelemetryClient {
4
4
  /**
5
5
  * Root span which measures the duration of the highest level application (ie: CLI)
6
6
  */
7
7
  rootSpan: Span;
8
- /**
9
- * Sets a shared attribute that will be added to all spans.
10
- * @param key - key of the attribute
11
- * @param value - value of the attribute
12
- */
13
- setSharedSpanAttribute(key: string, value: AttributeValue): void;
14
8
  /**
15
9
  * Flushes all telemetry and shuts down the telemetry client.
16
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/telemetry",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Helpers for reporting telemetry in Cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",