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

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,12 @@
1
1
  # Release History
2
2
 
3
+ ## 1.0.0-beta.7 (2022-04-05)
4
+
5
+ ### Features Added
6
+
7
+ - Added authentication support using @azure/identity TokenCredential.
8
+ - Added file access control in Windows for retriable telemetry.
9
+
3
10
  ## 1.0.0-beta.6 (2022-02-08)
4
11
 
5
12
  ### Other Changes
package/README.md CHANGED
@@ -28,8 +28,8 @@ Add the exporter to your existing OpenTelemetry tracer provider (`NodeTracerProv
28
28
 
29
29
  ```js
30
30
  const { AzureMonitorTraceExporter } = require("@azure/monitor-opentelemetry-exporter");
31
- const { NodeTracerProvider } = require("@opentelemetry/node");
32
- const { BatchSpanProcessor } = require("@opentelemetry/tracing");
31
+ const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
32
+ const { BatchSpanProcessor } = require("@opentelemetry/sdk-trace-base");
33
33
 
34
34
  // Use your existing provider
35
35
  const provider = new NodeTracerProvider({
@@ -44,7 +44,8 @@ provider.register();
44
44
 
45
45
  // Create an exporter instance
46
46
  const exporter = new AzureMonitorTraceExporter({
47
- instrumentationKey: "ikey"
47
+ connectionString:
48
+ process.env["APPLICATIONINSIGHTS_CONNECTION_STRING"] || "<your connection string>"
48
49
  });
49
50
 
50
51
  // Add the exporter to the provider
@@ -79,15 +80,12 @@ For more information on the OpenTelemetry project, please review the [**OpenTele
79
80
  You can enable debug logging by changing the logging level of your provider.
80
81
 
81
82
  ```js
82
- const provider = new NodeTracerProvider({
83
- logLevel: LogLevel.DEBUG,
84
- plugins: {
85
- https: {
86
- // Ignore Application Insights Ingestion Server
87
- ignoreOutgoingUrls: [new RegExp(/dc.services.visualstudio.com/i)]
88
- }
89
- }
90
- });
83
+ const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
84
+ const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
85
+
86
+ const provider = new NodeTracerProvider();
87
+ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL);
88
+ provider.register();
91
89
  ```
92
90
 
93
91
  ## Next steps
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var coreRestPipeline = require('@azure/core-rest-pipeline');
11
11
  var coreClient = require('@azure/core-client');
12
12
  var fs = require('fs');
13
13
  var path = require('path');
14
+ var child_process = require('child_process');
14
15
  var util = require('util');
15
16
 
16
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -39,6 +40,7 @@ var url__default = /*#__PURE__*/_interopDefaultLegacy(url);
39
40
  var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
40
41
  var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
41
42
  var path__namespace = /*#__PURE__*/_interopNamespace(path);
43
+ var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
42
44
 
43
45
  // Copyright (c) Microsoft Corporation.
44
46
  // Licensed under the MIT license.
@@ -191,7 +193,6 @@ class ConnectionStringParser {
191
193
  ConnectionStringParser.FIELDS_SEPARATOR = ";";
192
194
  ConnectionStringParser.FIELD_KEY_VALUE_SEPARATOR = "=";
193
195
 
194
- // Copyright (c) Microsoft Corporation.
195
196
  const DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60000;
196
197
  const DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;
197
198
  /**
@@ -206,6 +207,172 @@ const DEFAULT_EXPORTER_CONFIG = {
206
207
  apiVersion: DEFAULT_BREEZE_API_VERSION,
207
208
  };
208
209
 
210
+ // Copyright (c) Microsoft Corporation.
211
+ class FileAccessControl {
212
+ // Check if file access control could be enabled
213
+ static checkFileProtection() {
214
+ if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION &&
215
+ !FileAccessControl.OS_FILE_PROTECTION_CHECKED) {
216
+ FileAccessControl.OS_FILE_PROTECTION_CHECKED = true;
217
+ // Node's chmod levels do not appropriately restrict file access on Windows
218
+ // Use the built-in command line tool ICACLS on Windows to properly restrict
219
+ // access to the temporary directory used for disk retry mode.
220
+ if (FileAccessControl.USE_ICACLS) {
221
+ // This should be async - but it's currently safer to have this synchronous
222
+ // This guarantees we can immediately fail setDiskRetryMode if we need to
223
+ try {
224
+ FileAccessControl.OS_PROVIDES_FILE_PROTECTION = fs__namespace.existsSync(FileAccessControl.ICACLS_PATH);
225
+ }
226
+ catch (e) {
227
+ // Ignore error
228
+ }
229
+ if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION) {
230
+ api.diag.warn("Could not find ICACLS in expected location! This is necessary to use disk retry mode on Windows.");
231
+ }
232
+ }
233
+ else {
234
+ // chmod works everywhere else
235
+ FileAccessControl.OS_PROVIDES_FILE_PROTECTION = true;
236
+ }
237
+ }
238
+ }
239
+ static async applyACLRules(directory) {
240
+ if (FileAccessControl.USE_ICACLS) {
241
+ if (FileAccessControl.ACLED_DIRECTORIES[directory] === undefined) {
242
+ // Avoid multiple calls race condition by setting ACLED_DIRECTORIES to false for this directory immediately
243
+ // If batches are being failed faster than the processes spawned below return, some data won't be stored to disk
244
+ // This is better than the alternative of potentially infinitely spawned processes
245
+ FileAccessControl.ACLED_DIRECTORIES[directory] = false;
246
+ try {
247
+ // Restrict this directory to only current user and administrator access
248
+ let identity = await this._getACLIdentity();
249
+ await this._runICACLS(this._getACLArguments(directory, identity));
250
+ FileAccessControl.ACLED_DIRECTORIES[directory] = true;
251
+ }
252
+ catch (ex) {
253
+ FileAccessControl.ACLED_DIRECTORIES[directory] = false; // false is used to cache failed (vs undefined which is "not yet tried")
254
+ throw ex;
255
+ }
256
+ }
257
+ else {
258
+ if (!FileAccessControl.ACLED_DIRECTORIES[directory]) {
259
+ throw new Error("Setting ACL restrictions did not succeed (cached result)");
260
+ }
261
+ }
262
+ }
263
+ }
264
+ static applyACLRulesSync(directory) {
265
+ if (FileAccessControl.USE_ICACLS) {
266
+ // For performance, only run ACL rules if we haven't already during this session
267
+ if (FileAccessControl.ACLED_DIRECTORIES[directory] === undefined) {
268
+ this._runICACLSSync(this._getACLArguments(directory, this._getACLIdentitySync()));
269
+ FileAccessControl.ACLED_DIRECTORIES[directory] = true; // If we get here, it succeeded. _runIACLSSync will throw on failures
270
+ return;
271
+ }
272
+ else if (!FileAccessControl.ACLED_DIRECTORIES[directory]) {
273
+ // falsy but not undefined
274
+ throw new Error("Setting ACL restrictions did not succeed (cached result)");
275
+ }
276
+ }
277
+ }
278
+ static _runICACLS(args) {
279
+ return new Promise((resolve, reject) => {
280
+ var aclProc = child_process__namespace.spawn(FileAccessControl.ICACLS_PATH, args, {
281
+ windowsHide: true,
282
+ });
283
+ aclProc.on("error", (e) => reject(e));
284
+ aclProc.on("close", (code) => {
285
+ if (code === 0) {
286
+ resolve();
287
+ }
288
+ else {
289
+ reject(new Error(`Setting ACL restrictions did not succeed (ICACLS returned code ${code})`));
290
+ }
291
+ });
292
+ });
293
+ }
294
+ static _runICACLSSync(args) {
295
+ // Some very old versions of Node (< 0.11) don't have this
296
+ if (child_process__namespace.spawnSync) {
297
+ var aclProc = child_process__namespace.spawnSync(FileAccessControl.ICACLS_PATH, args, {
298
+ windowsHide: true,
299
+ });
300
+ if (aclProc.error) {
301
+ throw aclProc.error;
302
+ }
303
+ else if (aclProc.status !== 0) {
304
+ throw new Error(`Setting ACL restrictions did not succeed (ICACLS returned code ${aclProc.status})`);
305
+ }
306
+ }
307
+ else {
308
+ throw new Error("Could not synchronously call ICACLS under current version of Node.js");
309
+ }
310
+ }
311
+ static _getACLIdentity() {
312
+ return new Promise((resolve, reject) => {
313
+ if (FileAccessControl.ACL_IDENTITY) {
314
+ resolve(FileAccessControl.ACL_IDENTITY);
315
+ }
316
+ var psProc = child_process__namespace.spawn(FileAccessControl.POWERSHELL_PATH, ["-Command", "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"], {
317
+ windowsHide: true,
318
+ stdio: ["ignore", "pipe", "pipe"], // Needed to prevent hanging on Win 7
319
+ });
320
+ let data = "";
321
+ psProc.stdout.on("data", (d) => (data += d));
322
+ psProc.on("error", (e) => reject(e));
323
+ psProc.on("close", (code) => {
324
+ FileAccessControl.ACL_IDENTITY = data && data.trim();
325
+ if (code === 0) {
326
+ resolve(FileAccessControl.ACL_IDENTITY);
327
+ }
328
+ else {
329
+ reject(new Error(`Getting ACL identity did not succeed (PS returned code ${code})`));
330
+ }
331
+ });
332
+ });
333
+ }
334
+ static _getACLIdentitySync() {
335
+ if (FileAccessControl.ACL_IDENTITY) {
336
+ return FileAccessControl.ACL_IDENTITY;
337
+ }
338
+ // Some very old versions of Node (< 0.11) don't have this
339
+ if (child_process__namespace.spawnSync) {
340
+ var psProc = child_process__namespace.spawnSync(FileAccessControl.POWERSHELL_PATH, ["-Command", "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"], {
341
+ windowsHide: true,
342
+ stdio: ["ignore", "pipe", "pipe"], // Needed to prevent hanging on Win 7
343
+ });
344
+ if (psProc.error) {
345
+ throw psProc.error;
346
+ }
347
+ else if (psProc.status !== 0) {
348
+ throw new Error(`Getting ACL identity did not succeed (PS returned code ${psProc.status})`);
349
+ }
350
+ FileAccessControl.ACL_IDENTITY = psProc.stdout && psProc.stdout.toString().trim();
351
+ return FileAccessControl.ACL_IDENTITY;
352
+ }
353
+ else {
354
+ throw new Error("Could not synchronously get ACL identity under current version of Node.js");
355
+ }
356
+ }
357
+ static _getACLArguments(directory, identity) {
358
+ return [
359
+ directory,
360
+ "/grant",
361
+ "*S-1-5-32-544:(OI)(CI)F",
362
+ "/grant",
363
+ `${identity}:(OI)(CI)F`,
364
+ "/inheritance:r",
365
+ ]; // Remove all inherited permissions
366
+ }
367
+ }
368
+ FileAccessControl.ICACLS_PATH = `${process.env.systemdrive}/windows/system32/icacls.exe`;
369
+ FileAccessControl.POWERSHELL_PATH = `${process.env.systemdrive}/windows/system32/windowspowershell/v1.0/powershell.exe`;
370
+ FileAccessControl.ACLED_DIRECTORIES = {};
371
+ FileAccessControl.ACL_IDENTITY = null;
372
+ FileAccessControl.OS_FILE_PROTECTION_CHECKED = false;
373
+ FileAccessControl.OS_PROVIDES_FILE_PROTECTION = false;
374
+ FileAccessControl.USE_ICACLS = os__namespace.type() === "Windows_NT";
375
+
209
376
  // Copyright (c) Microsoft Corporation.
210
377
  const readdirAsync$1 = util.promisify(fs__namespace.readdir);
211
378
  const statAsync$1 = util.promisify(fs__namespace.stat);
@@ -269,36 +436,56 @@ class FileSystemPersist {
269
436
  this.fileRetemptionPeriod = 7 * 24 * 60 * 60 * 1000; // 7 days
270
437
  this.cleanupTimeOut = 60 * 60 * 1000; // 1 hour
271
438
  this.maxBytesOnDisk = 50000000; // ~50MB
439
+ this._tempDirectory = "";
272
440
  this._fileCleanupTimer = null;
273
441
  this._options = Object.assign(Object.assign({}, DEFAULT_EXPORTER_CONFIG), options);
274
- if (!this._options.instrumentationKey) {
275
- api.diag.error(`No instrumentation key was provided to FileSystemPersister. Files may not be properly persisted`);
442
+ this._enabled = true;
443
+ FileAccessControl.checkFileProtection();
444
+ if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION) {
445
+ this._enabled = false;
446
+ api.diag.error("Sufficient file protection capabilities were not detected. Files will not be persisted");
276
447
  }
277
- this._tempDirectory = path__namespace.join(os__namespace.tmpdir(), FileSystemPersist.TEMPDIR_PREFIX + this._options.instrumentationKey);
278
- // Starts file cleanup task
279
- if (!this._fileCleanupTimer) {
280
- this._fileCleanupTimer = setTimeout(() => {
281
- this._fileCleanupTask();
282
- }, this.cleanupTimeOut);
283
- this._fileCleanupTimer.unref();
448
+ if (!this._options.instrumentationKey) {
449
+ this._enabled = false;
450
+ api.diag.error(`No instrumentation key was provided to FileSystemPersister. Files will not be persisted`);
451
+ }
452
+ if (this._enabled) {
453
+ this._tempDirectory = path__namespace.join(os__namespace.tmpdir(), FileSystemPersist.TEMPDIR_PREFIX + this._options.instrumentationKey);
454
+ // Starts file cleanup task
455
+ if (!this._fileCleanupTimer) {
456
+ this._fileCleanupTimer = setTimeout(() => {
457
+ this._fileCleanupTask();
458
+ }, this.cleanupTimeOut);
459
+ this._fileCleanupTimer.unref();
460
+ }
284
461
  }
285
462
  }
286
463
  push(value) {
287
- api.diag.debug("Pushing value to persistent storage", value.toString());
288
- return this._storeToDisk(JSON.stringify(value));
464
+ if (this._enabled) {
465
+ api.diag.debug("Pushing value to persistent storage", value.toString());
466
+ return this._storeToDisk(JSON.stringify(value));
467
+ }
468
+ return new Promise((resolve) => {
469
+ resolve(false);
470
+ });
289
471
  }
290
472
  async shift() {
291
- api.diag.debug("Searching for filesystem persisted files");
292
- try {
293
- const buffer = await this._getFirstFileOnDisk();
294
- if (buffer) {
295
- return JSON.parse(buffer.toString("utf8"));
473
+ if (this._enabled) {
474
+ api.diag.debug("Searching for filesystem persisted files");
475
+ try {
476
+ const buffer = await this._getFirstFileOnDisk();
477
+ if (buffer) {
478
+ return JSON.parse(buffer.toString("utf8"));
479
+ }
296
480
  }
481
+ catch (e) {
482
+ api.diag.debug("Failed to read persisted file", e);
483
+ }
484
+ return null;
297
485
  }
298
- catch (e) {
299
- api.diag.debug("Failed to read persisted file", e);
300
- }
301
- return null;
486
+ return new Promise((resolve) => {
487
+ resolve(null);
488
+ });
302
489
  }
303
490
  /**
304
491
  * Check for temp telemetry files
@@ -1397,13 +1584,13 @@ class ApplicationInsightsClientContext extends coreClient__namespace.ServiceClie
1397
1584
  const defaults = {
1398
1585
  requestContentType: "application/json; charset=utf-8"
1399
1586
  };
1400
- const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.4`;
1587
+ const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.7`;
1401
1588
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1402
1589
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1403
1590
  : `${packageDetails}`;
1404
1591
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1405
1592
  userAgentPrefix
1406
- }, baseUri: options.endpoint || "{Host}/v2" });
1593
+ }, baseUri: options.endpoint || "{Host}/v2.1" });
1407
1594
  super(optionsWithDefaults);
1408
1595
  // Assigning values to Constant parameters
1409
1596
  this.host = options.host || "https://dc.services.visualstudio.com";
@@ -1475,6 +1662,7 @@ const trackOperationSpec = {
1475
1662
  };
1476
1663
 
1477
1664
  // Copyright (c) Microsoft Corporation.
1665
+ const applicationInsightsResource = "https://monitor.azure.com//.default";
1478
1666
  /**
1479
1667
  * Exporter HTTP sender class
1480
1668
  * @internal
@@ -1487,7 +1675,15 @@ class HttpSender {
1487
1675
  host: this._exporterOptions.endpointUrl,
1488
1676
  };
1489
1677
  this._appInsightsClient = new ApplicationInsightsClient(Object.assign({}, this._appInsightsClientOptions));
1678
+ // Handle redirects in HTTP Sender
1490
1679
  this._appInsightsClient.pipeline.removePolicy({ name: coreRestPipeline.redirectPolicyName });
1680
+ if (this._exporterOptions.aadTokenCredential) {
1681
+ let scopes = [applicationInsightsResource];
1682
+ this._appInsightsClient.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
1683
+ credential: this._exporterOptions.aadTokenCredential,
1684
+ scopes: scopes,
1685
+ }));
1686
+ }
1491
1687
  }
1492
1688
  /**
1493
1689
  * Send Azure envelopes
@@ -1549,7 +1745,7 @@ const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
1549
1745
  * AzureMonitorTraceExporter version.
1550
1746
  * @internal
1551
1747
  */
1552
- const packageVersion = "1.0.0-beta.6";
1748
+ const packageVersion = "1.0.0-beta.7";
1553
1749
  var DependencyTypes;
1554
1750
  (function (DependencyTypes) {
1555
1751
  DependencyTypes["InProc"] = "InProc";
@@ -1603,12 +1799,13 @@ function getInstance() {
1603
1799
  * @internal
1604
1800
  */
1605
1801
  function isRetriable(statusCode) {
1606
- return (statusCode === 206 || // Retriable
1802
+ return (statusCode === 206 || // Partial Accept
1803
+ statusCode === 401 || // Unauthorized
1804
+ statusCode === 403 || // Forbidden
1607
1805
  statusCode === 408 || // Timeout
1608
- statusCode === 429 || // Throttle
1609
- statusCode === 439 || // Quota
1806
+ statusCode === 429 || // Too many requests
1610
1807
  statusCode === 500 || // Server Error
1611
- statusCode === 503 // Server Unavilable
1808
+ statusCode === 503 // Server Unavailable
1612
1809
  );
1613
1810
  }
1614
1811
  /**
@@ -2060,6 +2257,7 @@ class AzureMonitorTraceExporter {
2060
2257
  const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];
2061
2258
  this._options = Object.assign({}, DEFAULT_EXPORTER_CONFIG);
2062
2259
  this._options.apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : this._options.apiVersion;
2260
+ this._options.aadTokenCredential = options.aadTokenCredential;
2063
2261
  if (connectionString) {
2064
2262
  const parsedConnectionString = ConnectionStringParser.parse(connectionString);
2065
2263
  this._options.instrumentationKey =
@@ -1,5 +1,3 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
1
  import { DEFAULT_BREEZE_API_VERSION, DEFAULT_BREEZE_ENDPOINT, } from "./Declarations/Constants";
4
2
  const DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60000;
5
3
  const DEFAULT_MAX_CONSECUTIVE_FAILURES_BEFORE_WARNING = 10;
@@ -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,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"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,0BAA0B,CAAC;AAElC,MAAM,oCAAoC,GAAG,KAAM,CAAC;AACpD,MAAM,+CAA+C,GAAG,EAAE,CAAC;AAkC3D;;;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.\nimport { TokenCredential } from \"@azure/core-http\";\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 * Azure Active Directory Credential\n */\n aadTokenCredential?: TokenCredential;\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 aadTokenCredential?: TokenCredential;\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"]}
@@ -22,6 +22,7 @@ export class AzureMonitorTraceExporter {
22
22
  const connectionString = options.connectionString || process.env[ENV_CONNECTION_STRING];
23
23
  this._options = Object.assign({}, DEFAULT_EXPORTER_CONFIG);
24
24
  this._options.apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : this._options.apiVersion;
25
+ this._options.aadTokenCredential = options.aadTokenCredential;
25
26
  if (connectionString) {
26
27
  const parsedConnectionString = ConnectionStringParser.parse(connectionString);
27
28
  this._options.instrumentationKey =
@@ -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,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,qB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,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACnC,IAAI;YACF,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAsB,CAAC;YACvE,IAAI,SAAS,EAAE;gBACb,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACpC;SACF;QAAC,OAAO,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,U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OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACnC,IAAI;YACF,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAsB,CAAC;YACvE,IAAI,SAAS,EAAE;gBACb,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACpC;SACF;QAAC,OAAO,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/sdk-trace-base\";\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 this._options.aadTokenCredential = options.aadTokenCredential;\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 +1 @@
1
- {"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAQtF,MAAM,OAAO,yBAA0B,SAAQ,gCAAgC;IAC7E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CACH,IAAqB,EACrB,OAAsD;QAEtD,OAAO,IAAI,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAC1E,CAAC;CACF;AACD,2BAA2B;AAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,kBAAkB,GAA6B;IACnD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport { ApplicationInsightsClientContext } from \"./applicationInsightsClientContext\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n ApplicationInsightsClientTrackOptionalParams,\n ApplicationInsightsClientTrackResponse\n} from \"./models\";\n\nexport class ApplicationInsightsClient extends ApplicationInsightsClientContext {\n /**\n * Initializes a new instance of the ApplicationInsightsClient class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n super(options);\n }\n\n /**\n * This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.\n * @param body The list of telemetry events to track.\n * @param options The options parameters.\n */\n track(\n body: TelemetryItem[],\n options?: ApplicationInsightsClientTrackOptionalParams\n ): Promise<ApplicationInsightsClientTrackResponse> {\n return this.sendOperationRequest({ body, options }, trackOperationSpec);\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst trackOperationSpec: coreClient.OperationSpec = {\n path: \"/track\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.TrackResponse\n },\n 206: {\n bodyMapper: Mappers.TrackResponse\n },\n 400: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 402: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 429: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 500: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 503: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n }\n },\n requestBody: Parameters.body,\n urlParameters: [Parameters.host],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer\n};\n"]}
1
+ {"version":3,"file":"applicationInsightsClient.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAQtF,MAAM,OAAO,yBAA0B,SAAQ,gCAAgC;IAC7E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CACH,IAAqB,EACrB,OAA6B;QAE7B,OAAO,IAAI,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAC1E,CAAC;CACF;AACD,2BAA2B;AAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,kBAAkB,GAA6B;IACnD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;SAClC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI;SACd;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport * as Parameters from \"./models/parameters\";\nimport * as Mappers from \"./models/mappers\";\nimport { ApplicationInsightsClientContext } from \"./applicationInsightsClientContext\";\nimport {\n ApplicationInsightsClientOptionalParams,\n TelemetryItem,\n TrackOptionalParams,\n TrackOperationResponse\n} from \"./models\";\n\nexport class ApplicationInsightsClient extends ApplicationInsightsClientContext {\n /**\n * Initializes a new instance of the ApplicationInsightsClient class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n super(options);\n }\n\n /**\n * This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.\n * @param body The list of telemetry events to track.\n * @param options The options parameters.\n */\n track(\n body: TelemetryItem[],\n options?: TrackOptionalParams\n ): Promise<TrackOperationResponse> {\n return this.sendOperationRequest({ body, options }, trackOperationSpec);\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst trackOperationSpec: coreClient.OperationSpec = {\n path: \"/track\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.TrackResponse\n },\n 206: {\n bodyMapper: Mappers.TrackResponse\n },\n 400: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 402: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 429: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 500: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n },\n 503: {\n bodyMapper: Mappers.TrackResponse,\n isError: true\n }\n },\n requestBody: Parameters.body,\n urlParameters: [Parameters.host],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer\n};\n"]}
@@ -19,13 +19,13 @@ export class ApplicationInsightsClientContext extends coreClient.ServiceClient {
19
19
  const defaults = {
20
20
  requestContentType: "application/json; charset=utf-8"
21
21
  };
22
- const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.4`;
22
+ const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.7`;
23
23
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
24
24
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
25
25
  : `${packageDetails}`;
26
26
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
27
27
  userAgentPrefix
28
- }, baseUri: options.endpoint || "{Host}/v2" });
28
+ }, baseUri: options.endpoint || "{Host}/v2.1" });
29
29
  super(optionsWithDefaults);
30
30
  // Assigning values to Constant parameters
31
31
  this.host = options.host || "https://dc.services.visualstudio.com";
@@ -1 +1 @@
1
- {"version":3,"file":"applicationInsightsClientContext.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,MAAM,OAAO,gCAAiC,SAAQ,UAAU,CAAC,aAAa;IAG5E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,sDAAsD,CAAC;QAC9E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,WAAW,GACzC,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,0CAA0C;QAC1C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,sCAAsC,CAAC;IACrE,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApplicationInsightsClientOptionalParams } from \"./models\";\n\nexport class ApplicationInsightsClientContext extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClientContext class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: ApplicationInsightsClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{Host}/v2\"\n };\n super(optionsWithDefaults);\n\n // Assigning values to Constant parameters\n this.host = options.host || \"https://dc.services.visualstudio.com\";\n }\n}\n"]}
1
+ {"version":3,"file":"applicationInsightsClientContext.js","sourceRoot":"","sources":["../../../src/generated/applicationInsightsClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,MAAM,OAAO,gCAAiC,SAAQ,UAAU,CAAC,aAAa;IAG5E;;;OAGG;IACH,YAAY,OAAiD;QAC3D,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAA4C;YACxD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,sDAAsD,CAAC;QAC9E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,aAAa,GAC3C,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE3B,0CAA0C;QAC1C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,sCAAsC,CAAC;IACrE,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApplicationInsightsClientOptionalParams } from \"./models\";\n\nexport class ApplicationInsightsClientContext extends coreClient.ServiceClient {\n host: string;\n\n /**\n * Initializes a new instance of the ApplicationInsightsClientContext class.\n * @param options The parameter options\n */\n constructor(options?: ApplicationInsightsClientOptionalParams) {\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: ApplicationInsightsClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.7`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{Host}/v2.1\"\n };\n super(optionsWithDefaults);\n\n // Assigning values to Constant parameters\n this.host = options.host || \"https://dc.services.visualstudio.com\";\n }\n}\n"]}