@ms-cloudpack/telemetry 0.3.10 → 0.4.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.
Files changed (44) hide show
  1. package/lib/AppInsights/AppInsightsTelemetryClient.d.ts.map +1 -1
  2. package/lib/AppInsights/AppInsightsTelemetryClient.js +1 -0
  3. package/lib/AppInsights/AppInsightsTelemetryClient.js.map +1 -1
  4. package/lib/AppInsights/getAppInsightsConfig.d.ts.map +1 -1
  5. package/lib/AppInsights/getAppInsightsConfig.js +1 -1
  6. package/lib/AppInsights/getAppInsightsConfig.js.map +1 -1
  7. package/lib/MetricEventAggregatorRegistry.d.ts +18 -0
  8. package/lib/MetricEventAggregatorRegistry.d.ts.map +1 -0
  9. package/lib/MetricEventAggregatorRegistry.js +29 -0
  10. package/lib/MetricEventAggregatorRegistry.js.map +1 -0
  11. package/lib/NoOp/NoOpTelemetryClient.d.ts +3 -4
  12. package/lib/NoOp/NoOpTelemetryClient.d.ts.map +1 -1
  13. package/lib/NoOp/NoOpTelemetryClient.js +3 -5
  14. package/lib/NoOp/NoOpTelemetryClient.js.map +1 -1
  15. package/lib/PerformanceRecorder.d.ts +14 -1
  16. package/lib/PerformanceRecorder.d.ts.map +1 -1
  17. package/lib/PerformanceRecorder.js +20 -1
  18. package/lib/PerformanceRecorder.js.map +1 -1
  19. package/lib/createTelemetryClient.js +1 -1
  20. package/lib/createTelemetryClient.js.map +1 -1
  21. package/lib/index.d.ts +2 -0
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js.map +1 -1
  24. package/lib/tsdoc-metadata.json +1 -1
  25. package/lib/types/MetricEvent.d.ts +7 -0
  26. package/lib/types/MetricEvent.d.ts.map +1 -0
  27. package/lib/types/MetricEvent.js +2 -0
  28. package/lib/types/MetricEvent.js.map +1 -0
  29. package/lib/types/MetricEventAggregator.d.ts +6 -0
  30. package/lib/types/MetricEventAggregator.d.ts.map +1 -0
  31. package/lib/types/MetricEventAggregator.js +2 -0
  32. package/lib/types/MetricEventAggregator.js.map +1 -0
  33. package/lib/types/TelemetryOptions.d.ts +2 -2
  34. package/lib/types/TelemetryOptions.d.ts.map +1 -1
  35. package/lib/types/TelemetryOptions.js.map +1 -1
  36. package/package.json +1 -1
  37. package/lib/NoOp/NoOpSpan.d.ts +0 -18
  38. package/lib/NoOp/NoOpSpan.d.ts.map +0 -1
  39. package/lib/NoOp/NoOpSpan.js +0 -44
  40. package/lib/NoOp/NoOpSpan.js.map +0 -1
  41. package/lib/NoOp/NoOpTracer.d.ts +0 -12
  42. package/lib/NoOp/NoOpTracer.d.ts.map +0 -1
  43. package/lib/NoOp/NoOpTracer.js +0 -28
  44. package/lib/NoOp/NoOpTracer.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AppInsightsTelemetryClient.d.ts","sourceRoot":"","sources":["../../src/AppInsights/AppInsightsTelemetryClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAIrE,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAO;IACjC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA8B;IACnE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;gBAExC,OAAO,EAAE,gBAAgB;IAoBrC,IAAW,WAAW,IAAI,mBAAmB,CAE5C;IAED,IAAW,QAAQ,IAAI,IAAI,CAE1B;IAED;;;;OAIG;IACI,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIxD;;OAEG;IACU,QAAQ;IAMrB;;;OAGG;IACI,SAAS,IAAI,MAAM;CAG3B"}
1
+ {"version":3,"file":"AppInsightsTelemetryClient.d.ts","sourceRoot":"","sources":["../../src/AppInsights/AppInsightsTelemetryClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAIrE,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAO;IACjC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA8B;IACnE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;gBAExC,OAAO,EAAE,gBAAgB;IAoBrC,IAAW,WAAW,IAAI,mBAAmB,CAE5C;IAED,IAAW,QAAQ,IAAI,IAAI,CAE1B;IAED;;;;OAIG;IACI,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIxD;;OAEG;IACU,QAAQ;IAOrB;;;OAGG;IACI,SAAS,IAAI,MAAM;CAG3B"}
@@ -36,6 +36,7 @@ export class AppInsightsTelemetryClient {
36
36
  * Flushes all telemetry and shuts down the telemetry client.
37
37
  */
38
38
  async shutdown() {
39
+ this._performance.shutdown();
39
40
  this.rootSpan.end();
40
41
  await this._traceProvider.forceFlush();
41
42
  shutdownAzureMonitor();
@@ -1 +1 @@
1
- {"version":3,"file":"AppInsightsTelemetryClient.js","sourceRoot":"","sources":["../../src/AppInsights/AppInsightsTelemetryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,KAAK,EAAoD,MAAM,oBAAoB,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,0BAA0B;IAMrC,YAAY,OAAyB;QAHpB,yBAAoB,GAA2B,EAAE,CAAC;QAIjE,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAE7C,kDAAkD;QAClD,eAAe,CAAC,MAAM,CAAC,CAAC;QAExB,IAAI,CAAC,cAAc,GAAI,KAAK,CAAC,iBAAiB,EAA0B,CAAC,WAAW,EAAwB,CAAC;QAE7G,wBAAwB;QACxB,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QAE/D,mEAAmE;QACnE,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,sBAAsB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAElG,mBAAmB;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,CAAC;QAE5E,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,GAAW,EAAE,KAAa;QACtD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QACpB,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;QACvC,oBAAoB,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import { shutdownAzureMonitor, useAzureMonitor } from '@azure/monitor-opentelemetry';\nimport { trace, type ProxyTracerProvider, type Span, type Tracer } from '@opentelemetry/api';\nimport type { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { PerformanceRecorder } from '../PerformanceRecorder.js';\nimport type { TelemetryClient } from '../types/TelemetryClient.js';\nimport type { TelemetryOptions } from '../types/TelemetryOptions.js';\nimport { SpanEnrichingProcessor } from './SpanEnrichingProcessor.js';\nimport { getAppInsightsConfig } from './getAppInsightsConfig.js';\n\nexport class AppInsightsTelemetryClient implements TelemetryClient {\n private readonly _performance: PerformanceRecorder;\n private readonly _rootSpan: Span;\n private readonly sharedSpanAttributes: Record<string, string> = {};\n private readonly _traceProvider: NodeTracerProvider;\n\n constructor(options: TelemetryOptions) {\n const config = getAppInsightsConfig(options);\n\n // Set up azure monitor (aka application insights)\n useAzureMonitor(config);\n\n this._traceProvider = (trace.getTracerProvider() as ProxyTracerProvider).getDelegate() as NodeTracerProvider;\n\n // Set shared attributes\n this.setSharedSpanAttribute('version', options.productVersion);\n\n // Set SpanEnrichingProcessor to add shared attributes to all spans\n this._traceProvider.addSpanProcessor(new SpanEnrichingProcessor(() => this.sharedSpanAttributes));\n\n // Create root span\n this._rootSpan = this.getTracer().startSpan(options.rootSpanName || 'root');\n\n this._performance = new PerformanceRecorder(this._rootSpan);\n }\n\n public get performance(): PerformanceRecorder {\n return this._performance;\n }\n\n public get rootSpan(): Span {\n return this._rootSpan;\n }\n\n /**\n * Sets a shared attribute that will be added to all spans.\n * @param key - key of the attribute\n * @param value - value of the attribute\n */\n public setSharedSpanAttribute(key: string, value: string) {\n this.sharedSpanAttributes[key] = value;\n }\n\n /**\n * Flushes all telemetry and shuts down the telemetry client.\n */\n public async shutdown() {\n this.rootSpan.end();\n await this._traceProvider.forceFlush();\n shutdownAzureMonitor();\n }\n\n /**\n * Gets the OpenTelemetry tracer.\n * @returns the OpenTelemetry tracer\n */\n public getTracer(): Tracer {\n return trace.getTracer('cloudpack-tracer');\n }\n}\n"]}
1
+ {"version":3,"file":"AppInsightsTelemetryClient.js","sourceRoot":"","sources":["../../src/AppInsights/AppInsightsTelemetryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,KAAK,EAAoD,MAAM,oBAAoB,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,0BAA0B;IAMrC,YAAY,OAAyB;QAHpB,yBAAoB,GAA2B,EAAE,CAAC;QAIjE,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAE7C,kDAAkD;QAClD,eAAe,CAAC,MAAM,CAAC,CAAC;QAExB,IAAI,CAAC,cAAc,GAAI,KAAK,CAAC,iBAAiB,EAA0B,CAAC,WAAW,EAAwB,CAAC;QAE7G,wBAAwB;QACxB,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QAE/D,mEAAmE;QACnE,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,sBAAsB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAElG,mBAAmB;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,CAAC;QAE5E,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,GAAW,EAAE,KAAa;QACtD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QACpB,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;QACvC,oBAAoB,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import { shutdownAzureMonitor, useAzureMonitor } from '@azure/monitor-opentelemetry';\nimport { trace, type ProxyTracerProvider, type Span, type Tracer } from '@opentelemetry/api';\nimport type { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { PerformanceRecorder } from '../PerformanceRecorder.js';\nimport type { TelemetryClient } from '../types/TelemetryClient.js';\nimport type { TelemetryOptions } from '../types/TelemetryOptions.js';\nimport { SpanEnrichingProcessor } from './SpanEnrichingProcessor.js';\nimport { getAppInsightsConfig } from './getAppInsightsConfig.js';\n\nexport class AppInsightsTelemetryClient implements TelemetryClient {\n private readonly _performance: PerformanceRecorder;\n private readonly _rootSpan: Span;\n private readonly sharedSpanAttributes: Record<string, string> = {};\n private readonly _traceProvider: NodeTracerProvider;\n\n constructor(options: TelemetryOptions) {\n const config = getAppInsightsConfig(options);\n\n // Set up azure monitor (aka application insights)\n useAzureMonitor(config);\n\n this._traceProvider = (trace.getTracerProvider() as ProxyTracerProvider).getDelegate() as NodeTracerProvider;\n\n // Set shared attributes\n this.setSharedSpanAttribute('version', options.productVersion);\n\n // Set SpanEnrichingProcessor to add shared attributes to all spans\n this._traceProvider.addSpanProcessor(new SpanEnrichingProcessor(() => this.sharedSpanAttributes));\n\n // Create root span\n this._rootSpan = this.getTracer().startSpan(options.rootSpanName || 'root');\n\n this._performance = new PerformanceRecorder(this._rootSpan);\n }\n\n public get performance(): PerformanceRecorder {\n return this._performance;\n }\n\n public get rootSpan(): Span {\n return this._rootSpan;\n }\n\n /**\n * Sets a shared attribute that will be added to all spans.\n * @param key - key of the attribute\n * @param value - value of the attribute\n */\n public setSharedSpanAttribute(key: string, value: string) {\n this.sharedSpanAttributes[key] = value;\n }\n\n /**\n * Flushes all telemetry and shuts down the telemetry client.\n */\n public async shutdown() {\n this._performance.shutdown();\n this.rootSpan.end();\n await this._traceProvider.forceFlush();\n shutdownAzureMonitor();\n }\n\n /**\n * Gets the OpenTelemetry tracer.\n * @returns the OpenTelemetry tracer\n */\n public getTracer(): Tracer {\n return trace.getTracer('cloudpack-tracer');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getAppInsightsConfig.d.ts","sourceRoot":"","sources":["../../src/AppInsights/getAppInsightsConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAGrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AASrE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,oCAuB7D"}
1
+ {"version":3,"file":"getAppInsightsConfig.d.ts","sourceRoot":"","sources":["../../src/AppInsights/getAppInsightsConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAGrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AASrE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,oCAsB7D"}
@@ -10,7 +10,7 @@ function sha256(input) {
10
10
  export function getAppInsightsConfig(options) {
11
11
  const config = {
12
12
  azureMonitorExporterOptions: {
13
- connectionString: 'InstrumentationKey=d512a3ac-e644-47b8-895a-4a9a25778aaf;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com',
13
+ connectionString: options.connectionString,
14
14
  },
15
15
  instrumentationOptions: {
16
16
  http: {
@@ -1 +1 @@
1
- {"version":3,"file":"getAppInsightsConfig.js","sourceRoot":"","sources":["../../src/AppInsights/getAppInsightsConfig.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,mBAAmB,MAAM,qCAAqC,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;AAC/B,MAAM,EAAE,0BAA0B,EAAE,GAAG,mBAAmB,CAAC;AAE3D,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAyB;IAC5D,MAAM,MAAM,GAAqC;QAC/C,2BAA2B,EAAE;YAC3B,gBAAgB,EACd,6HAA6H;SAChI;QACD,sBAAsB,EAAE;YACtB,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;aACf;YACD,QAAQ,EAAE;gBACR,OAAO,EAAE,KAAK;aACf;SACF;QACD,QAAQ,EAAE,IAAI,QAAQ,CAAC;YACrB,+CAA+C;YAC/C,CAAC,0BAA0B,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3E,CAAC,0BAA0B,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW;YAC9D,CAAC,0BAA0B,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB;SACzE,CAAC;KACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import Resources from '@opentelemetry/resources';\nimport SemanticConventions from '@opentelemetry/semantic-conventions';\nimport type { AzureMonitorOpenTelemetryOptions } from '@azure/monitor-opentelemetry';\nimport { createHash } from 'crypto';\nimport { getComputerName } from './getComputerName.js';\nimport type { TelemetryOptions } from '../types/TelemetryOptions.js';\n\nconst { Resource } = Resources;\nconst { SemanticResourceAttributes } = SemanticConventions;\n\nfunction sha256(input: string) {\n return createHash('sha256').update(input).digest('hex');\n}\n\nexport function getAppInsightsConfig(options: TelemetryOptions) {\n const config: AzureMonitorOpenTelemetryOptions = {\n azureMonitorExporterOptions: {\n connectionString:\n 'InstrumentationKey=d512a3ac-e644-47b8-895a-4a9a25778aaf;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com',\n },\n instrumentationOptions: {\n http: {\n enabled: false,\n },\n azureSdk: {\n enabled: false,\n },\n },\n resource: new Resource({\n // Use a hash of the computer name to avoid PII\n [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: sha256(getComputerName()),\n [SemanticResourceAttributes.SERVICE_NAME]: options.serviceName,\n [SemanticResourceAttributes.SERVICE_NAMESPACE]: options.serviceNamespace,\n }),\n };\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"getAppInsightsConfig.js","sourceRoot":"","sources":["../../src/AppInsights/getAppInsightsConfig.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,mBAAmB,MAAM,qCAAqC,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;AAC/B,MAAM,EAAE,0BAA0B,EAAE,GAAG,mBAAmB,CAAC;AAE3D,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAyB;IAC5D,MAAM,MAAM,GAAqC;QAC/C,2BAA2B,EAAE;YAC3B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C;QACD,sBAAsB,EAAE;YACtB,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;aACf;YACD,QAAQ,EAAE;gBACR,OAAO,EAAE,KAAK;aACf;SACF;QACD,QAAQ,EAAE,IAAI,QAAQ,CAAC;YACrB,+CAA+C;YAC/C,CAAC,0BAA0B,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3E,CAAC,0BAA0B,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW;YAC9D,CAAC,0BAA0B,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB;SACzE,CAAC;KACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import Resources from '@opentelemetry/resources';\nimport SemanticConventions from '@opentelemetry/semantic-conventions';\nimport type { AzureMonitorOpenTelemetryOptions } from '@azure/monitor-opentelemetry';\nimport { createHash } from 'crypto';\nimport { getComputerName } from './getComputerName.js';\nimport type { TelemetryOptions } from '../types/TelemetryOptions.js';\n\nconst { Resource } = Resources;\nconst { SemanticResourceAttributes } = SemanticConventions;\n\nfunction sha256(input: string) {\n return createHash('sha256').update(input).digest('hex');\n}\n\nexport function getAppInsightsConfig(options: TelemetryOptions) {\n const config: AzureMonitorOpenTelemetryOptions = {\n azureMonitorExporterOptions: {\n connectionString: options.connectionString,\n },\n instrumentationOptions: {\n http: {\n enabled: false,\n },\n azureSdk: {\n enabled: false,\n },\n },\n resource: new Resource({\n // Use a hash of the computer name to avoid PII\n [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: sha256(getComputerName()),\n [SemanticResourceAttributes.SERVICE_NAME]: options.serviceName,\n [SemanticResourceAttributes.SERVICE_NAMESPACE]: options.serviceNamespace,\n }),\n };\n\n return config;\n}\n"]}
@@ -0,0 +1,18 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricEventAggregatorRegistry.d.ts","sourceRoot":"","sources":["../src/MetricEventAggregatorRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE9E,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6C;IAE1E;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAQhD;;;OAGG;IACH,mBAAmB,IAAI,WAAW,EAAE;CAQrC"}
@@ -0,0 +1,29 @@
1
+ export class MetricEventAggregatorRegistry {
2
+ constructor() {
3
+ this._aggregators = new Set();
4
+ }
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(aggregator) {
12
+ if (!this._aggregators.has(aggregator)) {
13
+ this._aggregators.add(aggregator);
14
+ }
15
+ return aggregator;
16
+ }
17
+ /**
18
+ * Gets all the aggregated events from all the registered aggregators.
19
+ * @returns The aggregated events.
20
+ */
21
+ getAggregatedEvents() {
22
+ const events = [];
23
+ for (const aggregator of this._aggregators) {
24
+ events.push(...aggregator.getAggregatedEvents());
25
+ }
26
+ return events;
27
+ }
28
+ }
29
+ //# sourceMappingURL=MetricEventAggregatorRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricEventAggregatorRegistry.js","sourceRoot":"","sources":["../src/MetricEventAggregatorRegistry.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,6BAA6B;IAA1C;QACmB,iBAAY,GAAG,IAAI,GAAG,EAAkC,CAAC;IA4B5E,CAAC;IA1BC;;;;;OAKG;IACH,QAAQ,CAAI,UAAoC;QAC9C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACtC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SACnC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,mBAAmB;QACjB,MAAM,MAAM,GAAkB,EAAE,CAAC;QACjC,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE;YAC1C,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;SAClD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import type { MetricEvent } from './types/MetricEvent.js';\nimport type { MetricEventAggregator } from './types/MetricEventAggregator.js';\n\nexport class MetricEventAggregatorRegistry {\n private readonly _aggregators = new Set<MetricEventAggregator<unknown>>();\n\n /**\n * Registers a new aggregator. If an aggregator already exists, it will be return the aggregator.\n * @param name - The name of the metric.\n * @param aggregate - The aggregator function.\n * @returns The aggregator that is passed in.\n */\n register<T>(aggregator: MetricEventAggregator<T>) {\n if (!this._aggregators.has(aggregator)) {\n this._aggregators.add(aggregator);\n }\n\n return aggregator;\n }\n\n /**\n * Gets all the aggregated events from all the registered aggregators.\n * @returns The aggregated events.\n */\n getAggregatedEvents(): MetricEvent[] {\n const events: MetricEvent[] = [];\n for (const aggregator of this._aggregators) {\n events.push(...aggregator.getAggregatedEvents());\n }\n\n return events;\n }\n}\n"]}
@@ -1,6 +1,5 @@
1
- import type { Span } from '@opentelemetry/api';
1
+ import { type Span } from '@opentelemetry/api';
2
2
  import type { TelemetryClient } from '../types/TelemetryClient.js';
3
- import { NoOpTracer } from './NoOpTracer.js';
4
3
  import { PerformanceRecorder } from '../PerformanceRecorder.js';
5
4
  /**
6
5
  * No-op implementation of {@link TelemetryClient}.
@@ -9,9 +8,9 @@ import { PerformanceRecorder } from '../PerformanceRecorder.js';
9
8
  export declare class NoOpTelemetryClient implements TelemetryClient {
10
9
  readonly rootSpan: Span;
11
10
  readonly performance: PerformanceRecorder;
12
- private tracer;
11
+ constructor();
13
12
  setSharedSpanAttribute(): TelemetryClient;
14
13
  shutdown(): Promise<void>;
15
- getTracer(): NoOpTracer;
14
+ getTracer(): import("@opentelemetry/api").Tracer;
16
15
  }
17
16
  //# sourceMappingURL=NoOpTelemetryClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoOpTelemetryClient.d.ts","sourceRoot":"","sources":["../../src/NoOp/NoOpTelemetryClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACzD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAkB;IACzC,QAAQ,CAAC,WAAW,sBAA0C;IAC9D,OAAO,CAAC,MAAM,CAAoB;IAElC,sBAAsB,IAAI,eAAe;IAKzC,QAAQ;IAKR,SAAS;CAGV"}
1
+ {"version":3,"file":"NoOpTelemetryClient.d.ts","sourceRoot":"","sources":["../../src/NoOp/NoOpTelemetryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAS,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACzD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;;IAO1C,sBAAsB,IAAI,eAAe;IAKzC,QAAQ;IAKR,SAAS;CAGV"}
@@ -1,5 +1,4 @@
1
- import { NoOpTracer } from './NoOpTracer.js';
2
- import { NoOpSpan } from './NoOpSpan.js';
1
+ import { trace } from '@opentelemetry/api';
3
2
  import { PerformanceRecorder } from '../PerformanceRecorder.js';
4
3
  /**
5
4
  * No-op implementation of {@link TelemetryClient}.
@@ -7,9 +6,8 @@ import { PerformanceRecorder } from '../PerformanceRecorder.js';
7
6
  */
8
7
  export class NoOpTelemetryClient {
9
8
  constructor() {
10
- this.rootSpan = new NoOpSpan();
9
+ this.rootSpan = this.getTracer().startSpan('no-op');
11
10
  this.performance = new PerformanceRecorder(this.rootSpan);
12
- this.tracer = new NoOpTracer();
13
11
  }
14
12
  setSharedSpanAttribute() {
15
13
  // No-op
@@ -20,7 +18,7 @@ export class NoOpTelemetryClient {
20
18
  return Promise.resolve();
21
19
  }
22
20
  getTracer() {
23
- return this.tracer;
21
+ return trace.getTracer('no-op');
24
22
  }
25
23
  }
26
24
  //# sourceMappingURL=NoOpTelemetryClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoOpTelemetryClient.js","sourceRoot":"","sources":["../../src/NoOp/NoOpTelemetryClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACW,aAAQ,GAAS,IAAI,QAAQ,EAAE,CAAC;QAChC,gBAAW,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtD,WAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAepC,CAAC;IAbC,sBAAsB;QACpB,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,QAAQ;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { TelemetryClient } from '../types/TelemetryClient.js';\nimport { NoOpTracer } from './NoOpTracer.js';\nimport { NoOpSpan } from './NoOpSpan.js';\nimport { PerformanceRecorder } from '../PerformanceRecorder.js';\n\n/**\n * No-op implementation of {@link TelemetryClient}.\n * This class will be used when Telemetry is disabled.\n */\nexport class NoOpTelemetryClient implements TelemetryClient {\n readonly rootSpan: Span = new NoOpSpan();\n readonly performance = new PerformanceRecorder(this.rootSpan);\n private tracer = new NoOpTracer();\n\n setSharedSpanAttribute(): TelemetryClient {\n // No-op\n return this;\n }\n\n shutdown() {\n // No-op\n return Promise.resolve();\n }\n\n getTracer() {\n return this.tracer;\n }\n}\n"]}
1
+ {"version":3,"file":"NoOpTelemetryClient.js","sourceRoot":"","sources":["../../src/NoOp/NoOpTelemetryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAI9B;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,sBAAsB;QACpB,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,QAAQ;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,SAAS;QACP,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["import { type Span, trace } from '@opentelemetry/api';\nimport type { TelemetryClient } from '../types/TelemetryClient.js';\nimport { PerformanceRecorder } from '../PerformanceRecorder.js';\n\n/**\n * No-op implementation of {@link TelemetryClient}.\n * This class will be used when Telemetry is disabled.\n */\nexport class NoOpTelemetryClient implements TelemetryClient {\n readonly rootSpan: Span;\n readonly performance: PerformanceRecorder;\n\n constructor() {\n this.rootSpan = this.getTracer().startSpan('no-op');\n this.performance = new PerformanceRecorder(this.rootSpan);\n }\n\n setSharedSpanAttribute(): TelemetryClient {\n // No-op\n return this;\n }\n\n shutdown() {\n // No-op\n return Promise.resolve();\n }\n\n getTracer() {\n return trace.getTracer('no-op');\n }\n}\n"]}
@@ -1,12 +1,21 @@
1
1
  import type { Span } from '@opentelemetry/api';
2
- import type { SpanAttributes } from './types/SpanAttributes.js';
3
2
  import type { PerformanceTracker } from './types/PerformanceTracker.js';
3
+ import type { SpanAttributes } from './types/SpanAttributes.js';
4
+ import type { MetricEventAggregator } from './types/MetricEventAggregator.js';
4
5
  /**
5
6
  * PerformanceRecorder is a utility class for recording performance metrics into telemetry.
6
7
  */
7
8
  export declare class PerformanceRecorder {
8
9
  private readonly span;
10
+ private readonly _metricEventAggregatorRegistry;
9
11
  constructor(span: Span);
12
+ /**
13
+ * Registers a new aggregator for a given metric.
14
+ * If an aggregator already exists, it will be skipped.
15
+ * @param name - The name of the metric.
16
+ * @param aggregator - The aggregator function.
17
+ */
18
+ registerAggregator<T>(aggregator: MetricEventAggregator<T>): MetricEventAggregator<T>;
10
19
  /**
11
20
  * Records a performance metric into telemetry. The metric will be recorded as an event on the span and logged to the console.
12
21
  * 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.
@@ -24,5 +33,9 @@ export declare class PerformanceRecorder {
24
33
  * @returns - The result of the `execute` function.
25
34
  */
26
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;
27
40
  }
28
41
  //# sourceMappingURL=PerformanceRecorder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PerformanceRecorder.d.ts","sourceRoot":"","sources":["../src/PerformanceRecorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE;;GAEG;AACH,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI;IAEvC;;;;OAIG;IACH,MAAM,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,oBAAoB,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAMhG;;;;;OAKG;IACG,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAqB/F"}
1
+ {"version":3,"file":"PerformanceRecorder.d.ts","sourceRoot":"","sources":["../src/PerformanceRecorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE9E;;GAEG;AACH,qBAAa,mBAAmB;IAGlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAuC;gBAEzD,IAAI,EAAE,IAAI;IAEvC;;;;;OAKG;IACH,kBAAkB,CAAC,CAAC,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAI1D;;;;OAIG;IACH,MAAM,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,oBAAoB,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAMhG;;;;;OAKG;IACG,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAsB9F;;OAEG;IACH,QAAQ,IAAI,IAAI;CAKjB"}
@@ -1,10 +1,21 @@
1
1
  import { performance } from 'perf_hooks';
2
+ import { MetricEventAggregatorRegistry } from './MetricEventAggregatorRegistry.js';
2
3
  /**
3
4
  * PerformanceRecorder is a utility class for recording performance metrics into telemetry.
4
5
  */
5
6
  export class PerformanceRecorder {
6
7
  constructor(span) {
7
8
  this.span = span;
9
+ this._metricEventAggregatorRegistry = new MetricEventAggregatorRegistry();
10
+ }
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(aggregator) {
18
+ return this._metricEventAggregatorRegistry.register(aggregator);
8
19
  }
9
20
  /**
10
21
  * Records a performance metric into telemetry. The metric will be recorded as an event on the span and logged to the console.
@@ -14,7 +25,7 @@ export class PerformanceRecorder {
14
25
  record(attributes) {
15
26
  const { name, value, additionalProperties = {} } = attributes;
16
27
  this.span.addEvent('Performance-Metric', { ...additionalProperties, name, value });
17
- console.debug(`Performance-Metric: ${name} ${value} ms`);
28
+ console.debug(`Performance-Metric: ${name} ${value}`);
18
29
  }
19
30
  /**
20
31
  * Tracks the execution time of a given `execute` function and report it to telemetry.
@@ -38,5 +49,13 @@ export class PerformanceRecorder {
38
49
  this.record({ name, value: performance.now() - startTime, additionalProperties });
39
50
  return result;
40
51
  }
52
+ /**
53
+ * Shuts down the performance recorder and records any aggregated events.
54
+ */
55
+ shutdown() {
56
+ for (const { name, value, attributes } of this._metricEventAggregatorRegistry.getAggregatedEvents()) {
57
+ this.record({ name, value, additionalProperties: attributes });
58
+ }
59
+ }
41
60
  }
42
61
  //# sourceMappingURL=PerformanceRecorder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PerformanceRecorder.js","sourceRoot":"","sources":["../src/PerformanceRecorder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC9B,YAA6B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAE3C;;;;OAIG;IACH,MAAM,CAAC,UAAkF;QACvF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC;QAC9D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,EAAE,GAAG,oBAAoB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,KAAK,CAAC,uBAAuB,IAAI,IAAI,KAAK,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAI,IAAY,EAAE,OAAoD;QAC/E,MAAM,oBAAoB,GAAmB,EAAE,CAAC;QAEhD,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAEpC,MAAM,OAAO,GAAuB;YAClC,IAAI;YACJ,SAAS;YACT,aAAa,EAAE,CAAC,UAA0B,EAAE,EAAE;gBAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;oBACrD,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBACnC;YACH,CAAC;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAElF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { performance } from 'perf_hooks';\nimport type { SpanAttributes } from './types/SpanAttributes.js';\nimport type { PerformanceTracker } from './types/PerformanceTracker.js';\n\n/**\n * PerformanceRecorder is a utility class for recording performance metrics into telemetry.\n */\nexport class PerformanceRecorder {\n constructor(private readonly span: Span) {}\n\n /**\n * Records a performance metric into telemetry. The metric will be recorded as an event on the span and logged to the console.\n * 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.\n * @param attributes\n */\n record(attributes: { name: string; value: number; additionalProperties?: SpanAttributes }): void {\n const { name, value, additionalProperties = {} } = attributes;\n this.span.addEvent('Performance-Metric', { ...additionalProperties, name, value });\n console.debug(`Performance-Metric: ${name} ${value} ms`);\n }\n\n /**\n * Tracks the execution time of a given `execute` function and report it to telemetry.\n * @param name - The name of the performance metric.\n * @param execute - The function to execute and track.\n * @returns - The result of the `execute` function.\n */\n async track<T>(name: string, execute: (tracker: PerformanceTracker) => Promise<T>): Promise<T> {\n const additionalProperties: SpanAttributes = {};\n\n const startTime = performance.now();\n\n const tracker: PerformanceTracker = {\n name,\n startTime,\n setProperties: (properties: SpanAttributes) => {\n for (const [key, value] of Object.entries(properties)) {\n additionalProperties[key] = value;\n }\n },\n };\n\n const result = await execute(tracker);\n\n this.record({ name, value: performance.now() - startTime, additionalProperties });\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"PerformanceRecorder.js","sourceRoot":"","sources":["../src/PerformanceRecorder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAKnF;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAG9B,YAA6B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QAFtB,mCAA8B,GAAG,IAAI,6BAA6B,EAAE,CAAC;IAE5C,CAAC;IAE3C;;;;;OAKG;IACH,kBAAkB,CAAI,UAAoC;QACxD,OAAO,IAAI,CAAC,8BAA8B,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAkF;QACvF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC;QAC9D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,EAAE,GAAG,oBAAoB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,KAAK,CAAC,uBAAuB,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAI,IAAY,EAAE,OAAoD;QAC/E,MAAM,oBAAoB,GAAmB,EAAE,CAAC;QAEhD,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAEpC,MAAM,OAAO,GAAuB;YAClC,IAAI;YACJ,SAAS;YACT,aAAa,EAAE,CAAC,UAA0B,EAAE,EAAE;gBAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;oBACrD,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBACnC;YACH,CAAC;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAElF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC,8BAA8B,CAAC,mBAAmB,EAAE,EAAE;YACnG,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,CAAC,CAAC;SAChE;IACH,CAAC;CACF","sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { performance } from 'perf_hooks';\nimport { MetricEventAggregatorRegistry } from './MetricEventAggregatorRegistry.js';\nimport type { PerformanceTracker } from './types/PerformanceTracker.js';\nimport type { SpanAttributes } from './types/SpanAttributes.js';\nimport type { MetricEventAggregator } from './types/MetricEventAggregator.js';\n\n/**\n * PerformanceRecorder is a utility class for recording performance metrics into telemetry.\n */\nexport class PerformanceRecorder {\n private readonly _metricEventAggregatorRegistry = new MetricEventAggregatorRegistry();\n\n constructor(private readonly span: Span) {}\n\n /**\n * Registers a new aggregator for a given metric.\n * If an aggregator already exists, it will be skipped.\n * @param name - The name of the metric.\n * @param aggregator - The aggregator function.\n */\n registerAggregator<T>(aggregator: MetricEventAggregator<T>) {\n return this._metricEventAggregatorRegistry.register(aggregator);\n }\n\n /**\n * Records a performance metric into telemetry. The metric will be recorded as an event on the span and logged to the console.\n * 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.\n * @param attributes\n */\n record(attributes: { name: string; value: number; additionalProperties?: SpanAttributes }): void {\n const { name, value, additionalProperties = {} } = attributes;\n this.span.addEvent('Performance-Metric', { ...additionalProperties, name, value });\n console.debug(`Performance-Metric: ${name} ${value}`);\n }\n\n /**\n * Tracks the execution time of a given `execute` function and report it to telemetry.\n * @param name - The name of the performance metric.\n * @param execute - The function to execute and track.\n * @returns - The result of the `execute` function.\n */\n async track<T>(name: string, execute: (tracker: PerformanceTracker) => Promise<T>): Promise<T> {\n const additionalProperties: SpanAttributes = {};\n\n const startTime = performance.now();\n\n const tracker: PerformanceTracker = {\n name,\n startTime,\n setProperties: (properties: SpanAttributes) => {\n for (const [key, value] of Object.entries(properties)) {\n additionalProperties[key] = value;\n }\n },\n };\n\n const result = await execute(tracker);\n\n this.record({ name, value: performance.now() - startTime, additionalProperties });\n\n return result;\n }\n\n /**\n * Shuts down the performance recorder and records any aggregated events.\n */\n shutdown(): void {\n for (const { name, value, attributes } of this._metricEventAggregatorRegistry.getAggregatedEvents()) {\n this.record({ name, value, additionalProperties: attributes });\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export async function createTelemetryClient(options) {
2
- if (!options.instrumentationKey) {
2
+ if (!options.connectionString) {
3
3
  console.debug('No connection string found. Telemetry will not be sent.');
4
4
  // Create a no-op telemetry client if no instrumentation key is provided
5
5
  const { NoOpTelemetryClient } = await import('./NoOp/NoOpTelemetryClient.js');
@@ -1 +1 @@
1
- {"version":3,"file":"createTelemetryClient.js","sourceRoot":"","sources":["../src/createTelemetryClient.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAyB;IACnE,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAEzE,wEAAwE;QACxE,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;QAC9E,OAAO,IAAI,mBAAmB,EAAE,CAAC;KAClC;IAED,0EAA0E;IAC1E,OAAO,CAAC,GAAG,CAAC,iDAAiD,GAAG,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC;IAE3F,yDAAyD;IACzD,MAAM,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CAAC,6CAA6C,CAAC,CAAC;IACnG,OAAO,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import type { TelemetryOptions } from './types/TelemetryOptions.js';\nimport type { TelemetryClient } from './types/TelemetryClient.js';\n\nexport async function createTelemetryClient(options: TelemetryOptions): Promise<TelemetryClient> {\n if (!options.instrumentationKey) {\n console.debug('No connection string found. Telemetry will not be sent.');\n\n // Create a no-op telemetry client if no instrumentation key is provided\n const { NoOpTelemetryClient } = await import('./NoOp/NoOpTelemetryClient.js');\n return new NoOpTelemetryClient();\n }\n\n // Set initial log level to WARN to avoid logging telemetry initialization\n process.env.APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL = options.logLevel || 'WARN';\n\n // Import TelemetryClient after setting initial log level\n const { AppInsightsTelemetryClient } = await import('./AppInsights/AppInsightsTelemetryClient.js');\n return new AppInsightsTelemetryClient(options);\n}\n"]}
1
+ {"version":3,"file":"createTelemetryClient.js","sourceRoot":"","sources":["../src/createTelemetryClient.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAyB;IACnE,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAC7B,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAEzE,wEAAwE;QACxE,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;QAC9E,OAAO,IAAI,mBAAmB,EAAE,CAAC;KAClC;IAED,0EAA0E;IAC1E,OAAO,CAAC,GAAG,CAAC,iDAAiD,GAAG,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC;IAE3F,yDAAyD;IACzD,MAAM,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CAAC,6CAA6C,CAAC,CAAC;IACnG,OAAO,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import type { TelemetryOptions } from './types/TelemetryOptions.js';\nimport type { TelemetryClient } from './types/TelemetryClient.js';\n\nexport async function createTelemetryClient(options: TelemetryOptions): Promise<TelemetryClient> {\n if (!options.connectionString) {\n console.debug('No connection string found. Telemetry will not be sent.');\n\n // Create a no-op telemetry client if no instrumentation key is provided\n const { NoOpTelemetryClient } = await import('./NoOp/NoOpTelemetryClient.js');\n return new NoOpTelemetryClient();\n }\n\n // Set initial log level to WARN to avoid logging telemetry initialization\n process.env.APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL = options.logLevel || 'WARN';\n\n // Import TelemetryClient after setting initial log level\n const { AppInsightsTelemetryClient } = await import('./AppInsights/AppInsightsTelemetryClient.js');\n return new AppInsightsTelemetryClient(options);\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -7,4 +7,6 @@ export { createNoOpTelemetryClient } from './createNoOpTelemetryClient.js';
7
7
  export type { PerformanceTracker } from './types/PerformanceTracker.js';
8
8
  export type { SpanAttributes } from './types/SpanAttributes.js';
9
9
  export type { PerformanceRecorder } from './PerformanceRecorder.js';
10
+ export type { MetricEvent } from './types/MetricEvent.js';
11
+ export type { MetricEventAggregator } from './types/MetricEventAggregator.js';
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAInE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["export type { Span, Tracer } from '@opentelemetry/api';\nexport { createTelemetryClient } from './createTelemetryClient.js';\nexport type { LogLevel } from './types/LogLevel.js';\nexport type { TelemetryClient } from './types/TelemetryClient.js';\nexport type { TelemetryOptions } from './types/TelemetryOptions.js';\nexport { createNoOpTelemetryClient } from './createNoOpTelemetryClient.js';\nexport type { PerformanceTracker } from './types/PerformanceTracker.js';\nexport type { SpanAttributes } from './types/SpanAttributes.js';\nexport type { PerformanceRecorder } from './PerformanceRecorder.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAInE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["export type { Span, Tracer } from '@opentelemetry/api';\nexport { createTelemetryClient } from './createTelemetryClient.js';\nexport type { LogLevel } from './types/LogLevel.js';\nexport type { TelemetryClient } from './types/TelemetryClient.js';\nexport type { TelemetryOptions } from './types/TelemetryOptions.js';\nexport { createNoOpTelemetryClient } from './createNoOpTelemetryClient.js';\nexport type { PerformanceTracker } from './types/PerformanceTracker.js';\nexport type { SpanAttributes } from './types/SpanAttributes.js';\nexport type { PerformanceRecorder } from './PerformanceRecorder.js';\nexport type { MetricEvent } from './types/MetricEvent.js';\nexport type { MetricEventAggregator } from './types/MetricEventAggregator.js';\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.36.4"
8
+ "packageVersion": "7.37.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,7 @@
1
+ import type { SpanAttributes } from './SpanAttributes.js';
2
+ export interface MetricEvent {
3
+ attributes?: SpanAttributes;
4
+ value: number;
5
+ name: string;
6
+ }
7
+ //# sourceMappingURL=MetricEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricEvent.d.ts","sourceRoot":"","sources":["../../src/types/MetricEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MetricEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricEvent.js","sourceRoot":"","sources":["../../src/types/MetricEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanAttributes } from './SpanAttributes.js';\n\nexport interface MetricEvent {\n attributes?: SpanAttributes;\n value: number;\n name: string;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { MetricEvent } from '../index.js';
2
+ export interface MetricEventAggregator<T> {
3
+ record(event: T): void;
4
+ getAggregatedEvents(): MetricEvent[];
5
+ }
6
+ //# sourceMappingURL=MetricEventAggregator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricEventAggregator.d.ts","sourceRoot":"","sources":["../../src/types/MetricEventAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACvB,mBAAmB,IAAI,WAAW,EAAE,CAAC;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MetricEventAggregator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricEventAggregator.js","sourceRoot":"","sources":["../../src/types/MetricEventAggregator.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetricEvent } from '../index.js';\n\nexport interface MetricEventAggregator<T> {\n record(event: T): void;\n getAggregatedEvents(): MetricEvent[];\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import type { LogLevel } from './LogLevel.js';
2
2
  export interface TelemetryOptions {
3
3
  /**
4
- * The instrumentation key for the Application Insights.
4
+ * The connection string for the Application Insights.
5
5
  */
6
- instrumentationKey?: string;
6
+ connectionString?: string;
7
7
  /**
8
8
  * The log level for the telemetry client.
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TelemetryOptions.d.ts","sourceRoot":"","sources":["../../src/types/TelemetryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"TelemetryOptions.d.ts","sourceRoot":"","sources":["../../src/types/TelemetryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"TelemetryOptions.js","sourceRoot":"","sources":["../../src/types/TelemetryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { LogLevel } from './LogLevel.js';\n\nexport interface TelemetryOptions {\n /**\n * The instrumentation key for the Application Insights.\n */\n instrumentationKey?: string;\n\n /**\n * The log level for the telemetry client.\n */\n logLevel?: LogLevel;\n\n /**\n * The version of the product. This will be added as a shared attribute to all spans.\n */\n productVersion: string;\n\n /**\n * A string value having a meaning that helps to distinguish a group of services, for example the team name that owns a group of services.\n * Possible values: cloudpack, cloudpack.services, etc.\n */\n serviceNamespace: string;\n\n /**\n * Logic name of the service\n * Possible values: cli, bundler-service, etc.\n */\n serviceName: string;\n\n /**\n * Name of the root span, 'root' will be used as a span name if this property is not set.\n */\n rootSpanName?: string;\n}\n"]}
1
+ {"version":3,"file":"TelemetryOptions.js","sourceRoot":"","sources":["../../src/types/TelemetryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { LogLevel } from './LogLevel.js';\n\nexport interface TelemetryOptions {\n /**\n * The connection string for the Application Insights.\n */\n connectionString?: string;\n\n /**\n * The log level for the telemetry client.\n */\n logLevel?: LogLevel;\n\n /**\n * The version of the product. This will be added as a shared attribute to all spans.\n */\n productVersion: string;\n\n /**\n * A string value having a meaning that helps to distinguish a group of services, for example the team name that owns a group of services.\n * Possible values: cloudpack, cloudpack.services, etc.\n */\n serviceNamespace: string;\n\n /**\n * Logic name of the service\n * Possible values: cli, bundler-service, etc.\n */\n serviceName: string;\n\n /**\n * Name of the root span, 'root' will be used as a span name if this property is not set.\n */\n rootSpanName?: string;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/telemetry",
3
- "version": "0.3.10",
3
+ "version": "0.4.1",
4
4
  "description": "Helpers for logging tasks to the console.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,18 +0,0 @@
1
- import type { Span, SpanContext } from '@opentelemetry/api';
2
- /**
3
- * No-op implementation of {@link Span}.
4
- * This class will be used when Telemetry is disabled.
5
- * @internal
6
- */
7
- export declare class NoOpSpan implements Span {
8
- spanContext(): SpanContext;
9
- setAttribute(): this;
10
- setAttributes(): this;
11
- addEvent(): this;
12
- setStatus(): this;
13
- updateName(): this;
14
- end(): void;
15
- isRecording(): boolean;
16
- recordException(): void;
17
- }
18
- //# sourceMappingURL=NoOpSpan.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoOpSpan.d.ts","sourceRoot":"","sources":["../../src/NoOp/NoOpSpan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,QAAS,YAAW,IAAI;IACnC,WAAW,IAAI,WAAW;IAQ1B,YAAY,IAAI,IAAI;IAKpB,aAAa,IAAI,IAAI;IAKrB,QAAQ,IAAI,IAAI;IAKhB,SAAS,IAAI,IAAI;IAKjB,UAAU,IAAI,IAAI;IAKlB,GAAG,IAAI,IAAI;IAIX,WAAW,IAAI,OAAO;IAItB,eAAe,IAAI,IAAI;CAGxB"}
@@ -1,44 +0,0 @@
1
- /**
2
- * No-op implementation of {@link Span}.
3
- * This class will be used when Telemetry is disabled.
4
- * @internal
5
- */
6
- export class NoOpSpan {
7
- spanContext() {
8
- return {
9
- spanId: '',
10
- traceFlags: 0,
11
- traceId: '',
12
- };
13
- }
14
- setAttribute() {
15
- // no-op
16
- return this;
17
- }
18
- setAttributes() {
19
- // no-op
20
- return this;
21
- }
22
- addEvent() {
23
- // no-op
24
- return this;
25
- }
26
- setStatus() {
27
- // no-op
28
- return this;
29
- }
30
- updateName() {
31
- // no-op
32
- return this;
33
- }
34
- end() {
35
- // no-op
36
- }
37
- isRecording() {
38
- return false;
39
- }
40
- recordException() {
41
- // no-op
42
- }
43
- }
44
- //# sourceMappingURL=NoOpSpan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoOpSpan.js","sourceRoot":"","sources":["../../src/NoOp/NoOpSpan.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACnB,WAAW;QACT,OAAO;YACL,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;IAED,YAAY;QACV,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa;QACX,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS;QACP,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU;QACR,QAAQ;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,QAAQ;IACV,CAAC;IAED,WAAW;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,eAAe;QACb,QAAQ;IACV,CAAC;CACF","sourcesContent":["import type { Span, SpanContext } from '@opentelemetry/api';\n\n/**\n * No-op implementation of {@link Span}.\n * This class will be used when Telemetry is disabled.\n * @internal\n */\nexport class NoOpSpan implements Span {\n spanContext(): SpanContext {\n return {\n spanId: '',\n traceFlags: 0,\n traceId: '',\n };\n }\n\n setAttribute(): this {\n // no-op\n return this;\n }\n\n setAttributes(): this {\n // no-op\n return this;\n }\n\n addEvent(): this {\n // no-op\n return this;\n }\n\n setStatus(): this {\n // no-op\n return this;\n }\n\n updateName(): this {\n // no-op\n return this;\n }\n\n end(): void {\n // no-op\n }\n\n isRecording(): boolean {\n return false;\n }\n\n recordException(): void {\n // no-op\n }\n}\n"]}
@@ -1,12 +0,0 @@
1
- import type { Context, Span, SpanOptions, Tracer } from '@opentelemetry/api';
2
- /**
3
- * No-op implementation of {@link Tracer}.
4
- * This class will be used when Telemetry is disabled.
5
- */
6
- export declare class NoOpTracer implements Tracer {
7
- startSpan(): Span;
8
- startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, fn: F): ReturnType<F>;
9
- startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, _opts: SpanOptions, fn: F): ReturnType<F>;
10
- startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, opts: SpanOptions, ctx: Context, fn: F): ReturnType<F>;
11
- }
12
- //# sourceMappingURL=NoOpTracer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoOpTracer.d.ts","sourceRoot":"","sources":["../../src/NoOp/NoOpTracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG7E;;;GAGG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,SAAS,IAAI,IAAI;IAIjB,eAAe,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAC5F,eAAe,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAChH,eAAe,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,EACrD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,CAAC,GACJ,UAAU,CAAC,CAAC,CAAC;CAsBjB"}
@@ -1,28 +0,0 @@
1
- import { NoOpSpan } from './NoOpSpan.js';
2
- /**
3
- * No-op implementation of {@link Tracer}.
4
- * This class will be used when Telemetry is disabled.
5
- */
6
- export class NoOpTracer {
7
- startSpan() {
8
- return new NoOpSpan();
9
- }
10
- startActiveSpan(_name, arg2, arg3, arg4) {
11
- let fn;
12
- if (arguments.length < 2) {
13
- return;
14
- }
15
- else if (arguments.length === 2) {
16
- fn = arg2;
17
- }
18
- else if (arguments.length === 3) {
19
- fn = arg3;
20
- }
21
- else {
22
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
23
- fn = arg4;
24
- }
25
- return fn(new NoOpSpan());
26
- }
27
- }
28
- //# sourceMappingURL=NoOpTracer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoOpTracer.js","sourceRoot":"","sources":["../../src/NoOp/NoOpTracer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;GAGG;AACH,MAAM,OAAO,UAAU;IACrB,SAAS;QACP,OAAO,IAAI,QAAQ,EAAE,CAAC;IACxB,CAAC;IAUD,eAAe,CACb,KAAa,EACb,IAAsB,EACtB,IAAkB,EAClB,IAAQ;QAER,IAAI,EAAK,CAAC;QAEV,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,OAAO;SACR;aAAM,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YACjC,EAAE,GAAG,IAAS,CAAC;SAChB;aAAM,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YACjC,EAAE,GAAG,IAAS,CAAC;SAChB;aAAM;YACL,oEAAoE;YACpE,EAAE,GAAG,IAAK,CAAC;SACZ;QAED,OAAO,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import type { Context, Span, SpanOptions, Tracer } from '@opentelemetry/api';\nimport { NoOpSpan } from './NoOpSpan.js';\n\n/**\n * No-op implementation of {@link Tracer}.\n * This class will be used when Telemetry is disabled.\n */\nexport class NoOpTracer implements Tracer {\n startSpan(): Span {\n return new NoOpSpan();\n }\n\n startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, fn: F): ReturnType<F>;\n startActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, _opts: SpanOptions, fn: F): ReturnType<F>;\n startActiveSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n opts: SpanOptions,\n ctx: Context,\n fn: F,\n ): ReturnType<F>;\n startActiveSpan<F extends (span: Span) => ReturnType<F>>(\n _name: string,\n arg2?: F | SpanOptions,\n arg3?: F | Context,\n arg4?: F,\n ): ReturnType<F> | undefined {\n let fn: F;\n\n if (arguments.length < 2) {\n return;\n } else if (arguments.length === 2) {\n fn = arg2 as F;\n } else if (arguments.length === 3) {\n fn = arg3 as F;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n fn = arg4!;\n }\n\n return fn(new NoOpSpan());\n }\n}\n"]}