@azure/monitor-opentelemetry-exporter 1.0.0-beta.13 → 1.0.0-beta.14

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/index.js CHANGED
@@ -66,7 +66,7 @@ const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
66
66
  * AzureMonitorTraceExporter version.
67
67
  * @internal
68
68
  */
69
- const packageVersion = "1.0.0-beta.13";
69
+ const packageVersion = "1.0.0-beta.14";
70
70
  var DependencyTypes;
71
71
  (function (DependencyTypes) {
72
72
  DependencyTypes["InProc"] = "InProc";
@@ -83,10 +83,10 @@ const ApplicationInsightsPageViewName = "Microsoft.ApplicationInsights.PageView"
83
83
  const ApplicationInsightsAvailabilityName = "Microsoft.ApplicationInsights.Availability";
84
84
  const ApplicationInsightsEventName = "Microsoft.ApplicationInsights.Event";
85
85
  const ApplicationInsightsMessageBaseType = "MessageData";
86
- const ApplicationInsightsExceptionBaseType = "TelemetryExceptionData";
86
+ const ApplicationInsightsExceptionBaseType = "ExceptionData";
87
87
  const ApplicationInsightsPageViewBaseType = "PageViewData";
88
88
  const ApplicationInsightsAvailabilityBaseType = "AvailabilityData";
89
- const ApplicationInsightsEventBaseType = "TelemetryEventData";
89
+ const ApplicationInsightsEventBaseType = "EventData";
90
90
 
91
91
  /**
92
92
  * ApplicationInsightsSampler is responsible for the following:
@@ -1743,7 +1743,7 @@ class ApplicationInsightsClient extends coreClient__namespace.ServiceClient {
1743
1743
  const defaults = {
1744
1744
  requestContentType: "application/json; charset=utf-8"
1745
1745
  };
1746
- const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.13`;
1746
+ const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.14`;
1747
1747
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1748
1748
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1749
1749
  : `${packageDetails}`;
@@ -2854,18 +2854,20 @@ function createResourceMetricEnvelope(resource, instrumentationKey) {
2854
2854
  }
2855
2855
  // Only send event when resource attributes are available
2856
2856
  if (Object.keys(resourceAttributes).length > 0) {
2857
+ let baseData = {
2858
+ version: 2,
2859
+ metrics: [{ name: "_APPRESOURCEPREVIEW_", value: 1 }],
2860
+ properties: resourceAttributes,
2861
+ };
2857
2862
  let envelope = {
2858
- name: "_APPRESOURCEPREVIEW_",
2863
+ name: "Microsoft.ApplicationInsights.Metric",
2859
2864
  time: new Date(),
2860
2865
  sampleRate: 100,
2861
2866
  instrumentationKey: instrumentationKey,
2862
2867
  version: 1,
2863
2868
  data: {
2864
2869
  baseType: "MetricData",
2865
- baseData: {
2866
- version: 2,
2867
- properties: resourceAttributes,
2868
- },
2870
+ baseData: baseData,
2869
2871
  },
2870
2872
  tags: tags,
2871
2873
  };
@@ -3447,7 +3449,6 @@ class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
3447
3449
  * Flag to determine if Exporter is shutdown.
3448
3450
  */
3449
3451
  this._isShutdown = false;
3450
- this._aggregationTemporality = sdkMetrics.AggregationTemporality.CUMULATIVE;
3451
3452
  api.diag.debug("AzureMonitorMetricExporter was successfully setup");
3452
3453
  }
3453
3454
  /**
@@ -3480,7 +3481,11 @@ class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
3480
3481
  * Select aggregation temporality
3481
3482
  */
3482
3483
  selectAggregationTemporality(_instrumentType) {
3483
- return this._aggregationTemporality;
3484
+ if (_instrumentType == sdkMetrics.InstrumentType.UP_DOWN_COUNTER ||
3485
+ _instrumentType == sdkMetrics.InstrumentType.OBSERVABLE_UP_DOWN_COUNTER) {
3486
+ return sdkMetrics.AggregationTemporality.CUMULATIVE;
3487
+ }
3488
+ return sdkMetrics.AggregationTemporality.DELTA;
3484
3489
  }
3485
3490
  /**
3486
3491
  * Force flush
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
  import { context, diag } from "@opentelemetry/api";
4
- import { AggregationTemporality, } from "@opentelemetry/sdk-metrics";
4
+ import { AggregationTemporality, InstrumentType, } from "@opentelemetry/sdk-metrics";
5
5
  import { ExportResultCode, suppressTracing } from "@opentelemetry/core";
6
6
  import { AzureMonitorBaseExporter } from "./base";
7
7
  import { resourceMetricsToEnvelope } from "../utils/metricUtils";
@@ -19,7 +19,6 @@ export class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
19
19
  * Flag to determine if Exporter is shutdown.
20
20
  */
21
21
  this._isShutdown = false;
22
- this._aggregationTemporality = AggregationTemporality.CUMULATIVE;
23
22
  diag.debug("AzureMonitorMetricExporter was successfully setup");
24
23
  }
25
24
  /**
@@ -52,7 +51,11 @@ export class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
52
51
  * Select aggregation temporality
53
52
  */
54
53
  selectAggregationTemporality(_instrumentType) {
55
- return this._aggregationTemporality;
54
+ if (_instrumentType == InstrumentType.UP_DOWN_COUNTER ||
55
+ _instrumentType == InstrumentType.OBSERVABLE_UP_DOWN_COUNTER) {
56
+ return AggregationTemporality.CUMULATIVE;
57
+ }
58
+ return AggregationTemporality.DELTA;
56
59
  }
57
60
  /**
58
61
  * Force flush
@@ -1 +1 @@
1
- {"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/export/metric.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,sBAAsB,GAIvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgB,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,MAAM,OAAO,0BACX,SAAQ,wBAAwB;IAYhC;;;OAGG;IAEH,YAAY,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AO,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { context, diag } from \"@opentelemetry/api\";\nimport {\n AggregationTemporality,\n InstrumentType,\n PushMetricExporter,\n ResourceMetrics,\n} from \"@opentelemetry/sdk-metrics\";\nimport { ExportResult, ExportResultCode, suppressTracing } from \"@opentelemetry/core\";\nimport { AzureMonitorBaseExporter } from \"./base\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { resourceMetricsToEnvelope } from \"../utils/metricUtils\";\nimport { AzureMonitorExporterOptions } from \"../config\";\n\n/**\n * Azure Monitor OpenTelemetry Metric Exporter.\n */\nexport class AzureMonitorMetricExporter\n extends AzureMonitorBaseExporter\n implements PushMetricExporter\n{\n /**\n * Flag to determine if Exporter is shutdown.\n */\n private _isShutdown = false;\n /**\n * Aggregation temporality.\n */\n private _aggregationTemporality: AggregationTemporality;\n\n /**\n * Initializes a new instance of the AzureMonitorMetricExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n\n constructor(options: AzureMonitorExporterOptions = {}) {\n super(options);\n this._aggregationTemporality = AggregationTemporality.CUMULATIVE;\n diag.debug(\"AzureMonitorMetricExporter was successfully setup\");\n }\n\n /**\n * Export OpenTelemetry resource metrics.\n * @param metrics - Resource metrics to export.\n * @param resultCallback - Result callback.\n */\n async export(\n metrics: ResourceMetrics,\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n if (this._isShutdown) {\n diag.info(\"Exporter shut down. Failed to export spans.\");\n setTimeout(() => resultCallback({ code: ExportResultCode.FAILED }), 0);\n return;\n }\n diag.info(`Exporting ${metrics.scopeMetrics.length} metrics(s). Converting to envelopes...`);\n\n let envelopes: Envelope[] = resourceMetricsToEnvelope(metrics, this._instrumentationKey);\n // Supress tracing until OpenTelemetry Metrics SDK support it\n context.with(suppressTracing(context.active()), async () => {\n resultCallback(await this._exportEnvelopes(envelopes));\n });\n }\n\n /**\n * Shutdown AzureMonitorMetricExporter.\n */\n public async shutdown(): Promise<void> {\n this._isShutdown = true;\n diag.info(\"AzureMonitorMetricExporter shutting down\");\n return this._shutdown();\n }\n\n /**\n * Select aggregation temporality\n */\n public selectAggregationTemporality(_instrumentType: InstrumentType): AggregationTemporality {\n return this._aggregationTemporality;\n }\n\n /**\n * Force flush\n */\n public async forceFlush() {\n return Promise.resolve();\n }\n}\n"]}
1
+ {"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/export/metric.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,cAAc,GAGf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgB,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,MAAM,OAAO,0BACX,SAAQ,wBAAwB;IAOhC;;;OAGG;IAEH,YAAY,UAAuC,EAAE;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QAVjB;;WAEG;QACK,gBAAW,GAAG,KAAK,CAAC;QAQ1B,IAAI,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,OAAwB,EACxB,cAA8C;QAE9C,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;YACzD,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACvE,OAAO;SACR;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,OAAO,CAAC,YAAY,CAAC,MAAM,yCAAyC,CAAC,CAAC;QAE7F,IAAI,SAAS,GAAe,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACzF,6DAA6D;QAC7D,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,IAAI,EAAE;YACzD,cAAc,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,4BAA4B,CAAC,eAA+B;QACjE,IACE,eAAe,IAAI,cAAc,CAAC,eAAe;YACjD,eAAe,IAAI,cAAc,CAAC,0BAA0B,EAC5D;YACA,OAAO,sBAAsB,CAAC,UAAU,CAAC;SAC1C;QACD,OAAO,sBAAsB,CAAC,KAAK,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;QACrB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { context, diag } from \"@opentelemetry/api\";\nimport {\n AggregationTemporality,\n InstrumentType,\n PushMetricExporter,\n ResourceMetrics,\n} from \"@opentelemetry/sdk-metrics\";\nimport { ExportResult, ExportResultCode, suppressTracing } from \"@opentelemetry/core\";\nimport { AzureMonitorBaseExporter } from \"./base\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { resourceMetricsToEnvelope } from \"../utils/metricUtils\";\nimport { AzureMonitorExporterOptions } from \"../config\";\n\n/**\n * Azure Monitor OpenTelemetry Metric Exporter.\n */\nexport class AzureMonitorMetricExporter\n extends AzureMonitorBaseExporter\n implements PushMetricExporter\n{\n /**\n * Flag to determine if Exporter is shutdown.\n */\n private _isShutdown = false;\n /**\n * Initializes a new instance of the AzureMonitorMetricExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n\n constructor(options: AzureMonitorExporterOptions = {}) {\n super(options);\n diag.debug(\"AzureMonitorMetricExporter was successfully setup\");\n }\n\n /**\n * Export OpenTelemetry resource metrics.\n * @param metrics - Resource metrics to export.\n * @param resultCallback - Result callback.\n */\n async export(\n metrics: ResourceMetrics,\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n if (this._isShutdown) {\n diag.info(\"Exporter shut down. Failed to export spans.\");\n setTimeout(() => resultCallback({ code: ExportResultCode.FAILED }), 0);\n return;\n }\n diag.info(`Exporting ${metrics.scopeMetrics.length} metrics(s). Converting to envelopes...`);\n\n let envelopes: Envelope[] = resourceMetricsToEnvelope(metrics, this._instrumentationKey);\n // Supress tracing until OpenTelemetry Metrics SDK support it\n context.with(suppressTracing(context.active()), async () => {\n resultCallback(await this._exportEnvelopes(envelopes));\n });\n }\n\n /**\n * Shutdown AzureMonitorMetricExporter.\n */\n public async shutdown(): Promise<void> {\n this._isShutdown = true;\n diag.info(\"AzureMonitorMetricExporter shutting down\");\n return this._shutdown();\n }\n\n /**\n * Select aggregation temporality\n */\n public selectAggregationTemporality(_instrumentType: InstrumentType): AggregationTemporality {\n if (\n _instrumentType == InstrumentType.UP_DOWN_COUNTER ||\n _instrumentType == InstrumentType.OBSERVABLE_UP_DOWN_COUNTER\n ) {\n return AggregationTemporality.CUMULATIVE;\n }\n return AggregationTemporality.DELTA;\n }\n\n /**\n * Force flush\n */\n public async forceFlush() {\n return Promise.resolve();\n }\n}\n"]}
@@ -23,7 +23,7 @@ export class ApplicationInsightsClient extends coreClient.ServiceClient {
23
23
  const defaults = {
24
24
  requestContentType: "application/json; charset=utf-8"
25
25
  };
26
- const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.13`;
26
+ const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.14`;
27
27
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
28
28
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
29
29
  : `${packageDetails}`;
@@ -1 +1 @@
1
- {"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAQ5C,MAAM,OAAO,yBAA0B,SAAQ,UAAU,CAAC,aAAa;IAGrE;;;OAGG;IACH,YAAY,OAAiD;;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,uDAAuD,CAAC;QAC/E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,aAAa,GAC9D,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CA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AAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as coreRestPipeline from \"@azure/core-rest-pipeline\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n TrackOptionalParams,\n TrackOperationResponse\n} from \"./models\";\n\nexport class ApplicationInsightsClient extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClient class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: ApplicationInsightsClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.13`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint ?? options.baseUri ?? \"{Host}/v2.1\"\n };\n super(optionsWithDefaults);\n\n if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {\n const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();\n const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(\n (pipelinePolicy) =>\n pipelinePolicy.name ===\n coreRestPipeline.bearerTokenAuthenticationPolicyName\n );\n if (!bearerTokenAuthenticationPolicyFound) {\n this.pipeline.removePolicy({\n name: coreRestPipeline.bearerTokenAuthenticationPolicyName\n });\n this.pipeline.addPolicy(\n coreRestPipeline.bearerTokenAuthenticationPolicy({\n scopes: `${optionsWithDefaults.baseUri}/.default`,\n challengeCallbacks: {\n authorizeRequestOnChallenge:\n coreClient.authorizeRequestOnClaimChallenge\n }\n })\n );\n }\n }\n\n // Assigning values to Constant parameters\n this.host = options.host || \"https://dc.services.visualstudio.com\";\n }\n\n /**\n * This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.\n * @param body The list of telemetry events to track.\n * @param options The options parameters.\n */\n track(\n body: TelemetryItem[],\n options?: TrackOptionalParams\n ): Promise<TrackOperationResponse> {\n return this.sendOperationRequest({ body, options }, trackOperationSpec);\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst trackOperationSpec: coreClient.OperationSpec = {\n path: \"/track\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.TrackResponse\n },\n 206: {\n bodyMapper: Mappers.TrackResponse\n },\n 400: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 402: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 429: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 500: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 503: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n }\n },\n requestBody: Parameters.body,\n urlParameters: [Parameters.host],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer\n};\n"]}
1
+ {"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAQ5C,MAAM,OAAO,yBAA0B,SAAQ,UAAU,CAAC,aAAa;IAGrE;;;OAGG;IACH,YAAY,OAAiD;;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,uDAAuD,CAAC;QAC/E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,aAAa,GAC9D,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE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a;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as coreRestPipeline from \"@azure/core-rest-pipeline\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n TrackOptionalParams,\n TrackOperationResponse\n} from \"./models\";\n\nexport class ApplicationInsightsClient extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClient class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: ApplicationInsightsClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.14`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint ?? options.baseUri ?? \"{Host}/v2.1\"\n };\n super(optionsWithDefaults);\n\n if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {\n const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();\n const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(\n (pipelinePolicy) =>\n pipelinePolicy.name ===\n coreRestPipeline.bearerTokenAuthenticationPolicyName\n );\n if (!bearerTokenAuthenticationPolicyFound) {\n this.pipeline.removePolicy({\n name: coreRestPipeline.bearerTokenAuthenticationPolicyName\n });\n this.pipeline.addPolicy(\n coreRestPipeline.bearerTokenAuthenticationPolicy({\n scopes: `${optionsWithDefaults.baseUri}/.default`,\n challengeCallbacks: {\n authorizeRequestOnChallenge:\n coreClient.authorizeRequestOnClaimChallenge\n }\n })\n );\n }\n }\n\n // Assigning values to Constant parameters\n this.host = options.host || \"https://dc.services.visualstudio.com\";\n }\n\n /**\n * This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.\n * @param body The list of telemetry events to track.\n * @param options The options parameters.\n */\n track(\n body: TelemetryItem[],\n options?: TrackOptionalParams\n ): Promise<TrackOperationResponse> {\n return this.sendOperationRequest({ body, options }, trackOperationSpec);\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst trackOperationSpec: coreClient.OperationSpec = {\n path: \"/track\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.TrackResponse\n },\n 206: {\n bodyMapper: Mappers.TrackResponse\n },\n 400: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 402: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 429: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 500: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 503: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n }\n },\n requestBody: Parameters.body,\n urlParameters: [Parameters.host],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer\n};\n"]}
@@ -173,18 +173,20 @@ export function createResourceMetricEnvelope(resource, instrumentationKey) {
173
173
  }
174
174
  // Only send event when resource attributes are available
175
175
  if (Object.keys(resourceAttributes).length > 0) {
176
+ let baseData = {
177
+ version: 2,
178
+ metrics: [{ name: "_APPRESOURCEPREVIEW_", value: 1 }],
179
+ properties: resourceAttributes,
180
+ };
176
181
  let envelope = {
177
- name: "_APPRESOURCEPREVIEW_",
182
+ name: "Microsoft.ApplicationInsights.Metric",
178
183
  time: new Date(),
179
184
  sampleRate: 100,
180
185
  instrumentationKey: instrumentationKey,
181
186
  version: 1,
182
187
  data: {
183
188
  baseType: "MetricData",
184
- baseData: {
185
- version: 2,
186
- properties: resourceAttributes,
187
- },
189
+ baseData: baseData,
188
190
  },
189
191
  tags: tags,
190
192
  };
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAA6B,MAAM,cAAc,CAAC;AAI9E,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACvD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,IAAI,qBAAc,OAAO,CAAC,IAA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AAC;SACjB;KACF;IACD,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport os from \"os\";\nimport {\n SemanticResourceAttributes,\n SemanticAttributes,\n DbSystemValues,\n} from \"@opentelemetry/semantic-conventions\";\nimport { Tags } from \"../types\";\nimport { getInstance } from \"../platform\";\nimport { KnownContextTagKeys, TelemetryItem as Envelope } from \"../generated\";\nimport { Resource } from \"@opentelemetry/resources\";\nimport { Attributes } from \"@opentelemetry/api\";\n\nexport function createTagsFromResource(resource: Resource): Tags {\n const context = getInstance();\n const tags: Tags = { ...context.tags };\n if (resource && resource.attributes) {\n tags[KnownContextTagKeys.AiCloudRole] = getCloudRole(resource);\n tags[KnownContextTagKeys.AiCloudRoleInstance] = getCloudRoleInstance(resource);\n const endUserId = resource.attributes[SemanticAttributes.ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n }\n return tags;\n}\n\nfunction getCloudRole(resource: Resource): string {\n let cloudRole = \"\";\n // Service attributes\n const serviceName = resource.attributes[SemanticResourceAttributes.SERVICE_NAME];\n const serviceNamespace = resource.attributes[SemanticResourceAttributes.SERVICE_NAMESPACE];\n if (serviceName) {\n // Custom Service name provided by customer is highest precedence\n if (!String(serviceName).startsWith(\"unknown_service\")) {\n if (serviceNamespace) {\n return `${serviceNamespace}.${serviceName}`;\n } else {\n return String(serviceName);\n }\n } else {\n // Service attributes will be only used if K8S attributes are not present\n if (serviceNamespace) {\n cloudRole = `${serviceNamespace}.${serviceName}`;\n } else {\n cloudRole = String(serviceName);\n }\n }\n }\n // Kubernetes attributes should take precedence\n const kubernetesDeploymentName =\n resource.attributes[SemanticResourceAttributes.K8S_DEPLOYMENT_NAME];\n if (kubernetesDeploymentName) {\n return String(kubernetesDeploymentName);\n }\n const kuberneteReplicasetName =\n resource.attributes[SemanticResourceAttributes.K8S_REPLICASET_NAME];\n if (kuberneteReplicasetName) {\n return String(kuberneteReplicasetName);\n }\n const kubernetesStatefulSetName =\n resource.attributes[SemanticResourceAttributes.K8S_STATEFULSET_NAME];\n if (kubernetesStatefulSetName) {\n return String(kubernetesStatefulSetName);\n }\n const kubernetesJobName = resource.attributes[SemanticResourceAttributes.K8S_JOB_NAME];\n if (kubernetesJobName) {\n return String(kubernetesJobName);\n }\n const kubernetesCronjobName = resource.attributes[SemanticResourceAttributes.K8S_CRONJOB_NAME];\n if (kubernetesCronjobName) {\n return String(kubernetesCronjobName);\n }\n const kubernetesDaemonsetName =\n resource.attributes[SemanticResourceAttributes.K8S_DAEMONSET_NAME];\n if (kubernetesDaemonsetName) {\n return String(kubernetesDaemonsetName);\n }\n return cloudRole;\n}\n\nfunction getCloudRoleInstance(resource: Resource): string {\n // Kubernetes attributes should take precedence\n const kubernetesPodName = resource.attributes[SemanticResourceAttributes.K8S_POD_NAME];\n if (kubernetesPodName) {\n return String(kubernetesPodName);\n }\n // Service attributes\n const serviceInstanceId = resource.attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID];\n if (serviceInstanceId) {\n return String(serviceInstanceId);\n }\n // Default\n return os && os.hostname();\n}\n\nexport function isSqlDB(dbSystem: string) {\n return (\n dbSystem === DbSystemValues.DB2 ||\n dbSystem === DbSystemValues.DERBY ||\n dbSystem === DbSystemValues.MARIADB ||\n dbSystem === DbSystemValues.MSSQL ||\n dbSystem === DbSystemValues.ORACLE ||\n dbSystem === DbSystemValues.SQLITE ||\n dbSystem === DbSystemValues.OTHER_SQL ||\n dbSystem === DbSystemValues.HSQLDB ||\n dbSystem === DbSystemValues.H2\n );\n}\n\nexport function getUrl(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const httpMethod = attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = attributes[SemanticAttributes.HTTP_SCHEME];\n const httpTarget = attributes[SemanticAttributes.HTTP_TARGET];\n if (httpScheme && httpTarget) {\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = attributes[SemanticAttributes.NET_PEER_PORT];\n if (netPeerPort) {\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\n if (netPeerIp) {\n return `${httpScheme}://${netPeerIp}:${netPeerPort}${httpTarget}`;\n }\n }\n }\n }\n }\n }\n }\n return \"\";\n}\n\nexport function getDependencyTarget(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const peerService = attributes[SemanticAttributes.PEER_SERVICE];\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\n if (peerService) {\n return String(peerService);\n } else if (httpHost) {\n return String(httpHost);\n } else if (httpUrl) {\n return String(httpUrl);\n } else if (netPeerName) {\n return String(netPeerName);\n } else if (netPeerIp) {\n return String(netPeerIp);\n }\n return \"\";\n}\n\nexport function createResourceMetricEnvelope(\n resource: Resource,\n instrumentationKey: string\n): Envelope | undefined {\n if (resource && resource.attributes) {\n const tags = createTagsFromResource(resource);\n const resourceAttributes: { [propertyName: string]: string } = {};\n for (const key of Object.keys(resource.attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_VERSION ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_NAME\n )\n ) {\n resourceAttributes[key] = resource.attributes[key] as string;\n }\n }\n // Only send event when resource attributes are available\n if (Object.keys(resourceAttributes).length > 0) {\n let envelope: Envelope = {\n name: \"_APPRESOURCEPREVIEW_\",\n time: new Date(),\n sampleRate: 100, // Metrics are never sampled\n instrumentationKey: instrumentationKey,\n version: 1,\n data: {\n baseType: \"MetricData\",\n baseData: {\n version: 2,\n properties: resourceAttributes,\n },\n },\n tags: tags,\n };\n return envelope;\n }\n }\n return;\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAA0C,MAAM,cAAc,CAAC;AAI3F,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACvD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,IAAI,qBAAc,OAAO,CAAC,IAAI,CAAE,CAAC;IACvC,IAAI,QAAQ,IAAI,QAAQ,CAAC,UAAU,EAAE;QACnC,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/E,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;SACxD;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,QAAkB;IACtC,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,qBAAqB;IACrB,MAAM,WAAW,GAAG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0BAA0B,CAAC,qBAAqB;gBACvD,GAAG,IAAI,0BAA0B,CAAC,sBAAsB;gBACxD,GAAG,IAAI,0BAA0B,CAAC,kBAAkB,CACrD,EACD;gBACA,kBAAkB,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAW,CAAC;aAC9D;SACF;QACD,yDAAyD;QACzD,IAAI,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9C,IAAI,QAAQ,GAAgB;gBAC1B,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBACrD,UAAU,EAAE,kBAAkB;aAC/B,CAAC;YACF,IAAI,QAAQ,GAAa;gBACvB,IAAI,EAAE,sCAAsC;gBAC5C,IAAI,EAAE,IAAI,IAAI,EAAE;gBAChB,UAAU,EAAE,GAAG;gBACf,kBAAkB,EAAE,kBAAkB;gBACtC,OAAO,EAAE,CAAC;gBACV,IAAI,EAAE;oBACJ,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,QAAQ;iBACnB;gBACD,IAAI,EAAE,IAAI;aACX,CAAC;YACF,OAAO,QAAQ,CAAC;SACjB;KACF;IACD,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport os from \"os\";\nimport {\n SemanticResourceAttributes,\n SemanticAttributes,\n DbSystemValues,\n} from \"@opentelemetry/semantic-conventions\";\nimport { Tags } from \"../types\";\nimport { getInstance } from \"../platform\";\nimport { KnownContextTagKeys, TelemetryItem as Envelope, MetricsData } from \"../generated\";\nimport { Resource } from \"@opentelemetry/resources\";\nimport { Attributes } from \"@opentelemetry/api\";\n\nexport function createTagsFromResource(resource: Resource): Tags {\n const context = getInstance();\n const tags: Tags = { ...context.tags };\n if (resource && resource.attributes) {\n tags[KnownContextTagKeys.AiCloudRole] = getCloudRole(resource);\n tags[KnownContextTagKeys.AiCloudRoleInstance] = getCloudRoleInstance(resource);\n const endUserId = resource.attributes[SemanticAttributes.ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n }\n return tags;\n}\n\nfunction getCloudRole(resource: Resource): string {\n let cloudRole = \"\";\n // Service attributes\n const serviceName = resource.attributes[SemanticResourceAttributes.SERVICE_NAME];\n const serviceNamespace = resource.attributes[SemanticResourceAttributes.SERVICE_NAMESPACE];\n if (serviceName) {\n // Custom Service name provided by customer is highest precedence\n if (!String(serviceName).startsWith(\"unknown_service\")) {\n if (serviceNamespace) {\n return `${serviceNamespace}.${serviceName}`;\n } else {\n return String(serviceName);\n }\n } else {\n // Service attributes will be only used if K8S attributes are not present\n if (serviceNamespace) {\n cloudRole = `${serviceNamespace}.${serviceName}`;\n } else {\n cloudRole = String(serviceName);\n }\n }\n }\n // Kubernetes attributes should take precedence\n const kubernetesDeploymentName =\n resource.attributes[SemanticResourceAttributes.K8S_DEPLOYMENT_NAME];\n if (kubernetesDeploymentName) {\n return String(kubernetesDeploymentName);\n }\n const kuberneteReplicasetName =\n resource.attributes[SemanticResourceAttributes.K8S_REPLICASET_NAME];\n if (kuberneteReplicasetName) {\n return String(kuberneteReplicasetName);\n }\n const kubernetesStatefulSetName =\n resource.attributes[SemanticResourceAttributes.K8S_STATEFULSET_NAME];\n if (kubernetesStatefulSetName) {\n return String(kubernetesStatefulSetName);\n }\n const kubernetesJobName = resource.attributes[SemanticResourceAttributes.K8S_JOB_NAME];\n if (kubernetesJobName) {\n return String(kubernetesJobName);\n }\n const kubernetesCronjobName = resource.attributes[SemanticResourceAttributes.K8S_CRONJOB_NAME];\n if (kubernetesCronjobName) {\n return String(kubernetesCronjobName);\n }\n const kubernetesDaemonsetName =\n resource.attributes[SemanticResourceAttributes.K8S_DAEMONSET_NAME];\n if (kubernetesDaemonsetName) {\n return String(kubernetesDaemonsetName);\n }\n return cloudRole;\n}\n\nfunction getCloudRoleInstance(resource: Resource): string {\n // Kubernetes attributes should take precedence\n const kubernetesPodName = resource.attributes[SemanticResourceAttributes.K8S_POD_NAME];\n if (kubernetesPodName) {\n return String(kubernetesPodName);\n }\n // Service attributes\n const serviceInstanceId = resource.attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID];\n if (serviceInstanceId) {\n return String(serviceInstanceId);\n }\n // Default\n return os && os.hostname();\n}\n\nexport function isSqlDB(dbSystem: string) {\n return (\n dbSystem === DbSystemValues.DB2 ||\n dbSystem === DbSystemValues.DERBY ||\n dbSystem === DbSystemValues.MARIADB ||\n dbSystem === DbSystemValues.MSSQL ||\n dbSystem === DbSystemValues.ORACLE ||\n dbSystem === DbSystemValues.SQLITE ||\n dbSystem === DbSystemValues.OTHER_SQL ||\n dbSystem === DbSystemValues.HSQLDB ||\n dbSystem === DbSystemValues.H2\n );\n}\n\nexport function getUrl(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const httpMethod = attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = attributes[SemanticAttributes.HTTP_SCHEME];\n const httpTarget = attributes[SemanticAttributes.HTTP_TARGET];\n if (httpScheme && httpTarget) {\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = attributes[SemanticAttributes.NET_PEER_PORT];\n if (netPeerPort) {\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\n if (netPeerIp) {\n return `${httpScheme}://${netPeerIp}:${netPeerPort}${httpTarget}`;\n }\n }\n }\n }\n }\n }\n }\n return \"\";\n}\n\nexport function getDependencyTarget(attributes: Attributes): string {\n if (!attributes) {\n return \"\";\n }\n const peerService = attributes[SemanticAttributes.PEER_SERVICE];\n const httpHost = attributes[SemanticAttributes.HTTP_HOST];\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n const netPeerName = attributes[SemanticAttributes.NET_PEER_NAME];\n const netPeerIp = attributes[SemanticAttributes.NET_PEER_IP];\n if (peerService) {\n return String(peerService);\n } else if (httpHost) {\n return String(httpHost);\n } else if (httpUrl) {\n return String(httpUrl);\n } else if (netPeerName) {\n return String(netPeerName);\n } else if (netPeerIp) {\n return String(netPeerIp);\n }\n return \"\";\n}\n\nexport function createResourceMetricEnvelope(\n resource: Resource,\n instrumentationKey: string\n): Envelope | undefined {\n if (resource && resource.attributes) {\n const tags = createTagsFromResource(resource);\n const resourceAttributes: { [propertyName: string]: string } = {};\n for (const key of Object.keys(resource.attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n !(\n key.startsWith(\"_MS.\") ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_VERSION ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE ||\n key == SemanticResourceAttributes.TELEMETRY_SDK_NAME\n )\n ) {\n resourceAttributes[key] = resource.attributes[key] as string;\n }\n }\n // Only send event when resource attributes are available\n if (Object.keys(resourceAttributes).length > 0) {\n let baseData: MetricsData = {\n version: 2,\n metrics: [{ name: \"_APPRESOURCEPREVIEW_\", value: 1 }],\n properties: resourceAttributes,\n };\n let envelope: Envelope = {\n name: \"Microsoft.ApplicationInsights.Metric\",\n time: new Date(),\n sampleRate: 100, // Metrics are never sampled\n instrumentationKey: instrumentationKey,\n version: 1,\n data: {\n baseType: \"MetricData\",\n baseData: baseData,\n },\n tags: tags,\n };\n return envelope;\n }\n }\n return;\n}\n"]}
@@ -19,7 +19,7 @@ export const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
19
19
  * AzureMonitorTraceExporter version.
20
20
  * @internal
21
21
  */
22
- export const packageVersion = "1.0.0-beta.13";
22
+ export const packageVersion = "1.0.0-beta.14";
23
23
  export var DependencyTypes;
24
24
  (function (DependencyTypes) {
25
25
  DependencyTypes["InProc"] = "InProc";
@@ -36,8 +36,8 @@ export const ApplicationInsightsPageViewName = "Microsoft.ApplicationInsights.Pa
36
36
  export const ApplicationInsightsAvailabilityName = "Microsoft.ApplicationInsights.Availability";
37
37
  export const ApplicationInsightsEventName = "Microsoft.ApplicationInsights.Event";
38
38
  export const ApplicationInsightsMessageBaseType = "MessageData";
39
- export const ApplicationInsightsExceptionBaseType = "TelemetryExceptionData";
39
+ export const ApplicationInsightsExceptionBaseType = "ExceptionData";
40
40
  export const ApplicationInsightsPageViewBaseType = "PageViewData";
41
41
  export const ApplicationInsightsAvailabilityBaseType = "AvailabilityData";
42
- export const ApplicationInsightsEventBaseType = "TelemetryEventData";
42
+ export const ApplicationInsightsEventBaseType = "EventData";
43
43
  //# sourceMappingURL=applicationinsights.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;AACpC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iDAA8B,CAAA;IAC9B,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,gCAAa,CAAA;AACf,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D,MAAM,CAAC,MAAM,8BAA8B,GAAG,uCAAuC,CAAC;AACtF,MAAM,CAAC,MAAM,gCAAgC,GAAG,yCAAyC,CAAC;AAC1F,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAwC,CAAC;AACxF,MAAM,CAAC,MAAM,mCAAmC,GAAG,4CAA4C,CAAC;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAAqC,CAAC;AAElF,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAChE,MAAM,CAAC,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;AAC7E,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAAC;AAClE,MAAM,CAAC,MAAM,uCAAuC,GAAG,kBAAkB,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * AI MS Links.\n * @internal\n */\nexport const MS_LINKS = \"_MS.links\";\n/**\n * AI enqueued time attribute.\n * @internal\n */\nexport const ENQUEUED_TIME = \"enqueuedTime\";\n/**\n * AI time since enqueued attribute.\n * @internal\n */\nexport const TIME_SINCE_ENQUEUED = \"timeSinceEnqueued\";\n/**\n * AzureMonitorTraceExporter version.\n * @internal\n */\nexport const packageVersion = \"1.0.0-beta.13\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n}\n\nexport const AzureMonitorSampleRate = \"_MS.sampleRate\";\nexport const ApplicationInsightsBaseType = \"_MS.baseType\";\n\nexport const ApplicationInsightsMessageName = \"Microsoft.ApplicationInsights.Message\";\nexport const ApplicationInsightsExceptionName = \"Microsoft.ApplicationInsights.Exception\";\nexport const ApplicationInsightsPageViewName = \"Microsoft.ApplicationInsights.PageView\";\nexport const ApplicationInsightsAvailabilityName = \"Microsoft.ApplicationInsights.Availability\";\nexport const ApplicationInsightsEventName = \"Microsoft.ApplicationInsights.Event\";\n\nexport const ApplicationInsightsMessageBaseType = \"MessageData\";\nexport const ApplicationInsightsExceptionBaseType = \"TelemetryExceptionData\";\nexport const ApplicationInsightsPageViewBaseType = \"PageViewData\";\nexport const ApplicationInsightsAvailabilityBaseType = \"AvailabilityData\";\nexport const ApplicationInsightsEventBaseType = \"TelemetryEventData\";\n"]}
1
+ {"version":3,"file":"applicationinsights.js","sourceRoot":"","sources":["../../../../src/utils/constants/applicationinsights.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;AACpC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,iDAA8B,CAAA;IAC9B,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,gCAAa,CAAA;AACf,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D,MAAM,CAAC,MAAM,8BAA8B,GAAG,uCAAuC,CAAC;AACtF,MAAM,CAAC,MAAM,gCAAgC,GAAG,yCAAyC,CAAC;AAC1F,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAwC,CAAC;AACxF,MAAM,CAAC,MAAM,mCAAmC,GAAG,4CAA4C,CAAC;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAAqC,CAAC;AAElF,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAChE,MAAM,CAAC,MAAM,oCAAoC,GAAG,eAAe,CAAC;AACpE,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAAC;AAClE,MAAM,CAAC,MAAM,uCAAuC,GAAG,kBAAkB,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * AI MS Links.\n * @internal\n */\nexport const MS_LINKS = \"_MS.links\";\n/**\n * AI enqueued time attribute.\n * @internal\n */\nexport const ENQUEUED_TIME = \"enqueuedTime\";\n/**\n * AI time since enqueued attribute.\n * @internal\n */\nexport const TIME_SINCE_ENQUEUED = \"timeSinceEnqueued\";\n/**\n * AzureMonitorTraceExporter version.\n * @internal\n */\nexport const packageVersion = \"1.0.0-beta.14\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n}\n\nexport const AzureMonitorSampleRate = \"_MS.sampleRate\";\nexport const ApplicationInsightsBaseType = \"_MS.baseType\";\n\nexport const ApplicationInsightsMessageName = \"Microsoft.ApplicationInsights.Message\";\nexport const ApplicationInsightsExceptionName = \"Microsoft.ApplicationInsights.Exception\";\nexport const ApplicationInsightsPageViewName = \"Microsoft.ApplicationInsights.PageView\";\nexport const ApplicationInsightsAvailabilityName = \"Microsoft.ApplicationInsights.Availability\";\nexport const ApplicationInsightsEventName = \"Microsoft.ApplicationInsights.Event\";\n\nexport const ApplicationInsightsMessageBaseType = \"MessageData\";\nexport const ApplicationInsightsExceptionBaseType = \"ExceptionData\";\nexport const ApplicationInsightsPageViewBaseType = \"PageViewData\";\nexport const ApplicationInsightsAvailabilityBaseType = \"AvailabilityData\";\nexport const ApplicationInsightsEventBaseType = \"EventData\";\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/monitor-opentelemetry-exporter",
3
3
  "author": "Microsoft Corporation",
4
4
  "sdk-type": "client",
5
- "version": "1.0.0-beta.13",
5
+ "version": "1.0.0-beta.14",
6
6
  "description": "Application Insights exporter for the OpenTelemetry JavaScript (Node.js) SDK",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist-esm/src/index.js",
@@ -108,13 +108,13 @@
108
108
  "@azure/core-auth": "^1.3.0",
109
109
  "@azure/core-rest-pipeline": "^1.1.0",
110
110
  "@opentelemetry/api": "^1.4.1",
111
- "@opentelemetry/api-logs": "0.39.1",
112
- "@opentelemetry/core": "^1.13.0",
113
- "@opentelemetry/resources": "^1.13.0",
114
- "@opentelemetry/sdk-metrics": "^1.13.0",
115
- "@opentelemetry/sdk-trace-base": "^1.13.0",
116
- "@opentelemetry/semantic-conventions": "^1.13.0",
117
- "@opentelemetry/sdk-logs": "0.39.1",
111
+ "@opentelemetry/api-logs": "^0.40.0",
112
+ "@opentelemetry/core": "^1.14.0",
113
+ "@opentelemetry/resources": "^1.14.0",
114
+ "@opentelemetry/sdk-metrics": "^1.14.0",
115
+ "@opentelemetry/sdk-trace-base": "^1.14.0",
116
+ "@opentelemetry/semantic-conventions": "^1.14.0",
117
+ "@opentelemetry/sdk-logs": "^0.40.0",
118
118
  "tslib": "^2.2.0"
119
119
  },
120
120
  "sideEffects": false,
@@ -160,10 +160,6 @@ export declare class AzureMonitorMetricExporter extends AzureMonitorBaseExporter
160
160
  * Flag to determine if Exporter is shutdown.
161
161
  */
162
162
  private _isShutdown;
163
- /**
164
- * Aggregation temporality.
165
- */
166
- private _aggregationTemporality;
167
163
  /**
168
164
  * Initializes a new instance of the AzureMonitorMetricExporter class.
169
165
  * @param AzureExporterConfig - Exporter configuration.