@azure/monitor-opentelemetry-exporter 1.0.0-beta.5 → 1.0.0-beta.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ## 1.0.0-beta.6 (2022-02-08)
4
+
5
+ ### Other Changes
6
+
7
+ - Updated OpenTelemtry dependencies to their latest available versions.
8
+
3
9
  ## 1.0.0-beta.5 (2021-10-05)
4
10
 
5
11
  ### Bugs Fixed
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Getting started
6
6
 
7
- This exporter package assumes your application is [already instrumented](https://github.com/open-telemetry/opentelemetry-js/blob/master/getting-started/README.md) with the OpenTelemetry SDK. Once you are ready to export OpenTelemetry data, you can add this exporter to your application.
7
+ This exporter package assumes your application is [already instrumented](https://opentelemetry.io/docs/js/getting-started/) with the OpenTelemetry SDK. Once you are ready to export OpenTelemetry data, you can add this exporter to your application.
8
8
 
9
9
  ### Install the package
10
10
 
package/dist/index.js CHANGED
@@ -2,22 +2,50 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var api = require('@opentelemetry/api');
8
6
  var core = require('@opentelemetry/core');
9
- var fs = require('fs');
10
7
  var os = require('os');
11
- var os__default = _interopDefault(os);
12
- var path = require('path');
13
- var util = require('util');
14
8
  var url = require('url');
15
- var url__default = _interopDefault(url);
9
+ var semanticConventions = require('@opentelemetry/semantic-conventions');
16
10
  var coreRestPipeline = require('@azure/core-rest-pipeline');
17
11
  var coreClient = require('@azure/core-client');
18
- var semanticConventions = require('@opentelemetry/semantic-conventions');
12
+ var fs = require('fs');
13
+ var path = require('path');
14
+ var util = require('util');
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var os__namespace = /*#__PURE__*/_interopNamespace(os);
37
+ var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
38
+ var url__default = /*#__PURE__*/_interopDefaultLegacy(url);
39
+ var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
40
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
41
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
19
42
 
20
43
  // Copyright (c) Microsoft Corporation.
44
+ // Licensed under the MIT license.
45
+ /**
46
+ * Azure service API version.
47
+ */
48
+ exports.ServiceApiVersion = void 0;
21
49
  (function (ServiceApiVersion) {
22
50
  /**
23
51
  * V2 Version
@@ -85,7 +113,7 @@ var PerformanceCounter;
85
113
  * Map a PerformanceCounter/QuickPulseCounter to a QuickPulseCounter. If no mapping exists, mapping is *undefined*
86
114
  * @internal
87
115
  */
88
- const PerformanceToQuickPulseCounter = {
116
+ ({
89
117
  [PerformanceCounter.PROCESSOR_TIME]: QuickPulseCounter.PROCESSOR_TIME,
90
118
  [PerformanceCounter.REQUEST_RATE]: QuickPulseCounter.REQUEST_RATE,
91
119
  [PerformanceCounter.REQUEST_DURATION]: QuickPulseCounter.REQUEST_DURATION,
@@ -95,8 +123,8 @@ const PerformanceToQuickPulseCounter = {
95
123
  [QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,
96
124
  [QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,
97
125
  [QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,
98
- [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE
99
- };
126
+ [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE,
127
+ });
100
128
 
101
129
  // Copyright (c) Microsoft Corporation.
102
130
  /**
@@ -175,25 +203,25 @@ const DEFAULT_EXPORTER_CONFIG = {
175
203
  endpointUrl: DEFAULT_BREEZE_ENDPOINT,
176
204
  batchSendRetryIntervalMs: DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS,
177
205
  maxConsecutiveFailuresBeforeWarning: DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING,
178
- apiVersion: DEFAULT_BREEZE_API_VERSION
206
+ apiVersion: DEFAULT_BREEZE_API_VERSION,
179
207
  };
180
208
 
181
209
  // Copyright (c) Microsoft Corporation.
182
- const readdirAsync = util.promisify(fs.readdir);
183
- const statAsync = util.promisify(fs.stat);
184
- const lstatAsync = util.promisify(fs.lstat);
185
- const mkdirAsync = util.promisify(fs.mkdir);
210
+ const readdirAsync$1 = util.promisify(fs__namespace.readdir);
211
+ const statAsync$1 = util.promisify(fs__namespace.stat);
212
+ const lstatAsync = util.promisify(fs__namespace.lstat);
213
+ const mkdirAsync = util.promisify(fs__namespace.mkdir);
186
214
  /**
187
215
  * Computes the size (in bytes) of all files in a directory at the root level. Asynchronously.
188
216
  * @internal
189
217
  */
190
218
  const getShallowDirectorySize = async (directory) => {
191
219
  // Get the directory listing
192
- const files = await readdirAsync(directory);
220
+ const files = await readdirAsync$1(directory);
193
221
  let totalSize = 0;
194
222
  // Query all file sizes
195
223
  for (const file of files) {
196
- const fileStats = await statAsync(path.join(directory, file));
224
+ const fileStats = await statAsync$1(path__namespace.join(directory, file));
197
225
  if (fileStats.isFile()) {
198
226
  totalSize += fileStats.size;
199
227
  }
@@ -227,11 +255,11 @@ const confirmDirExists = async (directory) => {
227
255
  };
228
256
 
229
257
  // Copyright (c) Microsoft Corporation.
230
- const statAsync$1 = util.promisify(fs.stat);
231
- const readdirAsync$1 = util.promisify(fs.readdir);
232
- const readFileAsync = util.promisify(fs.readFile);
233
- const unlinkAsync = util.promisify(fs.unlink);
234
- const writeFileAsync = util.promisify(fs.writeFile);
258
+ const statAsync = util.promisify(fs__namespace.stat);
259
+ const readdirAsync = util.promisify(fs__namespace.readdir);
260
+ const readFileAsync = util.promisify(fs__namespace.readFile);
261
+ const unlinkAsync = util.promisify(fs__namespace.unlink);
262
+ const writeFileAsync = util.promisify(fs__namespace.writeFile);
235
263
  /**
236
264
  * File system persist class.
237
265
  * @internal
@@ -246,7 +274,7 @@ class FileSystemPersist {
246
274
  if (!this._options.instrumentationKey) {
247
275
  api.diag.error(`No instrumentation key was provided to FileSystemPersister. Files may not be properly persisted`);
248
276
  }
249
- this._tempDirectory = path.join(os.tmpdir(), FileSystemPersist.TEMPDIR_PREFIX + this._options.instrumentationKey);
277
+ this._tempDirectory = path__namespace.join(os__namespace.tmpdir(), FileSystemPersist.TEMPDIR_PREFIX + this._options.instrumentationKey);
250
278
  // Starts file cleanup task
251
279
  if (!this._fileCleanupTimer) {
252
280
  this._fileCleanupTimer = setTimeout(() => {
@@ -278,16 +306,16 @@ class FileSystemPersist {
278
306
  */
279
307
  async _getFirstFileOnDisk() {
280
308
  try {
281
- const stats = await statAsync$1(this._tempDirectory);
309
+ const stats = await statAsync(this._tempDirectory);
282
310
  if (stats.isDirectory()) {
283
- const origFiles = await readdirAsync$1(this._tempDirectory);
284
- const files = origFiles.filter((f) => path.basename(f).includes(FileSystemPersist.FILENAME_SUFFIX));
311
+ const origFiles = await readdirAsync(this._tempDirectory);
312
+ const files = origFiles.filter((f) => path__namespace.basename(f).includes(FileSystemPersist.FILENAME_SUFFIX));
285
313
  if (files.length === 0) {
286
314
  return null;
287
315
  }
288
316
  else {
289
317
  const firstFile = files[0];
290
- const filePath = path.join(this._tempDirectory, firstFile);
318
+ const filePath = path__namespace.join(this._tempDirectory, firstFile);
291
319
  const payload = await readFileAsync(filePath);
292
320
  // delete the file first to prevent double sending
293
321
  await unlinkAsync(filePath);
@@ -326,7 +354,7 @@ class FileSystemPersist {
326
354
  return false;
327
355
  }
328
356
  const fileName = `${new Date().getTime()}${FileSystemPersist.FILENAME_SUFFIX}`;
329
- const fileFullPath = path.join(this._tempDirectory, fileName);
357
+ const fileFullPath = path__namespace.join(this._tempDirectory, fileName);
330
358
  // Mode 600 is w/r for creator and no read access for others
331
359
  api.diag.info(`saving data to disk at: ${fileFullPath}`);
332
360
  try {
@@ -340,10 +368,10 @@ class FileSystemPersist {
340
368
  }
341
369
  async _fileCleanupTask() {
342
370
  try {
343
- const stats = await statAsync$1(this._tempDirectory);
371
+ const stats = await statAsync(this._tempDirectory);
344
372
  if (stats.isDirectory()) {
345
- const origFiles = await readdirAsync$1(this._tempDirectory);
346
- const files = origFiles.filter((f) => path.basename(f).includes(FileSystemPersist.FILENAME_SUFFIX));
373
+ const origFiles = await readdirAsync(this._tempDirectory);
374
+ const files = origFiles.filter((f) => path__namespace.basename(f).includes(FileSystemPersist.FILENAME_SUFFIX));
347
375
  if (files.length === 0) {
348
376
  return false;
349
377
  }
@@ -353,7 +381,7 @@ class FileSystemPersist {
353
381
  const fileCreationDate = new Date(parseInt(file.split(FileSystemPersist.FILENAME_SUFFIX)[0]));
354
382
  const expired = new Date(+new Date() - this.fileRetemptionPeriod) > fileCreationDate;
355
383
  if (expired) {
356
- const filePath = path.join(this._tempDirectory, file);
384
+ const filePath = path__namespace.join(this._tempDirectory, file);
357
385
  await unlinkAsync(filePath);
358
386
  }
359
387
  });
@@ -1356,7 +1384,7 @@ var Mappers = /*#__PURE__*/Object.freeze({
1356
1384
  * Code generated by Microsoft (R) AutoRest Code Generator.
1357
1385
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1358
1386
  */
1359
- class ApplicationInsightsClientContext extends coreClient.ServiceClient {
1387
+ class ApplicationInsightsClientContext extends coreClient__namespace.ServiceClient {
1360
1388
  /**
1361
1389
  * Initializes a new instance of the ApplicationInsightsClientContext class.
1362
1390
  * @param options The parameter options
@@ -1407,7 +1435,7 @@ class ApplicationInsightsClient extends ApplicationInsightsClientContext {
1407
1435
  }
1408
1436
  }
1409
1437
  // Operation Specifications
1410
- const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
1438
+ const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1411
1439
  const trackOperationSpec = {
1412
1440
  path: "/track",
1413
1441
  httpMethod: "POST",
@@ -1456,7 +1484,7 @@ class HttpSender {
1456
1484
  this._exporterOptions = _exporterOptions;
1457
1485
  // Build endpoint using provided configuration or default values
1458
1486
  this._appInsightsClientOptions = {
1459
- host: this._exporterOptions.endpointUrl
1487
+ host: this._exporterOptions.endpointUrl,
1460
1488
  };
1461
1489
  this._appInsightsClient = new ApplicationInsightsClient(Object.assign({}, this._appInsightsClientOptions));
1462
1490
  this._appInsightsClient.pipeline.removePolicy({ name: coreRestPipeline.redirectPolicyName });
@@ -1492,7 +1520,7 @@ class HttpSender {
1492
1520
  }
1493
1521
  handlePermanentRedirect(location) {
1494
1522
  if (location) {
1495
- const locUrl = new url__default.URL(location);
1523
+ const locUrl = new url__default["default"].URL(location);
1496
1524
  if (locUrl && locUrl.host) {
1497
1525
  this._appInsightsClient.host = "https://" + locUrl.host;
1498
1526
  }
@@ -1521,7 +1549,7 @@ const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
1521
1549
  * AzureMonitorTraceExporter version.
1522
1550
  * @internal
1523
1551
  */
1524
- const packageVersion = "1.0.0-beta.5";
1552
+ const packageVersion = "1.0.0-beta.6";
1525
1553
  var DependencyTypes;
1526
1554
  (function (DependencyTypes) {
1527
1555
  DependencyTypes["InProc"] = "InProc";
@@ -1544,7 +1572,7 @@ class Context {
1544
1572
  this._loadInternalContext();
1545
1573
  }
1546
1574
  _loadDeviceContext() {
1547
- this.tags[KnownContextTagKeys.AiDeviceOsVersion] = os && `${os.type()} ${os.release()}`;
1575
+ this.tags[KnownContextTagKeys.AiDeviceOsVersion] = os__namespace && `${os__namespace.type()} ${os__namespace.release()}`;
1548
1576
  }
1549
1577
  _loadInternalContext() {
1550
1578
  const { node } = process.versions;
@@ -1691,7 +1719,7 @@ function createTagsFromSpan(span) {
1691
1719
  tags[KnownContextTagKeys.AiCloudRoleInstance] = String(serviceInstanceId);
1692
1720
  }
1693
1721
  else {
1694
- tags[KnownContextTagKeys.AiCloudRoleInstance] = os__default && os__default.hostname();
1722
+ tags[KnownContextTagKeys.AiCloudRoleInstance] = os__default["default"] && os__default["default"].hostname();
1695
1723
  }
1696
1724
  const endUserId = span.resource.attributes[semanticConventions.SemanticAttributes.ENDUSER_ID];
1697
1725
  if (endUserId) {
@@ -1752,7 +1780,7 @@ function createPropertiesFromSpan(span) {
1752
1780
  }
1753
1781
  const links = span.links.map((link) => ({
1754
1782
  operation_Id: link.context.traceId,
1755
- id: link.context.spanId
1783
+ id: link.context.spanId,
1756
1784
  }));
1757
1785
  if (links.length > 0) {
1758
1786
  properties[MS_LINKS] = JSON.stringify(links);
@@ -1836,7 +1864,7 @@ function createDependencyData(span) {
1836
1864
  resultCode: "0",
1837
1865
  type: "Dependency",
1838
1866
  duration: msToTimeSpan(core.hrTimeToMilliseconds(span.duration)),
1839
- version: 2
1867
+ version: 2,
1840
1868
  };
1841
1869
  if (span.kind === api.SpanKind.PRODUCER) {
1842
1870
  remoteDependencyData.type = DependencyTypes.QueueMessage;
@@ -1944,7 +1972,7 @@ function createRequestData(span) {
1944
1972
  responseCode: "0",
1945
1973
  duration: msToTimeSpan(core.hrTimeToMilliseconds(span.duration)),
1946
1974
  version: 2,
1947
- source: undefined
1975
+ source: undefined,
1948
1976
  };
1949
1977
  const httpMethod = span.attributes[semanticConventions.SemanticAttributes.HTTP_METHOD];
1950
1978
  const grpcStatusCode = span.attributes[semanticConventions.SemanticAttributes.RPC_GRPC_STATUS_CODE];
@@ -2012,8 +2040,8 @@ function readableSpanToEnvelope(span, ikey) {
2012
2040
  data: {
2013
2041
  baseType,
2014
2042
  baseData: Object.assign(Object.assign({}, baseData), { properties,
2015
- measurements })
2016
- }
2043
+ measurements }),
2044
+ },
2017
2045
  };
2018
2046
  }
2019
2047
 
@@ -2057,7 +2085,7 @@ class AzureMonitorTraceExporter {
2057
2085
  ? { code: core.ExportResultCode.SUCCESS }
2058
2086
  : {
2059
2087
  code: core.ExportResultCode.FAILED,
2060
- error: new Error("Failed to persist envelope in disk.")
2088
+ error: new Error("Failed to persist envelope in disk."),
2061
2089
  };
2062
2090
  }
2063
2091
  catch (ex) {
@@ -2097,7 +2125,7 @@ class AzureMonitorTraceExporter {
2097
2125
  }
2098
2126
  // Failed -- not retriable
2099
2127
  return {
2100
- code: core.ExportResultCode.FAILED
2128
+ code: core.ExportResultCode.FAILED,
2101
2129
  };
2102
2130
  }
2103
2131
  else {
@@ -2108,7 +2136,7 @@ class AzureMonitorTraceExporter {
2108
2136
  else {
2109
2137
  // Failed -- not retriable
2110
2138
  return {
2111
- code: core.ExportResultCode.FAILED
2139
+ code: core.ExportResultCode.FAILED,
2112
2140
  };
2113
2141
  }
2114
2142
  }
@@ -91,6 +91,6 @@ export const PerformanceToQuickPulseCounter = {
91
91
  [QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,
92
92
  [QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,
93
93
  [QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,
94
- [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE
94
+ [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE,
95
95
  };
96
96
  //# sourceMappingURL=Constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/Declarations/Const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BAAkB,QAY7B;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAyC;IAClF,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,iBAAiB,CAAC,cAAc;IACrE,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC,YAAY;IACjE,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC,gBAAgB;IAEzE,kCAAkC;IAClC,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC,eAAe;IACtE,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,EAAE,iBAAiB,CAAC,oBAAoB;IAChF,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC,eAAe;IACtE,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,EAAE,iBAAiB,CAAC,uBAAuB;IACtF,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,iBAAiB,CAAC,mBAAmB;IAC9E,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,iBAAiB,CAAC,cAAc;CACrE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Azure service API version.\n */\nexport enum ServiceApiVersion {\n /**\n * V2 Version\n */\n V2 = \"2020-09-15_Preview\"\n}\n\n/**\n * Default Breeze endpoint.\n * @internal\n */\nexport const DEFAULT_BREEZE_ENDPOINT = \"https://dc.services.visualstudio.com\";\n/**\n * Default Breeze API version.\n * @internal\n */\nexport const DEFAULT_BREEZE_API_VERSION = ServiceApiVersion.V2;\n/**\n * Default Live Metrics endpoint.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_ENDPOINT = \"https://rt.services.visualstudio.com\";\n/**\n * Default Live Metrics host.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_HOST = \"rt.services.visualstudio.com\";\n/**\n * Connection string environment variable name.\n * @internal\n */\nexport const ENV_CONNECTION_STRING = \"APPLICATIONINSIGHTS_CONNECTION_STRING\";\n/**\n * Instrumentation key environment variable name.\n * @internal\n */\nexport const ENV_INSTRUMENTATION_KEY = \"APPINSIGHTS_INSTRUMENTATIONKEY\";\n\n/**\n * QuickPulse metric counter names.\n * @internal\n */\nexport enum QuickPulseCounter {\n // Memory\n COMMITTED_BYTES = \"\\\\Memory\\\\Committed Bytes\",\n\n // CPU\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n\n // Request\n REQUEST_RATE = \"\\\\ApplicationInsights\\\\Requests/Sec\",\n REQUEST_FAILURE_RATE = \"\\\\ApplicationInsights\\\\Requests Failed/Sec\",\n REQUEST_DURATION = \"\\\\ApplicationInsights\\\\Request Duration\",\n\n // Dependency\n DEPENDENCY_RATE = \"\\\\ApplicationInsights\\\\Dependency Calls/Sec\",\n DEPENDENCY_FAILURE_RATE = \"\\\\ApplicationInsights\\\\Dependency Calls Failed/Sec\",\n DEPENDENCY_DURATION = \"\\\\ApplicationInsights\\\\Dependency Call Duration\",\n\n // Exception\n EXCEPTION_RATE = \"\\\\ApplicationInsights\\\\Exceptions/Sec\"\n}\n\n/**\n * Performance metric counter names.\n * @internal\n */\nexport enum PerformanceCounter {\n // Memory\n PRIVATE_BYTES = \"\\\\Process(??APP_WIN32_PROC??)\\\\Private Bytes\",\n AVAILABLE_BYTES = \"\\\\Memory\\\\Available Bytes\",\n\n // CPU\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n PROCESS_TIME = \"\\\\Process(??APP_WIN32_PROC??)\\\\% Processor Time\",\n\n // Requests\n REQUEST_RATE = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Requests/Sec\",\n REQUEST_DURATION = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Request Execution Time\"\n}\n\n/**\n * Map a PerformanceCounter/QuickPulseCounter to a QuickPulseCounter. If no mapping exists, mapping is *undefined*\n * @internal\n */\nexport const PerformanceToQuickPulseCounter: { [key: string]: QuickPulseCounter } = {\n [PerformanceCounter.PROCESSOR_TIME]: QuickPulseCounter.PROCESSOR_TIME,\n [PerformanceCounter.REQUEST_RATE]: QuickPulseCounter.REQUEST_RATE,\n [PerformanceCounter.REQUEST_DURATION]: QuickPulseCounter.REQUEST_DURATION,\n\n // Remap quick pulse only counters\n [QuickPulseCounter.COMMITTED_BYTES]: QuickPulseCounter.COMMITTED_BYTES,\n [QuickPulseCounter.REQUEST_FAILURE_RATE]: QuickPulseCounter.REQUEST_FAILURE_RATE,\n [QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,\n [QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,\n [QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,\n [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE\n};\n\n/**\n * QuickPulse document types.\n * @internal\n */\nexport type QuickPulseDocumentType =\n | \"Event\"\n | \"Exception\"\n | \"Trace\"\n | \"Metric\"\n | \"Request\"\n | \"RemoteDependency\"\n | \"Availability\";\n/**\n * QuickPulse telemetry types.\n * @internal\n */\nexport type QuickPulseType =\n | \"EventTelemetryDocument\"\n | \"ExceptionTelemetryDocument\"\n | \"TraceTelemetryDocument\"\n | \"MetricTelemetryDocument\"\n | \"RequestTelemetryDocument\"\n | \"DependencyTelemetryDocument\"\n | \"AvailabilityTelemetryDocument\";\n"]}
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/Declarations/Constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,8CAAyB,CAAA;AAC3B,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAA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,EAAE,iBAAiB,CAAC,gBAAgB;IAEzE,kCAAkC;IAClC,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC,eAAe;IACtE,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,EAAE,iBAAiB,CAAC,oBAAoB;IAChF,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC,eAAe;IACtE,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,EAAE,iBAAiB,CAAC,uBAAuB;IACtF,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,iBAAiB,CAAC,mBAAmB;IAC9E,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,iBAAiB,CAAC,cAAc;CACrE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Azure service API version.\n */\nexport enum ServiceApiVersion {\n /**\n * V2 Version\n */\n V2 = \"2020-09-15_Preview\",\n}\n\n/**\n * Default Breeze endpoint.\n * @internal\n */\nexport const DEFAULT_BREEZE_ENDPOINT = \"https://dc.services.visualstudio.com\";\n/**\n * Default Breeze API version.\n * @internal\n */\nexport const DEFAULT_BREEZE_API_VERSION = ServiceApiVersion.V2;\n/**\n * Default Live Metrics endpoint.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_ENDPOINT = \"https://rt.services.visualstudio.com\";\n/**\n * Default Live Metrics host.\n * @internal\n */\nexport const DEFAULT_LIVEMETRICS_HOST = \"rt.services.visualstudio.com\";\n/**\n * Connection string environment variable name.\n * @internal\n */\nexport const ENV_CONNECTION_STRING = \"APPLICATIONINSIGHTS_CONNECTION_STRING\";\n/**\n * Instrumentation key environment variable name.\n * @internal\n */\nexport const ENV_INSTRUMENTATION_KEY = \"APPINSIGHTS_INSTRUMENTATIONKEY\";\n\n/**\n * QuickPulse metric counter names.\n * @internal\n */\nexport enum QuickPulseCounter {\n // Memory\n COMMITTED_BYTES = \"\\\\Memory\\\\Committed Bytes\",\n\n // CPU\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n\n // Request\n REQUEST_RATE = \"\\\\ApplicationInsights\\\\Requests/Sec\",\n REQUEST_FAILURE_RATE = \"\\\\ApplicationInsights\\\\Requests Failed/Sec\",\n REQUEST_DURATION = \"\\\\ApplicationInsights\\\\Request Duration\",\n\n // Dependency\n DEPENDENCY_RATE = \"\\\\ApplicationInsights\\\\Dependency Calls/Sec\",\n DEPENDENCY_FAILURE_RATE = \"\\\\ApplicationInsights\\\\Dependency Calls Failed/Sec\",\n DEPENDENCY_DURATION = \"\\\\ApplicationInsights\\\\Dependency Call Duration\",\n\n // Exception\n EXCEPTION_RATE = \"\\\\ApplicationInsights\\\\Exceptions/Sec\",\n}\n\n/**\n * Performance metric counter names.\n * @internal\n */\nexport enum PerformanceCounter {\n // Memory\n PRIVATE_BYTES = \"\\\\Process(??APP_WIN32_PROC??)\\\\Private Bytes\",\n AVAILABLE_BYTES = \"\\\\Memory\\\\Available Bytes\",\n\n // CPU\n PROCESSOR_TIME = \"\\\\Processor(_Total)\\\\% Processor Time\",\n PROCESS_TIME = \"\\\\Process(??APP_WIN32_PROC??)\\\\% Processor Time\",\n\n // Requests\n REQUEST_RATE = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Requests/Sec\",\n REQUEST_DURATION = \"\\\\ASP.NET Applications(??APP_W3SVC_PROC??)\\\\Request Execution Time\",\n}\n\n/**\n * Map a PerformanceCounter/QuickPulseCounter to a QuickPulseCounter. If no mapping exists, mapping is *undefined*\n * @internal\n */\nexport const PerformanceToQuickPulseCounter: { [key: string]: QuickPulseCounter } = {\n [PerformanceCounter.PROCESSOR_TIME]: QuickPulseCounter.PROCESSOR_TIME,\n [PerformanceCounter.REQUEST_RATE]: QuickPulseCounter.REQUEST_RATE,\n [PerformanceCounter.REQUEST_DURATION]: QuickPulseCounter.REQUEST_DURATION,\n\n // Remap quick pulse only counters\n [QuickPulseCounter.COMMITTED_BYTES]: QuickPulseCounter.COMMITTED_BYTES,\n [QuickPulseCounter.REQUEST_FAILURE_RATE]: QuickPulseCounter.REQUEST_FAILURE_RATE,\n [QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,\n [QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,\n [QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,\n [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE,\n};\n\n/**\n * QuickPulse document types.\n * @internal\n */\nexport type QuickPulseDocumentType =\n | \"Event\"\n | \"Exception\"\n | \"Trace\"\n | \"Metric\"\n | \"Request\"\n | \"RemoteDependency\"\n | \"Availability\";\n/**\n * QuickPulse telemetry types.\n * @internal\n */\nexport type QuickPulseType =\n | \"EventTelemetryDocument\"\n | \"ExceptionTelemetryDocument\"\n | \"TraceTelemetryDocument\"\n | \"MetricTelemetryDocument\"\n | \"RequestTelemetryDocument\"\n | \"DependencyTelemetryDocument\"\n | \"AvailabilityTelemetryDocument\";\n"]}
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { DEFAULT_BREEZE_API_VERSION, DEFAULT_BREEZE_ENDPOINT } from "./Declarations/Constants";
3
+ import { DEFAULT_BREEZE_API_VERSION, DEFAULT_BREEZE_ENDPOINT, } from "./Declarations/Constants";
4
4
  const DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60000;
5
5
  const DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;
6
6
  /**
@@ -12,6 +12,6 @@ export const DEFAULT_EXPORTER_CONFIG = {
12
12
  endpointUrl: DEFAULT_BREEZE_ENDPOINT,
13
13
  batchSendRetryIntervalMs: DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS,
14
14
  maxConsecutiveFailuresBeforeWarning: DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING,
15
- apiVersion: DEFAULT_BREEZE_API_VERSION
15
+ apiVersion: DEFAULT_BREEZE_API_VERSION,
16
16
  };
17
17
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EAExB,MAAM,0BAA0B,CAAC;AAElC,MAAM,oCAAoC,GAAG,KAAM,CAAC;AACpD,MAAM,+CAA+C,GAAG,EAAE,CAAC;AA6B3D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAgC;IAClE,kBAAkB,EAAE,EAAE;IACtB,WAAW,EAAE,uBAAuB;IACpC,wBAAwB,EAAE,oCAAoC;IAC9D,mCAAmC,EAAE,+CAA+C;IACpF,UAAU,EAAE,0BAA0B;CACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DEFAULT_BREEZE_API_VERSION,\n DEFAULT_BREEZE_ENDPOINT,\n ServiceApiVersion\n} from \"./Declarations/Constants\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\nconst DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;\n\n/**\n * Provides configuration options for AzureMonitorTraceExporter.\n */\nexport interface AzureExporterConfig {\n /**\n * Azure Monitor Connection String, if not provided the exporter will try to use environment variable APPLICATIONINSIGHTS_CONNECTION_STRING\n * Ex: \"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://dc.services.visualstudio.com\"\n */\n connectionString?: string;\n /**\n * Azure service API version.\n */\n apiVersion?: ServiceApiVersion;\n}\n\n/**\n * Internal Azure exporter configuration\n * @internal\n */\nexport interface AzureExporterInternalConfig {\n instrumentationKey: string;\n batchSendRetryIntervalMs: number;\n maxConsecutiveFailuresBeforeWarning: number;\n endpointUrl: string;\n apiVersion: ServiceApiVersion;\n}\n\n/**\n * Internal default Azure exporter configuration\n * @internal\n */\nexport const DEFAULT_EXPORTER_CONFIG: AzureExporterInternalConfig = {\n instrumentationKey: \"\",\n endpointUrl: DEFAULT_BREEZE_ENDPOINT,\n batchSendRetryIntervalMs: DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS,\n maxConsecutiveFailuresBeforeWarning: DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING,\n apiVersion: DEFAULT_BREEZE_API_VERSION\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,0BAA0B,CAAC;AAElC,MAAM,oCAAoC,GAAG,KAAM,CAAC;AACpD,MAAM,+CAA+C,GAAG,EAAE,CAAC;AA6B3D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAgC;IAClE,kBAAkB,EAAE,EAAE;IACtB,WAAW,EAAE,uBAAuB;IACpC,wBAAwB,EAAE,oCAAoC;IAC9D,mCAAmC,EAAE,+CAA+C;IACpF,UAAU,EAAE,0BAA0B;CACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DEFAULT_BREEZE_API_VERSION,\n DEFAULT_BREEZE_ENDPOINT,\n ServiceApiVersion,\n} from \"./Declarations/Constants\";\n\nconst DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60_000;\nconst DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;\n\n/**\n * Provides configuration options for AzureMonitorTraceExporter.\n */\nexport interface AzureExporterConfig {\n /**\n * Azure Monitor Connection String, if not provided the exporter will try to use environment variable APPLICATIONINSIGHTS_CONNECTION_STRING\n * Ex: \"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://dc.services.visualstudio.com\"\n */\n connectionString?: string;\n /**\n * Azure service API version.\n */\n apiVersion?: ServiceApiVersion;\n}\n\n/**\n * Internal Azure exporter configuration\n * @internal\n */\nexport interface AzureExporterInternalConfig {\n instrumentationKey: string;\n batchSendRetryIntervalMs: number;\n maxConsecutiveFailuresBeforeWarning: number;\n endpointUrl: string;\n apiVersion: ServiceApiVersion;\n}\n\n/**\n * Internal default Azure exporter configuration\n * @internal\n */\nexport const DEFAULT_EXPORTER_CONFIG: AzureExporterInternalConfig = {\n instrumentationKey: \"\",\n endpointUrl: DEFAULT_BREEZE_ENDPOINT,\n batchSendRetryIntervalMs: DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS,\n maxConsecutiveFailuresBeforeWarning: DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING,\n apiVersion: DEFAULT_BREEZE_API_VERSION,\n};\n"]}
@@ -4,7 +4,7 @@ import { diag } from "@opentelemetry/api";
4
4
  import { ExportResultCode } from "@opentelemetry/core";
5
5
  import { ConnectionStringParser } from "../utils/connectionStringParser";
6
6
  import { HttpSender, FileSystemPersist } from "../platform";
7
- import { DEFAULT_EXPORTER_CONFIG } from "../config";
7
+ import { DEFAULT_EXPORTER_CONFIG, } from "../config";
8
8
  import { isRetriable } from "../utils/breezeUtils";
9
9
  import { ENV_CONNECTION_STRING } from "../Declarations/Constants";
10
10
  import { readableSpanToEnvelope } from "../utils/spanUtils";
@@ -47,7 +47,7 @@ export class AzureMonitorTraceExporter {
47
47
  ? { code: ExportResultCode.SUCCESS }
48
48
  : {
49
49
  code: ExportResultCode.FAILED,
50
- error: new Error("Failed to persist envelope in disk.")
50
+ error: new Error("Failed to persist envelope in disk."),
51
51
  };
52
52
  }
53
53
  catch (ex) {
@@ -87,7 +87,7 @@ export class AzureMonitorTraceExporter {
87
87
  }
88
88
  // Failed -- not retriable
89
89
  return {
90
- code: ExportResultCode.FAILED
90
+ code: ExportResultCode.FAILED,
91
91
  };
92
92
  }
93
93
  else {
@@ -98,7 +98,7 @@ export class AzureMonitorTraceExporter {
98
98
  else {
99
99
  // Failed -- not retriable
100
100
  return {
101
- code: ExportResultCode.FAILED
101
+ code: ExportResultCode.FAILED,
102
102
  };
103
103
  }
104
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/export/trace.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAgB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,uBAAuB,EAGxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAOpC;;;OAGG;IACH,YAAY,UAA+B,EAAE;;QAC3C,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;QAClC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,qBACR,uBAAuB,CAC3B,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAE1E,IAAI,gBAAgB,EAAE;YACpB,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC9E,IAAI,CAAC,QAAQ,CAAC,kBAAkB;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O,GAAG,EAAE;YACZ,IAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC;IAEO,eAAe,CAAC,KAAgB;QACtC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { diag } from \"@opentelemetry/api\";\nimport { ExportResult, ExportResultCode } from \"@opentelemetry/core\";\nimport { ReadableSpan, SpanExporter } from \"@opentelemetry/tracing\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { ConnectionStringParser } from \"../utils/connectionStringParser\";\nimport { HttpSender, FileSystemPersist } from \"../platform\";\nimport {\n DEFAULT_EXPORTER_CONFIG,\n AzureExporterConfig,\n AzureExporterInternalConfig\n} from \"../config\";\nimport { PersistentStorage, Sender } from \"../types\";\nimport { isRetriable, BreezeResponse } from \"../utils/breezeUtils\";\nimport { ENV_CONNECTION_STRING } from \"../Declarations/Constants\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { readableSpanToEnvelope } from \"../utils/spanUtils\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Exporter.\n */\nexport class AzureMonitorTraceExporter implements SpanExporter {\n private readonly _persister: PersistentStorage;\n private readonly _sender: Sender;\n private _numConsecutiveRedirects: number;\n private _retryTimer: NodeJS.Timer | null;\n private readonly _options: AzureExporterInternalConfig;\n\n /**\n * Initializes a new instance of the AzureMonitorTraceExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n constructor(options: AzureExporterConfig = {}) {\n this._numConsecutiveRedirects = 0;\n const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];\n this._options = {\n ...DEFAULT_EXPORTER_CONFIG\n };\n this._options.apiVersion = options.apiVersion ?? this._options.apiVersion;\n\n if (connectionString) {\n const parsedConnectionString = ConnectionStringParser.parse(connectionString);\n this._options.instrumentationKey =\n parsedConnectionString.instrumentationkey ?? this._options.instrumentationKey;\n this._options.endpointUrl =\n parsedConnectionString.ingestionendpoint?.trim() ?? this._options.endpointUrl;\n }\n // Instrumentation key is required\n if (!this._options.instrumentationKey) {\n const message =\n \"No instrumentation key or connection string was provided to the Azure Monitor Exporter\";\n diag.error(message);\n throw new Error(message);\n }\n\n this._sender = new HttpSender(this._options);\n this._persister = new FileSystemPersist(this._options);\n this._retryTimer = null;\n diag.debug(\"AzureMonitorTraceExporter was successfully setup\");\n }\n\n private async _persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this._persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\")\n };\n } catch (ex) {\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n private async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n try {\n const { result, statusCode } = await this._sender.send(envelopes);\n this._numConsecutiveRedirects = 0;\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this._retryTimer) {\n this._retryTimer = setTimeout(() => {\n this._retryTimer = null;\n this._sendFirstPersistedFile();\n }, this._options.batchSendRetryIntervalMs);\n this._retryTimer.unref();\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n breezeResponse.errors.forEach((error) => {\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n if (filteredEnvelopes.length > 0) {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED\n };\n }\n } catch (error) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this._numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this._numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this._sender.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n return { code: ExportResultCode.FAILED, error: new Error(\"Circular redirect\") };\n }\n } else if (restError.statusCode && isRetriable(restError.statusCode)) {\n return await this._persist(envelopes);\n }\n if (this._isNetworkError(restError)) {\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message\n );\n return await this._persist(envelopes);\n }\n\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message\n );\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n /**\n * Export OpenTelemetry spans.\n * @param spans - Spans to export.\n * @param resultCallback - Result callback.\n */\n async export(\n spans: ReadableSpan[],\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n diag.info(`Exporting ${spans.length} span(s). Converting to envelopes...`);\n const envelopes = spans.map((span) =>\n readableSpanToEnvelope(span, this._options.instrumentationKey)\n );\n resultCallback(await this.exportEnvelopes(envelopes));\n }\n\n /**\n * Shutdown AzureMonitorTraceExporter.\n */\n async shutdown(): Promise<void> {\n diag.info(\"Azure Monitor Trace Exporter shutting down\");\n return this._sender.shutdown();\n }\n\n private async _sendFirstPersistedFile(): Promise<void> {\n try {\n const envelopes = (await this._persister.shift()) as Envelope[] | null;\n if (envelopes) {\n await this._sender.send(envelopes);\n }\n } catch (err) {\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private _isNetworkError(error: RestError): boolean {\n if (error && error.code && error.code === \"REQUEST_SEND_ERROR\") {\n return true;\n }\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/export/trace.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAgB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,uBAAuB,GAGxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAOpC;;;OAGG;IACH,YAAY,UAA+B,EAAE;;QAC3C,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;QAClC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,qBACR,uBAAuB,CAC3B,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAE1E,IAAI,gBAAgB,EAAE;YACpB,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC9E,IAAI,CAAC,QAAQ,CAAC,kBAAkB;gBAC9B,MAAA,sBAAsB,CAAC,kBAAkB,mCAAI,IAAI,CAAC,QAAQ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G,CAAC,CAAC;SAClD;IACH,CAAC;IAEO,eAAe,CAAC,KAAgB;QACtC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { diag } from \"@opentelemetry/api\";\nimport { ExportResult, ExportResultCode } from \"@opentelemetry/core\";\nimport { ReadableSpan, SpanExporter } from \"@opentelemetry/tracing\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { ConnectionStringParser } from \"../utils/connectionStringParser\";\nimport { HttpSender, FileSystemPersist } from \"../platform\";\nimport {\n DEFAULT_EXPORTER_CONFIG,\n AzureExporterConfig,\n AzureExporterInternalConfig,\n} from \"../config\";\nimport { PersistentStorage, Sender } from \"../types\";\nimport { isRetriable, BreezeResponse } from \"../utils/breezeUtils\";\nimport { ENV_CONNECTION_STRING } from \"../Declarations/Constants\";\nimport { TelemetryItem as Envelope } from \"../generated\";\nimport { readableSpanToEnvelope } from \"../utils/spanUtils\";\n\n/**\n * Azure Monitor OpenTelemetry Trace Exporter.\n */\nexport class AzureMonitorTraceExporter implements SpanExporter {\n private readonly _persister: PersistentStorage;\n private readonly _sender: Sender;\n private _numConsecutiveRedirects: number;\n private _retryTimer: NodeJS.Timer | null;\n private readonly _options: AzureExporterInternalConfig;\n\n /**\n * Initializes a new instance of the AzureMonitorTraceExporter class.\n * @param AzureExporterConfig - Exporter configuration.\n */\n constructor(options: AzureExporterConfig = {}) {\n this._numConsecutiveRedirects = 0;\n const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];\n this._options = {\n ...DEFAULT_EXPORTER_CONFIG,\n };\n this._options.apiVersion = options.apiVersion ?? this._options.apiVersion;\n\n if (connectionString) {\n const parsedConnectionString = ConnectionStringParser.parse(connectionString);\n this._options.instrumentationKey =\n parsedConnectionString.instrumentationkey ?? this._options.instrumentationKey;\n this._options.endpointUrl =\n parsedConnectionString.ingestionendpoint?.trim() ?? this._options.endpointUrl;\n }\n // Instrumentation key is required\n if (!this._options.instrumentationKey) {\n const message =\n \"No instrumentation key or connection string was provided to the Azure Monitor Exporter\";\n diag.error(message);\n throw new Error(message);\n }\n\n this._sender = new HttpSender(this._options);\n this._persister = new FileSystemPersist(this._options);\n this._retryTimer = null;\n diag.debug(\"AzureMonitorTraceExporter was successfully setup\");\n }\n\n private async _persist(envelopes: unknown[]): Promise<ExportResult> {\n try {\n const success = await this._persister.push(envelopes);\n return success\n ? { code: ExportResultCode.SUCCESS }\n : {\n code: ExportResultCode.FAILED,\n error: new Error(\"Failed to persist envelope in disk.\"),\n };\n } catch (ex) {\n return { code: ExportResultCode.FAILED, error: ex };\n }\n }\n\n private async exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {\n diag.info(`Exporting ${envelopes.length} envelope(s)`);\n\n try {\n const { result, statusCode } = await this._sender.send(envelopes);\n this._numConsecutiveRedirects = 0;\n if (statusCode === 200) {\n // Success -- @todo: start retry timer\n if (!this._retryTimer) {\n this._retryTimer = setTimeout(() => {\n this._retryTimer = null;\n this._sendFirstPersistedFile();\n }, this._options.batchSendRetryIntervalMs);\n this._retryTimer.unref();\n }\n return { code: ExportResultCode.SUCCESS };\n } else if (statusCode && isRetriable(statusCode)) {\n // Failed -- persist failed data\n if (result) {\n diag.info(result);\n const breezeResponse = JSON.parse(result) as BreezeResponse;\n const filteredEnvelopes: Envelope[] = [];\n breezeResponse.errors.forEach((error) => {\n if (error.statusCode && isRetriable(error.statusCode)) {\n filteredEnvelopes.push(envelopes[error.index]);\n }\n });\n if (filteredEnvelopes.length > 0) {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(filteredEnvelopes);\n }\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED,\n };\n } else {\n // calls resultCallback(ExportResult) based on result of persister.push\n return await this._persist(envelopes);\n }\n } else {\n // Failed -- not retriable\n return {\n code: ExportResultCode.FAILED,\n };\n }\n } catch (error) {\n const restError = error as RestError;\n if (\n restError.statusCode &&\n (restError.statusCode === 307 || // Temporary redirect\n restError.statusCode === 308)\n ) {\n // Permanent redirect\n this._numConsecutiveRedirects++;\n // To prevent circular redirects\n if (this._numConsecutiveRedirects < 10) {\n if (restError.response && restError.response.headers) {\n const location = restError.response.headers.get(\"location\");\n if (location) {\n // Update sender URL\n this._sender.handlePermanentRedirect(location);\n // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically\n return this.exportEnvelopes(envelopes);\n }\n }\n } else {\n return { code: ExportResultCode.FAILED, error: new Error(\"Circular redirect\") };\n }\n } else if (restError.statusCode && isRetriable(restError.statusCode)) {\n return await this._persist(envelopes);\n }\n if (this._isNetworkError(restError)) {\n diag.error(\n \"Retrying due to transient client side error. Error message:\",\n restError.message\n );\n return await this._persist(envelopes);\n }\n\n diag.error(\n \"Envelopes could not be exported and are not retriable. Error message:\",\n restError.message\n );\n return { code: ExportResultCode.FAILED, error: restError };\n }\n }\n\n /**\n * Export OpenTelemetry spans.\n * @param spans - Spans to export.\n * @param resultCallback - Result callback.\n */\n async export(\n spans: ReadableSpan[],\n resultCallback: (result: ExportResult) => void\n ): Promise<void> {\n diag.info(`Exporting ${spans.length} span(s). Converting to envelopes...`);\n const envelopes = spans.map((span) =>\n readableSpanToEnvelope(span, this._options.instrumentationKey)\n );\n resultCallback(await this.exportEnvelopes(envelopes));\n }\n\n /**\n * Shutdown AzureMonitorTraceExporter.\n */\n async shutdown(): Promise<void> {\n diag.info(\"Azure Monitor Trace Exporter shutting down\");\n return this._sender.shutdown();\n }\n\n private async _sendFirstPersistedFile(): Promise<void> {\n try {\n const envelopes = (await this._persister.shift()) as Envelope[] | null;\n if (envelopes) {\n await this._sender.send(envelopes);\n }\n } catch (err) {\n diag.warn(`Failed to fetch persisted file`, err);\n }\n }\n\n private _isNetworkError(error: RestError): boolean {\n if (error && error.code && error.code === \"REQUEST_SEND_ERROR\") {\n return true;\n }\n return false;\n }\n}\n"]}
@@ -7,6 +7,6 @@
7
7
  export const SDK_INFO = {
8
8
  NAME: "opentelemetry",
9
9
  RUNTIME: "node",
10
- LANGUAGE: "nodejs"
10
+ LANGUAGE: "nodejs",
11
11
  };
12
12
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,QAAQ;CACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * SDK info\n * @internal\n */\nexport const SDK_INFO = {\n NAME: \"opentelemetry\",\n RUNTIME: \"node\",\n LANGUAGE: \"nodejs\"\n};\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,QAAQ;CACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * SDK info\n * @internal\n */\nexport const SDK_INFO = {\n NAME: \"opentelemetry\",\n RUNTIME: \"node\",\n LANGUAGE: \"nodejs\",\n};\n"]}
@@ -3,7 +3,7 @@
3
3
  import url from "url";
4
4
  import { diag } from "@opentelemetry/api";
5
5
  import { redirectPolicyName } from "@azure/core-rest-pipeline";
6
- import { ApplicationInsightsClient } from "../../generated";
6
+ import { ApplicationInsightsClient, } from "../../generated";
7
7
  /**
8
8
  * Exporter HTTP sender class
9
9
  * @internal
@@ -13,7 +13,7 @@ export class HttpSender {
13
13
  this._exporterOptions = _exporterOptions;
14
14
  // Build endpoint using provided configuration or default values
15
15
  this._appInsightsClientOptions = {
16
- host: this._exporterOptions.endpointUrl
16
+ host: this._exporterOptions.endpointUrl,
17
17
  };
18
18
  this._appInsightsClient = new ApplicationInsightsClient(Object.assign({}, this._appInsightsClientOptions));
19
19
  this._appInsightsClient.pipeline.removePolicy({ name: redirectPolicyName });
@@ -1 +1 @@
1
- {"version":3,"file":"httpSender.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/httpSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAEL,yBAAyB,EAG1B,MAAM,iBAAiB,CAAC;AAGzB;;;GAGG;AACH,MAAM,OAAO,UAAU;IAIrB,YAAoB,gBAA6C;QAA7C,qBAAgB,GAAhB,gBAAgB,CAA6B;QAC/D,gEAAgE;QAChE,IAAI,CAAC,yBAAyB,GAAG;YAC/B,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW;SACxC,CAAC;QAEF,IAAI,CAAC,kBAAkB,GAAG,IAAI,yBAAyB,mBAClD,IAAI,CAAC,yBAAyB,EACjC,CAAC;QAEH,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,SAAqB;;QAC9B,IAAI,OAAO,GAAiD,EAAE,CAAC;QAC/D,IAAI;YACF,IAAI,QAA2C,CAAC;YAChD,SAAS,UAAU,CAAC,WAAkC,EAAE,YAAqB;gBAC3E,QAAQ,GAAG,WAAW,CAAC;gBACvB,IAAI,OAAO,CAAC,UAAU,EAAE;oBACtB,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;iBAC/C;YACH,CAAC;YACD,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,SAAS,kCACxC,OAAO,KACV,UAAU,IACV,CAAC;YAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,EAAE,MAAM,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,UAAU,mCAAI,EAAE,EAAE,CAAC;SAC7E;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACxC,CAAC;IAED,uBAAuB,CAAC,QAA4B;QAClD,IAAI,QAAQ,EAAE;YACZ,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE;gBACzB,IAAI,CAAC,kBAAkB,CAAC,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;aACzD;SACF;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport url from \"url\";\nimport { diag } from \"@opentelemetry/api\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport { Sender, SenderResult } from \"../../types\";\nimport {\n TelemetryItem as Envelope,\n ApplicationInsightsClient,\n ApplicationInsightsClientOptionalParams,\n ApplicationInsightsClientTrackOptionalParams\n} from \"../../generated\";\nimport { AzureExporterInternalConfig } from \"../../config\";\n\n/**\n * Exporter HTTP sender class\n * @internal\n */\nexport class HttpSender implements Sender {\n private readonly _appInsightsClient: ApplicationInsightsClient;\n private _appInsightsClientOptions: ApplicationInsightsClientOptionalParams;\n\n constructor(private _exporterOptions: AzureExporterInternalConfig) {\n // Build endpoint using provided configuration or default values\n this._appInsightsClientOptions = {\n host: this._exporterOptions.endpointUrl\n };\n\n this._appInsightsClient = new ApplicationInsightsClient({\n ...this._appInsightsClientOptions\n });\n\n this._appInsightsClient.pipeline.removePolicy({ name: redirectPolicyName });\n }\n\n /**\n * Send Azure envelopes\n * @internal\n */\n async send(envelopes: Envelope[]): Promise<SenderResult> {\n let options: ApplicationInsightsClientTrackOptionalParams = {};\n try {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n await this._appInsightsClient.track(envelopes, {\n ...options,\n onResponse\n });\n\n return { statusCode: response?.status, result: response?.bodyAsText ?? \"\" };\n } catch (e) {\n throw e;\n }\n }\n\n /**\n * Shutdown sender\n * @internal\n */\n async shutdown(): Promise<void> {\n diag.info(\"HttpSender shutting down\");\n }\n\n handlePermanentRedirect(location: string | undefined) {\n if (location) {\n const locUrl = new url.URL(location);\n if (locUrl && locUrl.host) {\n this._appInsightsClient.host = \"https://\" + locUrl.host;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"httpSender.js","sourceRoot":"","sources":["../../../../src/platform/nodejs/httpSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAEL,yBAAyB,GAG1B,MAAM,iBAAiB,CAAC;AAGzB;;;GAGG;AACH,MAAM,OAAO,UAAU;IAIrB,YAAoB,gBAA6C;QAA7C,qBAAgB,GAAhB,gBAAgB,CAA6B;QAC/D,gEAAgE;QAChE,IAAI,CAA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BAAkB,CAAC,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;aACzD;SACF;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport url from \"url\";\nimport { diag } from \"@opentelemetry/api\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport { Sender, SenderResult } from \"../../types\";\nimport {\n TelemetryItem as Envelope,\n ApplicationInsightsClient,\n ApplicationInsightsClientOptionalParams,\n ApplicationInsightsClientTrackOptionalParams,\n} from \"../../generated\";\nimport { AzureExporterInternalConfig } from \"../../config\";\n\n/**\n * Exporter HTTP sender class\n * @internal\n */\nexport class HttpSender implements Sender {\n private readonly _appInsightsClient: ApplicationInsightsClient;\n private _appInsightsClientOptions: ApplicationInsightsClientOptionalParams;\n\n constructor(private _exporterOptions: AzureExporterInternalConfig) {\n // Build endpoint using provided configuration or default values\n this._appInsightsClientOptions = {\n host: this._exporterOptions.endpointUrl,\n };\n\n this._appInsightsClient = new ApplicationInsightsClient({\n ...this._appInsightsClientOptions,\n });\n\n this._appInsightsClient.pipeline.removePolicy({ name: redirectPolicyName });\n }\n\n /**\n * Send Azure envelopes\n * @internal\n */\n async send(envelopes: Envelope[]): Promise<SenderResult> {\n let options: ApplicationInsightsClientTrackOptionalParams = {};\n try {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n await this._appInsightsClient.track(envelopes, {\n ...options,\n onResponse,\n });\n\n return { statusCode: response?.status, result: response?.bodyAsText ?? \"\" };\n } catch (e) {\n throw e;\n }\n }\n\n /**\n * Shutdown sender\n * @internal\n */\n async shutdown(): Promise<void> {\n diag.info(\"HttpSender shutting down\");\n }\n\n handlePermanentRedirect(location: string | undefined) {\n if (location) {\n const locUrl = new url.URL(location);\n if (locUrl && locUrl.host) {\n this._appInsightsClient.host = \"https://\" + locUrl.host;\n }\n }\n }\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.5";
22
+ export const packageVersion = "1.0.0-beta.6";
23
23
  export var DependencyTypes;
24
24
  (function (DependencyTypes) {
25
25
  DependencyTypes["InProc"] = "InProc";
@@ -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,cAAc,CAAC;AAE7C,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","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.5\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\"\n}\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,cAAc,CAAC;AAE7C,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","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.6\";\n\nexport enum DependencyTypes {\n InProc = \"InProc\",\n QueueMessage = \"Queue Message\",\n Sql = \"SQL\",\n Http = \"Http\",\n Grpc = \"GRPC\",\n}\n"]}
@@ -4,7 +4,7 @@ import { SpanKind } from "@opentelemetry/api";
4
4
  import { hrTimeToMilliseconds } from "@opentelemetry/core";
5
5
  import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
6
6
  import { TIME_SINCE_ENQUEUED, ENQUEUED_TIME } from "./constants/applicationinsights";
7
- import { AzNamespace, MessageBusDestination } from "./constants/span/azAttributes";
7
+ import { AzNamespace, MessageBusDestination, } from "./constants/span/azAttributes";
8
8
  /**
9
9
  * Average span.links[].attributes.enqueuedTime
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"eventhub.js","sourceRoot":"","sources":["../../../src/utils/eventhub.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EACL,WAAW,EACX,qBAAqB,EAEtB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,IAAkB,EAAE,EAAE;IAClD,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QACpC,MAAM,YAAY,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,aAAa,CAAoB,CAAC;QACpE,IAAI,YAAY,EAAE;YAChB,iBAAiB,IAAI,CAAC,CAAC;YACvB,eAAe,IAAI,WAAW,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;SAC7E;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF;;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"@opentelemetry/api\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { SemanticAttributes } from \"@opentelemetry/semantic-conventions\";\nimport { ReadableSpan } from \"@opentelemetry/tracing\";\nimport { RemoteDependencyData, RequestData } from \"../generated\";\nimport { TIME_SINCE_ENQUEUED, ENQUEUED_TIME } from \"./constants/applicationinsights\";\nimport {\n AzNamespace,\n MessageBusDestination,\n MicrosoftEventHub\n} from \"./constants/span/azAttributes\";\n\n/**\n * Average span.links[].attributes.enqueuedTime\n */\nconst getTimeSinceEnqueued = (span: ReadableSpan) => {\n let countEnqueueDiffs = 0;\n let sumEnqueueDiffs = 0;\n const startTimeMs = hrTimeToMilliseconds(span.startTime);\n\n span.links.forEach(({ attributes }) => {\n const enqueuedTime = attributes?.[ENQUEUED_TIME] as string | number;\n if (enqueuedTime) {\n countEnqueueDiffs += 1;\n sumEnqueueDiffs += startTimeMs - (parseFloat(enqueuedTime.toString()) || 0);\n }\n });\n\n return Math.max(sumEnqueueDiffs / (countEnqueueDiffs || 1), 0);\n};\n\n/**\n * Implementation of Mapping to Azure Monitor\n *\n * https://gist.github.com/lmolkova/e4215c0f44a49ef824983382762e6b92#mapping-to-azure-monitor-application-insights-telemetry\n * @internal\n */\nexport const parseEventHubSpan = (\n span: ReadableSpan,\n baseData: RequestData | RemoteDependencyData\n): void => {\n const namespace = span.attributes[AzNamespace] as typeof MicrosoftEventHub;\n const peerAddress = ((span.attributes[SemanticAttributes.NET_PEER_NAME] ||\n span.attributes[\"peer.address\"] ||\n \"unknown\") as string).replace(/\\/$/g, \"\"); // remove trailing \"/\"\n const messageBusDestination = (span.attributes[MessageBusDestination] || \"unknown\") as string;\n\n switch (span.kind) {\n case SpanKind.CLIENT:\n baseData.type = namespace;\n baseData.target = `${peerAddress}/${messageBusDestination}`;\n break;\n case SpanKind.PRODUCER:\n baseData.type = `Queue Message | ${namespace}`;\n baseData.target = `${peerAddress}/${messageBusDestination}`;\n break;\n case SpanKind.CONSUMER:\n baseData.type = `Queue Message | ${namespace}`;\n (baseData as any).source = `${peerAddress}/${messageBusDestination}`;\n baseData.measurements = {\n ...baseData.measurements,\n [TIME_SINCE_ENQUEUED]: getTimeSinceEnqueued(span)\n };\n break;\n default: // no op\n }\n};\n"]}
1
+ {"version":3,"file":"eventhub.js","sourceRoot":"","sources":["../../../src/utils/eventhub.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EACL,WAAW,EACX,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,IAAkB,EAAE,EAAE;IAClD,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QACpC,MAAM,YAAY,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,aAAa,CAAoB,CAAC;QACpE,IAAI,YAAY,EAAE;YAChB,iBAAiB,IAAI,CAAC,CAAC;YACvB,eAAe,IAAI,WAAW,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;SAC7E;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjE,CAA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\nimport { SpanKind } from \"@opentelemetry/api\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { SemanticAttributes } from \"@opentelemetry/semantic-conventions\";\nimport { ReadableSpan } from \"@opentelemetry/tracing\";\nimport { RemoteDependencyData, RequestData } from \"../generated\";\nimport { TIME_SINCE_ENQUEUED, ENQUEUED_TIME } from \"./constants/applicationinsights\";\nimport {\n AzNamespace,\n MessageBusDestination,\n MicrosoftEventHub,\n} from \"./constants/span/azAttributes\";\n\n/**\n * Average span.links[].attributes.enqueuedTime\n */\nconst getTimeSinceEnqueued = (span: ReadableSpan) => {\n let countEnqueueDiffs = 0;\n let sumEnqueueDiffs = 0;\n const startTimeMs = hrTimeToMilliseconds(span.startTime);\n\n span.links.forEach(({ attributes }) => {\n const enqueuedTime = attributes?.[ENQUEUED_TIME] as string | number;\n if (enqueuedTime) {\n countEnqueueDiffs += 1;\n sumEnqueueDiffs += startTimeMs - (parseFloat(enqueuedTime.toString()) || 0);\n }\n });\n\n return Math.max(sumEnqueueDiffs / (countEnqueueDiffs || 1), 0);\n};\n\n/**\n * Implementation of Mapping to Azure Monitor\n *\n * https://gist.github.com/lmolkova/e4215c0f44a49ef824983382762e6b92#mapping-to-azure-monitor-application-insights-telemetry\n * @internal\n */\nexport const parseEventHubSpan = (\n span: ReadableSpan,\n baseData: RequestData | RemoteDependencyData\n): void => {\n const namespace = span.attributes[AzNamespace] as typeof MicrosoftEventHub;\n const peerAddress = (\n (span.attributes[SemanticAttributes.NET_PEER_NAME] ||\n span.attributes[\"peer.address\"] ||\n \"unknown\") as string\n ).replace(/\\/$/g, \"\"); // remove trailing \"/\"\n const messageBusDestination = (span.attributes[MessageBusDestination] || \"unknown\") as string;\n\n switch (span.kind) {\n case SpanKind.CLIENT:\n baseData.type = namespace;\n baseData.target = `${peerAddress}/${messageBusDestination}`;\n break;\n case SpanKind.PRODUCER:\n baseData.type = `Queue Message | ${namespace}`;\n baseData.target = `${peerAddress}/${messageBusDestination}`;\n break;\n case SpanKind.CONSUMER:\n baseData.type = `Queue Message | ${namespace}`;\n (baseData as any).source = `${peerAddress}/${messageBusDestination}`;\n baseData.measurements = {\n ...baseData.measurements,\n [TIME_SINCE_ENQUEUED]: getTimeSinceEnqueued(span),\n };\n break;\n default: // no op\n }\n};\n"]}
@@ -4,13 +4,13 @@ import os from "os";
4
4
  import { URL } from "url";
5
5
  import { hrTimeToMilliseconds } from "@opentelemetry/core";
6
6
  import { diag, SpanKind, SpanStatusCode } from "@opentelemetry/api";
7
- import { SemanticResourceAttributes, SemanticAttributes, DbSystemValues } from "@opentelemetry/semantic-conventions";
7
+ import { SemanticResourceAttributes, SemanticAttributes, DbSystemValues, } from "@opentelemetry/semantic-conventions";
8
8
  import { msToTimeSpan } from "./breezeUtils";
9
9
  import { getInstance } from "../platform";
10
10
  import { parseEventHubSpan } from "./eventhub";
11
11
  import { DependencyTypes, MS_LINKS } from "./constants/applicationinsights";
12
12
  import { AzNamespace, MicrosoftEventHub } from "./constants/span/azAttributes";
13
- import { KnownContextTagKeys } from "../generated";
13
+ import { KnownContextTagKeys, } from "../generated";
14
14
  function createTagsFromSpan(span) {
15
15
  const context = getInstance();
16
16
  const tags = Object.assign({}, context.tags);
@@ -95,7 +95,7 @@ function createPropertiesFromSpan(span) {
95
95
  }
96
96
  const links = span.links.map((link) => ({
97
97
  operation_Id: link.context.traceId,
98
- id: link.context.spanId
98
+ id: link.context.spanId,
99
99
  }));
100
100
  if (links.length > 0) {
101
101
  properties[MS_LINKS] = JSON.stringify(links);
@@ -179,7 +179,7 @@ function createDependencyData(span) {
179
179
  resultCode: "0",
180
180
  type: "Dependency",
181
181
  duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),
182
- version: 2
182
+ version: 2,
183
183
  };
184
184
  if (span.kind === SpanKind.PRODUCER) {
185
185
  remoteDependencyData.type = DependencyTypes.QueueMessage;
@@ -287,7 +287,7 @@ function createRequestData(span) {
287
287
  responseCode: "0",
288
288
  duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),
289
289
  version: 2,
290
- source: undefined
290
+ source: undefined,
291
291
  };
292
292
  const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];
293
293
  const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];
@@ -355,8 +355,8 @@ export function readableSpanToEnvelope(span, ikey) {
355
355
  data: {
356
356
  baseType,
357
357
  baseData: Object.assign(Object.assign({}, baseData), { properties,
358
- measurements })
359
- }
358
+ measurements }),
359
+ },
360
360
  };
361
361
  }
362
362
  //# sourceMappingURL=spanUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spanUtils.js","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAQ,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACf,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAIL,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAEtB,SAAS,kBAAkB,CAAC,IAAkB;IAC5C,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,IAAI,qBAAc,OAAO,CAAC,IAAI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,CAAC,MAAM,CAAC;QACrB,KAAK,QAAQ,CAAC,QAAQ;YACpB,IAAI,GAAG,uCAAuC,CAAC;YAC/C,QAAQ,GAAG,aAAa,CAAC;YACzB,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACnC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;YAC1D,MAAM;QACR;YACE,QAAQ;YACR,IAAI,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KACzD;IAED,YAAY;IACZ,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,QAAQ,EAAE;YACnC,QAAQ,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,MAAM,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;SAC/E;QACD,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,iBAAiB,EAAE;YACtD,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SACnC;KACF;IAED,OAAO;QACL,IAAI;QACJ,UAAU;QACV,IAAI;QACJ,kBAAkB;QAClB,IAAI;QACJ,OAAO,EAAE,CAAC;QACV,IAAI,EAAE;YACJ,QAAQ;YACR,QAAQ,kCACH,QAAQ,KACX,UAAU;gBACV,YAAY,GACb;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport os from \"os\";\nimport { URL } from \"url\";\nimport { ReadableSpan } from \"@opentelemetry/tracing\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { diag, SpanKind, SpanStatusCode, Link } from \"@opentelemetry/api\";\nimport {\n SemanticResourceAttributes,\n SemanticAttributes,\n DbSystemValues\n} from \"@opentelemetry/semantic-conventions\";\n\nimport { Tags, Properties, MSLink, Measurements } from \"../types\";\nimport { msToTimeSpan } from \"./breezeUtils\";\nimport { getInstance } from \"../platform\";\nimport { parseEventHubSpan } from \"./eventhub\";\nimport { DependencyTypes, MS_LINKS } from \"./constants/applicationinsights\";\nimport { AzNamespace, MicrosoftEventHub } from \"./constants/span/azAttributes\";\nimport {\n RemoteDependencyData,\n RequestData,\n TelemetryItem as Envelope,\n KnownContextTagKeys\n} from \"../generated\";\n\nfunction createTagsFromSpan(span: ReadableSpan): Tags {\n const context = getInstance();\n const tags: Tags = { ...context.tags };\n\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n if (span.parentSpanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanId;\n }\n if (span.resource && span.resource.attributes) {\n const serviceName = span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME];\n const serviceNamespace = span.resource.attributes[SemanticResourceAttributes.SERVICE_NAMESPACE];\n if (serviceName) {\n if (serviceNamespace) {\n tags[KnownContextTagKeys.AiCloudRole] = `${serviceNamespace}.${serviceName}`;\n } else {\n tags[KnownContextTagKeys.AiCloudRole] = String(serviceName);\n }\n }\n const serviceInstanceId =\n span.resource.attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID];\n if (serviceInstanceId) {\n tags[KnownContextTagKeys.AiCloudRoleInstance] = String(serviceInstanceId);\n } else {\n tags[KnownContextTagKeys.AiCloudRoleInstance] = os && os.hostname();\n }\n const endUserId = span.resource.attributes[SemanticAttributes.ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n }\n if (span.kind === SpanKind.SERVER) {\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const httpClientIp = span.attributes[SemanticAttributes.HTTP_CLIENT_IP];\n const netPeerIp = span.attributes[SemanticAttributes.NET_PEER_IP];\n if (httpMethod) {\n const httpRoute = span.attributes[SemanticAttributes.HTTP_ROUTE];\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n tags[KnownContextTagKeys.AiOperationName] = span.name; // Default\n if (httpRoute) {\n tags[\n KnownContextTagKeys.AiOperationName\n ] = `${httpMethod as string} ${httpRoute as string}`;\n } else if (httpUrl) {\n try {\n let url = new URL(String(httpUrl));\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod} ${url.pathname}`;\n } catch (ex) {}\n }\n if (httpClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);\n } else if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n } else {\n tags[KnownContextTagKeys.AiOperationName] = span.name;\n if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n }\n }\n // TODO: Operation Name and Location IP TBD for non server spans\n\n const httpUserAgent = span.attributes[SemanticAttributes.HTTP_USER_AGENT];\n if (httpUserAgent) {\n // TODO: Not exposed in Swagger, need to update def\n tags[\"ai.user.userAgent\"] = String(httpUserAgent);\n }\n\n return tags;\n}\n\nfunction createPropertiesFromSpan(span: ReadableSpan): [Properties, Measurements] {\n const properties: Properties = {};\n const measurements: Measurements = {};\n\n for (const key of Object.keys(span.attributes)) {\n if (\n !(\n key.startsWith(\"http.\") ||\n key.startsWith(\"rpc.\") ||\n key.startsWith(\"db.\") ||\n key.startsWith(\"peer.\") ||\n key.startsWith(\"net.\")\n )\n ) {\n properties[key] = span.attributes[key] as string;\n }\n }\n\n const links: MSLink[] = span.links.map((link: Link) => ({\n operation_Id: link.context.traceId,\n id: link.context.spanId\n }));\n\n if (links.length > 0) {\n properties[MS_LINKS] = JSON.stringify(links);\n }\n\n return [properties, measurements];\n}\n\nfunction 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\nfunction getUrl(span: ReadableSpan): string {\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = span.attributes[SemanticAttributes.HTTP_SCHEME];\n const httpTarget = span.attributes[SemanticAttributes.HTTP_TARGET];\n if (httpScheme && httpTarget) {\n const httpHost = span.attributes[SemanticAttributes.HTTP_HOST];\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = span.attributes[SemanticAttributes.NET_PEER_PORT];\n if (netPeerPort) {\n const netPeerName = span.attributes[SemanticAttributes.NET_PEER_NAME];\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = span.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\nfunction getDependencyTarget(span: ReadableSpan): string {\n const peerService = span.attributes[SemanticAttributes.PEER_SERVICE];\n const httpHost = span.attributes[SemanticAttributes.HTTP_HOST];\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n const netPeerName = span.attributes[SemanticAttributes.NET_PEER_NAME];\n const netPeerIp = span.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\nfunction createDependencyData(span: ReadableSpan): RemoteDependencyData {\n const remoteDependencyData: RemoteDependencyData = {\n name: span.name, //Default\n id: `${span.spanContext().spanId}`,\n success: span.status.code != SpanStatusCode.ERROR,\n resultCode: \"0\",\n type: \"Dependency\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2\n };\n if (span.kind === SpanKind.PRODUCER) {\n remoteDependencyData.type = DependencyTypes.QueueMessage;\n }\n if (span.kind === SpanKind.INTERNAL && span.parentSpanId) {\n remoteDependencyData.type = DependencyTypes.InProc;\n }\n\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const dbSystem = span.attributes[SemanticAttributes.DB_SYSTEM];\n const rpcSystem = span.attributes[SemanticAttributes.RPC_SYSTEM];\n // HTTP Dependency\n if (httpMethod) {\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n try {\n let dependencyUrl = new URL(String(httpUrl));\n remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;\n } catch (ex) {}\n }\n remoteDependencyData.type = DependencyTypes.Http;\n remoteDependencyData.data = getUrl(span);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n remoteDependencyData.resultCode = String(httpStatusCode);\n }\n let target = getDependencyTarget(span);\n if (target) {\n try {\n // Remove default port\n let portRegex = new RegExp(/(https?)(:\\/\\/.*)(:\\d+)(\\S*)/);\n let res = portRegex.exec(target);\n if (res != null) {\n let protocol = res[1];\n let port = res[3];\n if ((protocol == \"https\" && port == \":443\") || (protocol == \"http\" && port == \":80\")) {\n // Drop port\n target = res[1] + res[2] + res[4];\n }\n }\n } catch (error) {}\n remoteDependencyData.target = `${target}`;\n }\n }\n // DB Dependency\n else if (dbSystem) {\n // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem\n if (String(dbSystem) === DbSystemValues.MYSQL) {\n remoteDependencyData.type = \"mysql\";\n } else if (String(dbSystem) === DbSystemValues.POSTGRESQL) {\n remoteDependencyData.type = \"postgresql\";\n } else if (String(dbSystem) === DbSystemValues.MONGODB) {\n remoteDependencyData.type = \"mongodb\";\n } else if (String(dbSystem) === DbSystemValues.REDIS) {\n remoteDependencyData.type = \"redis\";\n } else if (isSqlDB(String(dbSystem))) {\n remoteDependencyData.type = \"SQL\";\n } else {\n remoteDependencyData.type = String(dbSystem);\n }\n const dbStatement = span.attributes[SemanticAttributes.DB_STATEMENT];\n const dbOperation = span.attributes[SemanticAttributes.DB_OPERATION];\n if (dbStatement) {\n remoteDependencyData.data = String(dbStatement);\n } else if (dbOperation) {\n remoteDependencyData.data = String(dbOperation);\n }\n let target = getDependencyTarget(span);\n const dbName = span.attributes[SemanticAttributes.DB_NAME];\n if (target) {\n remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;\n } else {\n remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;\n }\n }\n // grpc Dependency\n else if (rpcSystem) {\n remoteDependencyData.type = DependencyTypes.Grpc;\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (grpcStatusCode) {\n remoteDependencyData.resultCode = String(grpcStatusCode);\n }\n let target = getDependencyTarget(span);\n if (target) {\n remoteDependencyData.target = `${target}`;\n } else if (rpcSystem) {\n remoteDependencyData.target = String(rpcSystem);\n }\n }\n return remoteDependencyData;\n}\n\nfunction createRequestData(span: ReadableSpan): RequestData {\n const requestData: RequestData = {\n id: `${span.spanContext().spanId}`,\n success: span.status.code != SpanStatusCode.ERROR,\n responseCode: \"0\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n source: undefined\n };\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (httpMethod) {\n requestData.url = getUrl(span);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n requestData.responseCode = String(httpStatusCode);\n }\n } else if (grpcStatusCode) {\n requestData.responseCode = String(grpcStatusCode);\n }\n return requestData;\n}\n\n/**\n * Span to Azure envelope parsing.\n * @internal\n */\nexport function readableSpanToEnvelope(span: ReadableSpan, ikey: string): Envelope {\n let name: string;\n let baseType: \"RemoteDependencyData\" | \"RequestData\";\n const sampleRate = 100;\n let baseData: RemoteDependencyData | RequestData;\n\n const time = new Date(hrTimeToMilliseconds(span.startTime));\n const instrumentationKey = ikey;\n const tags = createTagsFromSpan(span);\n const [properties, measurements] = createPropertiesFromSpan(span);\n switch (span.kind) {\n case SpanKind.CLIENT:\n case SpanKind.PRODUCER:\n case SpanKind.INTERNAL:\n name = \"Microsoft.ApplicationInsights.RemoteDependency\";\n baseType = \"RemoteDependencyData\";\n baseData = createDependencyData(span);\n break;\n case SpanKind.SERVER:\n case SpanKind.CONSUMER:\n name = \"Microsoft.ApplicationInsights.Request\";\n baseType = \"RequestData\";\n baseData = createRequestData(span);\n baseData.name = tags[KnownContextTagKeys.AiOperationName];\n break;\n default:\n // never\n diag.error(`Unsupported span kind ${span.kind}`);\n throw new Error(`Unsupported span kind ${span.kind}`);\n }\n\n // Azure SDK\n if (span.attributes[AzNamespace]) {\n if (span.kind === SpanKind.INTERNAL) {\n baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;\n }\n if (span.attributes[AzNamespace] === MicrosoftEventHub) {\n parseEventHubSpan(span, baseData);\n }\n }\n\n return {\n name,\n sampleRate,\n time,\n instrumentationKey,\n tags,\n version: 1,\n data: {\n baseType,\n baseData: {\n ...baseData,\n properties,\n measurements\n }\n }\n };\n}\n"]}
1
+ {"version":3,"file":"spanUtils.js","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI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W,CAAC,EAAE,CAAC;SAC/E;QACD,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,iBAAiB,EAAE;YACtD,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SACnC;KACF;IAED,OAAO;QACL,IAAI;QACJ,UAAU;QACV,IAAI;QACJ,kBAAkB;QAClB,IAAI;QACJ,OAAO,EAAE,CAAC;QACV,IAAI,EAAE;YACJ,QAAQ;YACR,QAAQ,kCACH,QAAQ,KACX,UAAU;gBACV,YAAY,GACb;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport os from \"os\";\nimport { URL } from \"url\";\nimport { ReadableSpan } from \"@opentelemetry/tracing\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport { diag, SpanKind, SpanStatusCode, Link } from \"@opentelemetry/api\";\nimport {\n SemanticResourceAttributes,\n SemanticAttributes,\n DbSystemValues,\n} from \"@opentelemetry/semantic-conventions\";\n\nimport { Tags, Properties, MSLink, Measurements } from \"../types\";\nimport { msToTimeSpan } from \"./breezeUtils\";\nimport { getInstance } from \"../platform\";\nimport { parseEventHubSpan } from \"./eventhub\";\nimport { DependencyTypes, MS_LINKS } from \"./constants/applicationinsights\";\nimport { AzNamespace, MicrosoftEventHub } from \"./constants/span/azAttributes\";\nimport {\n RemoteDependencyData,\n RequestData,\n TelemetryItem as Envelope,\n KnownContextTagKeys,\n} from \"../generated\";\n\nfunction createTagsFromSpan(span: ReadableSpan): Tags {\n const context = getInstance();\n const tags: Tags = { ...context.tags };\n\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n if (span.parentSpanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanId;\n }\n if (span.resource && span.resource.attributes) {\n const serviceName = span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME];\n const serviceNamespace = span.resource.attributes[SemanticResourceAttributes.SERVICE_NAMESPACE];\n if (serviceName) {\n if (serviceNamespace) {\n tags[KnownContextTagKeys.AiCloudRole] = `${serviceNamespace}.${serviceName}`;\n } else {\n tags[KnownContextTagKeys.AiCloudRole] = String(serviceName);\n }\n }\n const serviceInstanceId =\n span.resource.attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID];\n if (serviceInstanceId) {\n tags[KnownContextTagKeys.AiCloudRoleInstance] = String(serviceInstanceId);\n } else {\n tags[KnownContextTagKeys.AiCloudRoleInstance] = os && os.hostname();\n }\n const endUserId = span.resource.attributes[SemanticAttributes.ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n }\n if (span.kind === SpanKind.SERVER) {\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const httpClientIp = span.attributes[SemanticAttributes.HTTP_CLIENT_IP];\n const netPeerIp = span.attributes[SemanticAttributes.NET_PEER_IP];\n if (httpMethod) {\n const httpRoute = span.attributes[SemanticAttributes.HTTP_ROUTE];\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n tags[KnownContextTagKeys.AiOperationName] = span.name; // Default\n if (httpRoute) {\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod as string} ${\n httpRoute as string\n }`;\n } else if (httpUrl) {\n try {\n let url = new URL(String(httpUrl));\n tags[KnownContextTagKeys.AiOperationName] = `${httpMethod} ${url.pathname}`;\n } catch (ex) {}\n }\n if (httpClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);\n } else if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n } else {\n tags[KnownContextTagKeys.AiOperationName] = span.name;\n if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n }\n }\n // TODO: Operation Name and Location IP TBD for non server spans\n\n const httpUserAgent = span.attributes[SemanticAttributes.HTTP_USER_AGENT];\n if (httpUserAgent) {\n // TODO: Not exposed in Swagger, need to update def\n tags[\"ai.user.userAgent\"] = String(httpUserAgent);\n }\n\n return tags;\n}\n\nfunction createPropertiesFromSpan(span: ReadableSpan): [Properties, Measurements] {\n const properties: Properties = {};\n const measurements: Measurements = {};\n\n for (const key of Object.keys(span.attributes)) {\n if (\n !(\n key.startsWith(\"http.\") ||\n key.startsWith(\"rpc.\") ||\n key.startsWith(\"db.\") ||\n key.startsWith(\"peer.\") ||\n key.startsWith(\"net.\")\n )\n ) {\n properties[key] = span.attributes[key] as string;\n }\n }\n\n const links: MSLink[] = span.links.map((link: Link) => ({\n operation_Id: link.context.traceId,\n id: link.context.spanId,\n }));\n\n if (links.length > 0) {\n properties[MS_LINKS] = JSON.stringify(links);\n }\n\n return [properties, measurements];\n}\n\nfunction 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\nfunction getUrl(span: ReadableSpan): string {\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n return String(httpUrl);\n } else {\n const httpScheme = span.attributes[SemanticAttributes.HTTP_SCHEME];\n const httpTarget = span.attributes[SemanticAttributes.HTTP_TARGET];\n if (httpScheme && httpTarget) {\n const httpHost = span.attributes[SemanticAttributes.HTTP_HOST];\n if (httpHost) {\n return `${httpScheme}://${httpHost}${httpTarget}`;\n } else {\n const netPeerPort = span.attributes[SemanticAttributes.NET_PEER_PORT];\n if (netPeerPort) {\n const netPeerName = span.attributes[SemanticAttributes.NET_PEER_NAME];\n if (netPeerName) {\n return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;\n } else {\n const netPeerIp = span.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\nfunction getDependencyTarget(span: ReadableSpan): string {\n const peerService = span.attributes[SemanticAttributes.PEER_SERVICE];\n const httpHost = span.attributes[SemanticAttributes.HTTP_HOST];\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n const netPeerName = span.attributes[SemanticAttributes.NET_PEER_NAME];\n const netPeerIp = span.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\nfunction createDependencyData(span: ReadableSpan): RemoteDependencyData {\n const remoteDependencyData: RemoteDependencyData = {\n name: span.name, //Default\n id: `${span.spanContext().spanId}`,\n success: span.status.code != SpanStatusCode.ERROR,\n resultCode: \"0\",\n type: \"Dependency\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n };\n if (span.kind === SpanKind.PRODUCER) {\n remoteDependencyData.type = DependencyTypes.QueueMessage;\n }\n if (span.kind === SpanKind.INTERNAL && span.parentSpanId) {\n remoteDependencyData.type = DependencyTypes.InProc;\n }\n\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const dbSystem = span.attributes[SemanticAttributes.DB_SYSTEM];\n const rpcSystem = span.attributes[SemanticAttributes.RPC_SYSTEM];\n // HTTP Dependency\n if (httpMethod) {\n const httpUrl = span.attributes[SemanticAttributes.HTTP_URL];\n if (httpUrl) {\n try {\n let dependencyUrl = new URL(String(httpUrl));\n remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;\n } catch (ex) {}\n }\n remoteDependencyData.type = DependencyTypes.Http;\n remoteDependencyData.data = getUrl(span);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n remoteDependencyData.resultCode = String(httpStatusCode);\n }\n let target = getDependencyTarget(span);\n if (target) {\n try {\n // Remove default port\n let portRegex = new RegExp(/(https?)(:\\/\\/.*)(:\\d+)(\\S*)/);\n let res = portRegex.exec(target);\n if (res != null) {\n let protocol = res[1];\n let port = res[3];\n if ((protocol == \"https\" && port == \":443\") || (protocol == \"http\" && port == \":80\")) {\n // Drop port\n target = res[1] + res[2] + res[4];\n }\n }\n } catch (error) {}\n remoteDependencyData.target = `${target}`;\n }\n }\n // DB Dependency\n else if (dbSystem) {\n // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem\n if (String(dbSystem) === DbSystemValues.MYSQL) {\n remoteDependencyData.type = \"mysql\";\n } else if (String(dbSystem) === DbSystemValues.POSTGRESQL) {\n remoteDependencyData.type = \"postgresql\";\n } else if (String(dbSystem) === DbSystemValues.MONGODB) {\n remoteDependencyData.type = \"mongodb\";\n } else if (String(dbSystem) === DbSystemValues.REDIS) {\n remoteDependencyData.type = \"redis\";\n } else if (isSqlDB(String(dbSystem))) {\n remoteDependencyData.type = \"SQL\";\n } else {\n remoteDependencyData.type = String(dbSystem);\n }\n const dbStatement = span.attributes[SemanticAttributes.DB_STATEMENT];\n const dbOperation = span.attributes[SemanticAttributes.DB_OPERATION];\n if (dbStatement) {\n remoteDependencyData.data = String(dbStatement);\n } else if (dbOperation) {\n remoteDependencyData.data = String(dbOperation);\n }\n let target = getDependencyTarget(span);\n const dbName = span.attributes[SemanticAttributes.DB_NAME];\n if (target) {\n remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;\n } else {\n remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;\n }\n }\n // grpc Dependency\n else if (rpcSystem) {\n remoteDependencyData.type = DependencyTypes.Grpc;\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (grpcStatusCode) {\n remoteDependencyData.resultCode = String(grpcStatusCode);\n }\n let target = getDependencyTarget(span);\n if (target) {\n remoteDependencyData.target = `${target}`;\n } else if (rpcSystem) {\n remoteDependencyData.target = String(rpcSystem);\n }\n }\n return remoteDependencyData;\n}\n\nfunction createRequestData(span: ReadableSpan): RequestData {\n const requestData: RequestData = {\n id: `${span.spanContext().spanId}`,\n success: span.status.code != SpanStatusCode.ERROR,\n responseCode: \"0\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n source: undefined,\n };\n const httpMethod = span.attributes[SemanticAttributes.HTTP_METHOD];\n const grpcStatusCode = span.attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n if (httpMethod) {\n requestData.url = getUrl(span);\n const httpStatusCode = span.attributes[SemanticAttributes.HTTP_STATUS_CODE];\n if (httpStatusCode) {\n requestData.responseCode = String(httpStatusCode);\n }\n } else if (grpcStatusCode) {\n requestData.responseCode = String(grpcStatusCode);\n }\n return requestData;\n}\n\n/**\n * Span to Azure envelope parsing.\n * @internal\n */\nexport function readableSpanToEnvelope(span: ReadableSpan, ikey: string): Envelope {\n let name: string;\n let baseType: \"RemoteDependencyData\" | \"RequestData\";\n const sampleRate = 100;\n let baseData: RemoteDependencyData | RequestData;\n\n const time = new Date(hrTimeToMilliseconds(span.startTime));\n const instrumentationKey = ikey;\n const tags = createTagsFromSpan(span);\n const [properties, measurements] = createPropertiesFromSpan(span);\n switch (span.kind) {\n case SpanKind.CLIENT:\n case SpanKind.PRODUCER:\n case SpanKind.INTERNAL:\n name = \"Microsoft.ApplicationInsights.RemoteDependency\";\n baseType = \"RemoteDependencyData\";\n baseData = createDependencyData(span);\n break;\n case SpanKind.SERVER:\n case SpanKind.CONSUMER:\n name = \"Microsoft.ApplicationInsights.Request\";\n baseType = \"RequestData\";\n baseData = createRequestData(span);\n baseData.name = tags[KnownContextTagKeys.AiOperationName];\n break;\n default:\n // never\n diag.error(`Unsupported span kind ${span.kind}`);\n throw new Error(`Unsupported span kind ${span.kind}`);\n }\n\n // Azure SDK\n if (span.attributes[AzNamespace]) {\n if (span.kind === SpanKind.INTERNAL) {\n baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;\n }\n if (span.attributes[AzNamespace] === MicrosoftEventHub) {\n parseEventHubSpan(span, baseData);\n }\n }\n\n return {\n name,\n sampleRate,\n time,\n instrumentationKey,\n tags,\n version: 1,\n data: {\n baseType,\n baseData: {\n ...baseData,\n properties,\n measurements,\n },\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -2,32 +2,32 @@
2
2
  "name": "@azure/monitor-opentelemetry-exporter",
3
3
  "author": "Microsoft Corporation",
4
4
  "sdk-type": "client",
5
- "version": "1.0.0-beta.5",
5
+ "version": "1.0.0-beta.6",
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",
9
9
  "types": "types/monitor-opentelemetry-exporter.d.ts",
10
10
  "scripts": {
11
11
  "clean": "rimraf dist-esm types dist",
12
- "build:autorest": "autorest ./swagger/README.md --typescript --v3",
13
12
  "build:browser": "echo skipped",
14
13
  "build:test": "echo skipped",
15
- "build:node": "tsc -p . && rollup -c 2>&1",
14
+ "build:node": "tsc -p . && dev-tool run bundle --browser-test=false",
16
15
  "build": "npm run build:node && npm run build:browser && api-extractor run --local",
17
16
  "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
18
17
  "extract-api": "tsc -p . && api-extractor run --local",
19
18
  "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
19
+ "generate:client": "autorest --typescript ./swagger/README.md",
20
20
  "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
21
21
  "lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o telemetry-exporter-lintReport.html || exit 0",
22
22
  "test": "npm run test:node && npm run test:browser",
23
23
  "test:node": "npm run unit-test:node",
24
24
  "test:browser": "npm run unit-test:browser",
25
25
  "unit-test:browser": "echo skipped",
26
- "unit-test:node": "nyc mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/internal/**/*.test.ts\"",
27
- "unit-test:node:debug": "nyc mocha --inspect-brk -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/internal/**/*.test.ts\"",
26
+ "unit-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"dist-esm/test/internal/**/*.test.js\"",
27
+ "unit-test:node:debug": "nyc mocha --inspect-brk -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"dist-esm/test/internal/**/*.test.js\"",
28
28
  "unit-test:node:no-timeout": "echo skipped",
29
29
  "unit-test": "npm run unit-test:node && npm run unit-test:browser",
30
- "functional-test": "nyc mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/internal/functional/*.test.ts\"",
30
+ "functional-test": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"dist-esm/test/internal/functional/*.test.js\"",
31
31
  "integration-test:browser": "echo skipped",
32
32
  "integration-test:node": "npm run functional-test",
33
33
  "integration-test": "npm run integration-test:node && npm run integration-test:browser",
@@ -36,8 +36,7 @@
36
36
  "prepare": "npm run build",
37
37
  "pack": "npm pack 2>&1",
38
38
  "build:samples": "echo Obsolete.",
39
- "execute:samples": "dev-tool samples run samples-dev",
40
- "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
39
+ "execute:samples": "dev-tool samples run samples-dev"
41
40
  },
42
41
  "engines": {
43
42
  "node": ">=12.0.0"
@@ -87,9 +86,9 @@
87
86
  "@azure/dev-tool": "^1.0.0",
88
87
  "@azure/eslint-plugin-azure-sdk": "^3.0.0",
89
88
  "@microsoft/api-extractor": "^7.18.11",
90
- "@opentelemetry/instrumentation": "0.22.0",
91
- "@opentelemetry/instrumentation-http": "0.22.0",
92
- "@opentelemetry/node": "0.22.0",
89
+ "@opentelemetry/instrumentation": "^0.27.0",
90
+ "@opentelemetry/instrumentation-http": "^0.27.0",
91
+ "@opentelemetry/node": "^0.24.0",
93
92
  "@types/mocha": "^7.0.2",
94
93
  "@types/node": "^12.0.0",
95
94
  "dotenv": "^8.2.0",
@@ -98,23 +97,21 @@
98
97
  "execa": "^5.0.0",
99
98
  "mocha": "^7.1.1",
100
99
  "nock": "^12.0.3",
101
- "nyc": "^14.0.0",
102
- "prettier": "^1.16.4",
100
+ "nyc": "^15.0.0",
101
+ "prettier": "^2.5.1",
103
102
  "rimraf": "^3.0.0",
104
- "rollup": "^1.16.3",
105
103
  "sinon": "^9.0.2",
106
104
  "ts-node": "^10.0.0",
107
- "typedoc": "0.15.2",
108
105
  "typescript": "~4.2.0"
109
106
  },
110
107
  "dependencies": {
111
108
  "@azure/core-client": "^1.0.0",
112
109
  "@azure/core-rest-pipeline": "^1.1.0",
113
- "@opentelemetry/api": "^1.0.1",
114
- "@opentelemetry/core": "^0.22.0",
115
- "@opentelemetry/resources": "^0.22.0",
116
- "@opentelemetry/semantic-conventions": "^0.24.0",
117
- "@opentelemetry/tracing": "^0.22.0",
110
+ "@opentelemetry/api": "~1.0.3",
111
+ "@opentelemetry/core": "~1.0.1",
112
+ "@opentelemetry/resources": "^1.0.1",
113
+ "@opentelemetry/semantic-conventions": "^1.0.1",
114
+ "@opentelemetry/tracing": "^0.24.0",
118
115
  "tslib": "^2.2.0"
119
116
  },
120
117
  "sideEffects": false,