@azure/monitor-opentelemetry-exporter 1.0.0-beta.18 → 1.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +389 -378
  3. package/dist-esm/src/export/base.js.map +1 -1
  4. package/dist-esm/src/export/log.js.map +1 -1
  5. package/dist-esm/src/export/metric.js.map +1 -1
  6. package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js +4 -4
  7. package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
  8. package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js +3 -3
  9. package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
  10. package/dist-esm/src/export/statsbeat/statsbeatExporter.js +2 -2
  11. package/dist-esm/src/export/statsbeat/statsbeatExporter.js.map +1 -1
  12. package/dist-esm/src/export/statsbeat/statsbeatMetrics.js +1 -1
  13. package/dist-esm/src/export/statsbeat/statsbeatMetrics.js.map +1 -1
  14. package/dist-esm/src/export/trace.js.map +1 -1
  15. package/dist-esm/src/generated/applicationInsightsClient.js +13 -30
  16. package/dist-esm/src/generated/applicationInsightsClient.js.map +1 -1
  17. package/dist-esm/src/generated/models/index.js.map +1 -1
  18. package/dist-esm/src/generated/models/mappers.js +276 -276
  19. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  20. package/dist-esm/src/generated/models/parameters.js +14 -14
  21. package/dist-esm/src/generated/models/parameters.js.map +1 -1
  22. package/dist-esm/src/platform/nodejs/baseSender.js +27 -8
  23. package/dist-esm/src/platform/nodejs/baseSender.js.map +1 -1
  24. package/dist-esm/src/platform/nodejs/context/context.js +2 -4
  25. package/dist-esm/src/platform/nodejs/context/context.js.map +1 -1
  26. package/dist-esm/src/platform/nodejs/httpSender.js.map +1 -1
  27. package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js +2 -2
  28. package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js.map +1 -1
  29. package/dist-esm/src/platform/nodejs/persist/fileSystemHelpers.js +15 -8
  30. package/dist-esm/src/platform/nodejs/persist/fileSystemHelpers.js.map +1 -1
  31. package/dist-esm/src/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
  32. package/dist-esm/src/sampling.js.map +1 -1
  33. package/dist-esm/src/utils/breezeUtils.js +12 -16
  34. package/dist-esm/src/utils/breezeUtils.js.map +1 -1
  35. package/dist-esm/src/utils/common.js +5 -1
  36. package/dist-esm/src/utils/common.js.map +1 -1
  37. package/dist-esm/src/utils/connectionStringParser.js.map +1 -1
  38. package/dist-esm/src/utils/constants/applicationinsights.js +2 -1
  39. package/dist-esm/src/utils/constants/applicationinsights.js.map +1 -1
  40. package/dist-esm/src/utils/eventhub.js.map +1 -1
  41. package/dist-esm/src/utils/logUtils.js +2 -3
  42. package/dist-esm/src/utils/logUtils.js.map +1 -1
  43. package/dist-esm/src/utils/metricUtils.js +1 -1
  44. package/dist-esm/src/utils/metricUtils.js.map +1 -1
  45. package/dist-esm/src/utils/spanUtils.js +14 -9
  46. package/dist-esm/src/utils/spanUtils.js.map +1 -1
  47. package/package.json +17 -18
  48. package/types/monitor-opentelemetry-exporter.d.ts +3 -0
package/dist/index.js CHANGED
@@ -34,7 +34,6 @@ function _interopNamespaceDefault(e) {
34
34
  }
35
35
 
36
36
  var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os$1);
37
- var coreRestPipeline__namespace = /*#__PURE__*/_interopNamespaceDefault(coreRestPipeline);
38
37
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
39
38
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
40
39
  var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_process);
@@ -61,7 +60,7 @@ const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
61
60
  * AzureMonitorTraceExporter version.
62
61
  * @internal
63
62
  */
64
- const packageVersion = "1.0.0-beta.18";
63
+ const packageVersion = "1.0.0-beta.20";
65
64
  var DependencyTypes;
66
65
  (function (DependencyTypes) {
67
66
  DependencyTypes["InProc"] = "InProc";
@@ -69,6 +68,7 @@ var DependencyTypes;
69
68
  DependencyTypes["Sql"] = "SQL";
70
69
  DependencyTypes["Http"] = "Http";
71
70
  DependencyTypes["Grpc"] = "GRPC";
71
+ DependencyTypes["Wcf"] = "WCF Service";
72
72
  })(DependencyTypes || (DependencyTypes = {}));
73
73
  const AzureMonitorSampleRate = "_MS.sampleRate";
74
74
  const ApplicationInsightsBaseType = "_MS.baseType";
@@ -537,9 +537,9 @@ class FileAccessControl {
537
537
  return [
538
538
  directory,
539
539
  "/grant",
540
- "*S-1-5-32-544:(OI)(CI)F",
540
+ "*S-1-5-32-544:(OI)(CI)F", // Full permission for Administrators
541
541
  "/grant",
542
- `${identity}:(OI)(CI)F`,
542
+ `${identity}:(OI)(CI)F`, // Full permission for current user
543
543
  "/inheritance:r",
544
544
  ]; // Remove all inherited permissions
545
545
  }
@@ -563,17 +563,23 @@ const mkdirAsync = util.promisify(fs__namespace.mkdir);
563
563
  * @internal
564
564
  */
565
565
  const getShallowDirectorySize = async (directory) => {
566
- // Get the directory listing
567
- const files = await readdirAsync$1(directory);
568
566
  let totalSize = 0;
569
- // Query all file sizes
570
- for (const file of files) {
571
- const fileStats = await statAsync$1(path__namespace.join(directory, file));
572
- if (fileStats.isFile()) {
573
- totalSize += fileStats.size;
567
+ try {
568
+ // Get the directory listing
569
+ const files = await readdirAsync$1(directory);
570
+ // Query all file sizes
571
+ for (const file of files) {
572
+ const fileStats = await statAsync$1(path__namespace.join(directory, file));
573
+ if (fileStats.isFile()) {
574
+ totalSize += fileStats.size;
575
+ }
574
576
  }
577
+ return totalSize;
578
+ }
579
+ catch (err) {
580
+ api.diag.error(`Error getting directory size: ${err}`);
581
+ return 0;
575
582
  }
576
- return totalSize;
577
583
  };
578
584
  /**
579
585
  * Validate directory exists.
@@ -878,9 +884,9 @@ const contentType = {
878
884
  isConstant: true,
879
885
  serializedName: "Content-Type",
880
886
  type: {
881
- name: "String"
882
- }
883
- }
887
+ name: "String",
888
+ },
889
+ },
884
890
  };
885
891
  const body = {
886
892
  parameterPath: "body",
@@ -892,11 +898,11 @@ const body = {
892
898
  element: {
893
899
  type: {
894
900
  name: "Composite",
895
- className: "TelemetryItem"
896
- }
897
- }
898
- }
899
- }
901
+ className: "TelemetryItem",
902
+ },
903
+ },
904
+ },
905
+ },
900
906
  };
901
907
  const accept = {
902
908
  parameterPath: "accept",
@@ -905,9 +911,9 @@ const accept = {
905
911
  isConstant: true,
906
912
  serializedName: "Accept",
907
913
  type: {
908
- name: "String"
909
- }
910
- }
914
+ name: "String",
915
+ },
916
+ },
911
917
  };
912
918
  const host = {
913
919
  parameterPath: "host",
@@ -915,10 +921,10 @@ const host = {
915
921
  serializedName: "Host",
916
922
  required: true,
917
923
  type: {
918
- name: "String"
919
- }
924
+ name: "String",
925
+ },
920
926
  },
921
- skipEncoding: true
927
+ skipEncoding: true,
922
928
  };
923
929
 
924
930
  /*
@@ -937,61 +943,61 @@ const TelemetryItem = {
937
943
  defaultValue: 1,
938
944
  serializedName: "ver",
939
945
  type: {
940
- name: "Number"
941
- }
946
+ name: "Number",
947
+ },
942
948
  },
943
949
  name: {
944
950
  serializedName: "name",
945
951
  required: true,
946
952
  type: {
947
- name: "String"
948
- }
953
+ name: "String",
954
+ },
949
955
  },
950
956
  time: {
951
957
  serializedName: "time",
952
958
  required: true,
953
959
  type: {
954
- name: "DateTime"
955
- }
960
+ name: "DateTime",
961
+ },
956
962
  },
957
963
  sampleRate: {
958
964
  defaultValue: 100,
959
965
  serializedName: "sampleRate",
960
966
  type: {
961
- name: "Number"
962
- }
967
+ name: "Number",
968
+ },
963
969
  },
964
970
  sequence: {
965
971
  constraints: {
966
- MaxLength: 64
972
+ MaxLength: 64,
967
973
  },
968
974
  serializedName: "seq",
969
975
  type: {
970
- name: "String"
971
- }
976
+ name: "String",
977
+ },
972
978
  },
973
979
  instrumentationKey: {
974
980
  serializedName: "iKey",
975
981
  type: {
976
- name: "String"
977
- }
982
+ name: "String",
983
+ },
978
984
  },
979
985
  tags: {
980
986
  serializedName: "tags",
981
987
  type: {
982
988
  name: "Dictionary",
983
- value: { type: { name: "String" } }
984
- }
989
+ value: { type: { name: "String" } },
990
+ },
985
991
  },
986
992
  data: {
987
993
  serializedName: "data",
988
994
  type: {
989
995
  name: "Composite",
990
- className: "MonitorBase"
991
- }
992
- }
993
- }
994
- }
996
+ className: "MonitorBase",
997
+ },
998
+ },
999
+ },
1000
+ },
995
1001
  };
996
1002
  const MonitorBase = {
997
1003
  type: {
@@ -1001,18 +1007,18 @@ const MonitorBase = {
1001
1007
  baseType: {
1002
1008
  serializedName: "baseType",
1003
1009
  type: {
1004
- name: "String"
1005
- }
1010
+ name: "String",
1011
+ },
1006
1012
  },
1007
1013
  baseData: {
1008
1014
  serializedName: "baseData",
1009
1015
  type: {
1010
1016
  name: "Composite",
1011
- className: "MonitorDomain"
1012
- }
1013
- }
1014
- }
1015
- }
1017
+ className: "MonitorDomain",
1018
+ },
1019
+ },
1020
+ },
1021
+ },
1016
1022
  };
1017
1023
  const MonitorDomain = {
1018
1024
  type: {
@@ -1025,11 +1031,11 @@ const MonitorDomain = {
1025
1031
  serializedName: "ver",
1026
1032
  required: true,
1027
1033
  type: {
1028
- name: "Number"
1029
- }
1030
- }
1031
- }
1032
- }
1034
+ name: "Number",
1035
+ },
1036
+ },
1037
+ },
1038
+ },
1033
1039
  };
1034
1040
  const TrackResponse = {
1035
1041
  type: {
@@ -1039,14 +1045,14 @@ const TrackResponse = {
1039
1045
  itemsReceived: {
1040
1046
  serializedName: "itemsReceived",
1041
1047
  type: {
1042
- name: "Number"
1043
- }
1048
+ name: "Number",
1049
+ },
1044
1050
  },
1045
1051
  itemsAccepted: {
1046
1052
  serializedName: "itemsAccepted",
1047
1053
  type: {
1048
- name: "Number"
1049
- }
1054
+ name: "Number",
1055
+ },
1050
1056
  },
1051
1057
  errors: {
1052
1058
  serializedName: "errors",
@@ -1055,13 +1061,13 @@ const TrackResponse = {
1055
1061
  element: {
1056
1062
  type: {
1057
1063
  name: "Composite",
1058
- className: "TelemetryErrorDetails"
1059
- }
1060
- }
1061
- }
1062
- }
1063
- }
1064
- }
1064
+ className: "TelemetryErrorDetails",
1065
+ },
1066
+ },
1067
+ },
1068
+ },
1069
+ },
1070
+ },
1065
1071
  };
1066
1072
  const TelemetryErrorDetails = {
1067
1073
  type: {
@@ -1071,23 +1077,23 @@ const TelemetryErrorDetails = {
1071
1077
  index: {
1072
1078
  serializedName: "index",
1073
1079
  type: {
1074
- name: "Number"
1075
- }
1080
+ name: "Number",
1081
+ },
1076
1082
  },
1077
1083
  statusCode: {
1078
1084
  serializedName: "statusCode",
1079
1085
  type: {
1080
- name: "Number"
1081
- }
1086
+ name: "Number",
1087
+ },
1082
1088
  },
1083
1089
  message: {
1084
1090
  serializedName: "message",
1085
1091
  type: {
1086
- name: "String"
1087
- }
1088
- }
1089
- }
1090
- }
1092
+ name: "String",
1093
+ },
1094
+ },
1095
+ },
1096
+ },
1091
1097
  };
1092
1098
  const MetricDataPoint = {
1093
1099
  type: {
@@ -1096,66 +1102,66 @@ const MetricDataPoint = {
1096
1102
  modelProperties: {
1097
1103
  namespace: {
1098
1104
  constraints: {
1099
- MaxLength: 256
1105
+ MaxLength: 256,
1100
1106
  },
1101
1107
  serializedName: "ns",
1102
1108
  type: {
1103
- name: "String"
1104
- }
1109
+ name: "String",
1110
+ },
1105
1111
  },
1106
1112
  name: {
1107
1113
  constraints: {
1108
- MaxLength: 1024
1114
+ MaxLength: 1024,
1109
1115
  },
1110
1116
  serializedName: "name",
1111
1117
  required: true,
1112
1118
  type: {
1113
- name: "String"
1114
- }
1119
+ name: "String",
1120
+ },
1115
1121
  },
1116
1122
  dataPointType: {
1117
1123
  serializedName: "kind",
1118
1124
  type: {
1119
- name: "String"
1120
- }
1125
+ name: "String",
1126
+ },
1121
1127
  },
1122
1128
  value: {
1123
1129
  serializedName: "value",
1124
1130
  required: true,
1125
1131
  type: {
1126
- name: "Number"
1127
- }
1132
+ name: "Number",
1133
+ },
1128
1134
  },
1129
1135
  count: {
1130
1136
  serializedName: "count",
1131
1137
  nullable: true,
1132
1138
  type: {
1133
- name: "Number"
1134
- }
1139
+ name: "Number",
1140
+ },
1135
1141
  },
1136
1142
  min: {
1137
1143
  serializedName: "min",
1138
1144
  nullable: true,
1139
1145
  type: {
1140
- name: "Number"
1141
- }
1146
+ name: "Number",
1147
+ },
1142
1148
  },
1143
1149
  max: {
1144
1150
  serializedName: "max",
1145
1151
  nullable: true,
1146
1152
  type: {
1147
- name: "Number"
1148
- }
1153
+ name: "Number",
1154
+ },
1149
1155
  },
1150
1156
  stdDev: {
1151
1157
  serializedName: "stdDev",
1152
1158
  nullable: true,
1153
1159
  type: {
1154
- name: "Number"
1155
- }
1156
- }
1157
- }
1158
- }
1160
+ name: "Number",
1161
+ },
1162
+ },
1163
+ },
1164
+ },
1159
1165
  };
1160
1166
  const TelemetryExceptionDetails = {
1161
1167
  type: {
@@ -1165,49 +1171,49 @@ const TelemetryExceptionDetails = {
1165
1171
  id: {
1166
1172
  serializedName: "id",
1167
1173
  type: {
1168
- name: "Number"
1169
- }
1174
+ name: "Number",
1175
+ },
1170
1176
  },
1171
1177
  outerId: {
1172
1178
  serializedName: "outerId",
1173
1179
  type: {
1174
- name: "Number"
1175
- }
1180
+ name: "Number",
1181
+ },
1176
1182
  },
1177
1183
  typeName: {
1178
1184
  constraints: {
1179
- MaxLength: 1024
1185
+ MaxLength: 1024,
1180
1186
  },
1181
1187
  serializedName: "typeName",
1182
1188
  type: {
1183
- name: "String"
1184
- }
1189
+ name: "String",
1190
+ },
1185
1191
  },
1186
1192
  message: {
1187
1193
  constraints: {
1188
- MaxLength: 32768
1194
+ MaxLength: 32768,
1189
1195
  },
1190
1196
  serializedName: "message",
1191
1197
  required: true,
1192
1198
  type: {
1193
- name: "String"
1194
- }
1199
+ name: "String",
1200
+ },
1195
1201
  },
1196
1202
  hasFullStack: {
1197
1203
  defaultValue: true,
1198
1204
  serializedName: "hasFullStack",
1199
1205
  type: {
1200
- name: "Boolean"
1201
- }
1206
+ name: "Boolean",
1207
+ },
1202
1208
  },
1203
1209
  stack: {
1204
1210
  constraints: {
1205
- MaxLength: 32768
1211
+ MaxLength: 32768,
1206
1212
  },
1207
1213
  serializedName: "stack",
1208
1214
  type: {
1209
- name: "String"
1210
- }
1215
+ name: "String",
1216
+ },
1211
1217
  },
1212
1218
  parsedStack: {
1213
1219
  serializedName: "parsedStack",
@@ -1216,13 +1222,13 @@ const TelemetryExceptionDetails = {
1216
1222
  element: {
1217
1223
  type: {
1218
1224
  name: "Composite",
1219
- className: "StackFrame"
1220
- }
1221
- }
1222
- }
1223
- }
1224
- }
1225
- }
1225
+ className: "StackFrame",
1226
+ },
1227
+ },
1228
+ },
1229
+ },
1230
+ },
1231
+ },
1226
1232
  };
1227
1233
  const StackFrame = {
1228
1234
  type: {
@@ -1233,45 +1239,45 @@ const StackFrame = {
1233
1239
  serializedName: "level",
1234
1240
  required: true,
1235
1241
  type: {
1236
- name: "Number"
1237
- }
1242
+ name: "Number",
1243
+ },
1238
1244
  },
1239
1245
  method: {
1240
1246
  constraints: {
1241
- MaxLength: 1024
1247
+ MaxLength: 1024,
1242
1248
  },
1243
1249
  serializedName: "method",
1244
1250
  required: true,
1245
1251
  type: {
1246
- name: "String"
1247
- }
1252
+ name: "String",
1253
+ },
1248
1254
  },
1249
1255
  assembly: {
1250
1256
  constraints: {
1251
- MaxLength: 1024
1257
+ MaxLength: 1024,
1252
1258
  },
1253
1259
  serializedName: "assembly",
1254
1260
  type: {
1255
- name: "String"
1256
- }
1261
+ name: "String",
1262
+ },
1257
1263
  },
1258
1264
  fileName: {
1259
1265
  constraints: {
1260
- MaxLength: 1024
1266
+ MaxLength: 1024,
1261
1267
  },
1262
1268
  serializedName: "fileName",
1263
1269
  type: {
1264
- name: "String"
1265
- }
1270
+ name: "String",
1271
+ },
1266
1272
  },
1267
1273
  line: {
1268
1274
  serializedName: "line",
1269
1275
  type: {
1270
- name: "Number"
1271
- }
1272
- }
1273
- }
1274
- }
1276
+ name: "Number",
1277
+ },
1278
+ },
1279
+ },
1280
+ },
1275
1281
  };
1276
1282
  const AvailabilityData = {
1277
1283
  type: {
@@ -1280,64 +1286,64 @@ const AvailabilityData = {
1280
1286
  additionalProperties: { type: { name: "Object" } },
1281
1287
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1282
1288
  constraints: {
1283
- MaxLength: 512
1289
+ MaxLength: 512,
1284
1290
  },
1285
1291
  serializedName: "id",
1286
1292
  required: true,
1287
1293
  type: {
1288
- name: "String"
1289
- }
1294
+ name: "String",
1295
+ },
1290
1296
  }, name: {
1291
1297
  constraints: {
1292
- MaxLength: 1024
1298
+ MaxLength: 1024,
1293
1299
  },
1294
1300
  serializedName: "name",
1295
1301
  required: true,
1296
1302
  type: {
1297
- name: "String"
1298
- }
1303
+ name: "String",
1304
+ },
1299
1305
  }, duration: {
1300
1306
  serializedName: "duration",
1301
1307
  required: true,
1302
1308
  type: {
1303
- name: "String"
1304
- }
1309
+ name: "String",
1310
+ },
1305
1311
  }, success: {
1306
1312
  serializedName: "success",
1307
1313
  required: true,
1308
1314
  type: {
1309
- name: "Boolean"
1310
- }
1315
+ name: "Boolean",
1316
+ },
1311
1317
  }, runLocation: {
1312
1318
  constraints: {
1313
- MaxLength: 1024
1319
+ MaxLength: 1024,
1314
1320
  },
1315
1321
  serializedName: "runLocation",
1316
1322
  type: {
1317
- name: "String"
1318
- }
1323
+ name: "String",
1324
+ },
1319
1325
  }, message: {
1320
1326
  constraints: {
1321
- MaxLength: 8192
1327
+ MaxLength: 8192,
1322
1328
  },
1323
1329
  serializedName: "message",
1324
1330
  type: {
1325
- name: "String"
1326
- }
1331
+ name: "String",
1332
+ },
1327
1333
  }, properties: {
1328
1334
  serializedName: "properties",
1329
1335
  type: {
1330
1336
  name: "Dictionary",
1331
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1332
- }
1337
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1338
+ },
1333
1339
  }, measurements: {
1334
1340
  serializedName: "measurements",
1335
1341
  type: {
1336
1342
  name: "Dictionary",
1337
- value: { type: { name: "Number" } }
1338
- }
1339
- } })
1340
- }
1343
+ value: { type: { name: "Number" } },
1344
+ },
1345
+ } }),
1346
+ },
1341
1347
  };
1342
1348
  const TelemetryEventData = {
1343
1349
  type: {
@@ -1346,27 +1352,27 @@ const TelemetryEventData = {
1346
1352
  additionalProperties: { type: { name: "Object" } },
1347
1353
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { name: {
1348
1354
  constraints: {
1349
- MaxLength: 512
1355
+ MaxLength: 512,
1350
1356
  },
1351
1357
  serializedName: "name",
1352
1358
  required: true,
1353
1359
  type: {
1354
- name: "String"
1355
- }
1360
+ name: "String",
1361
+ },
1356
1362
  }, properties: {
1357
1363
  serializedName: "properties",
1358
1364
  type: {
1359
1365
  name: "Dictionary",
1360
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1361
- }
1366
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1367
+ },
1362
1368
  }, measurements: {
1363
1369
  serializedName: "measurements",
1364
1370
  type: {
1365
1371
  name: "Dictionary",
1366
- value: { type: { name: "Number" } }
1367
- }
1368
- } })
1369
- }
1372
+ value: { type: { name: "Number" } },
1373
+ },
1374
+ } }),
1375
+ },
1370
1376
  };
1371
1377
  const TelemetryExceptionData = {
1372
1378
  type: {
@@ -1381,38 +1387,38 @@ const TelemetryExceptionData = {
1381
1387
  element: {
1382
1388
  type: {
1383
1389
  name: "Composite",
1384
- className: "TelemetryExceptionDetails"
1385
- }
1386
- }
1387
- }
1390
+ className: "TelemetryExceptionDetails",
1391
+ },
1392
+ },
1393
+ },
1388
1394
  }, severityLevel: {
1389
1395
  serializedName: "severityLevel",
1390
1396
  nullable: true,
1391
1397
  type: {
1392
- name: "String"
1393
- }
1398
+ name: "String",
1399
+ },
1394
1400
  }, problemId: {
1395
1401
  constraints: {
1396
- MaxLength: 1024
1402
+ MaxLength: 1024,
1397
1403
  },
1398
1404
  serializedName: "problemId",
1399
1405
  type: {
1400
- name: "String"
1401
- }
1406
+ name: "String",
1407
+ },
1402
1408
  }, properties: {
1403
1409
  serializedName: "properties",
1404
1410
  type: {
1405
1411
  name: "Dictionary",
1406
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1407
- }
1412
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1413
+ },
1408
1414
  }, measurements: {
1409
1415
  serializedName: "measurements",
1410
1416
  type: {
1411
1417
  name: "Dictionary",
1412
- value: { type: { name: "Number" } }
1413
- }
1414
- } })
1415
- }
1418
+ value: { type: { name: "Number" } },
1419
+ },
1420
+ } }),
1421
+ },
1416
1422
  };
1417
1423
  const MessageData = {
1418
1424
  type: {
@@ -1421,32 +1427,32 @@ const MessageData = {
1421
1427
  additionalProperties: { type: { name: "Object" } },
1422
1428
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { message: {
1423
1429
  constraints: {
1424
- MaxLength: 32768
1430
+ MaxLength: 32768,
1425
1431
  },
1426
1432
  serializedName: "message",
1427
1433
  required: true,
1428
1434
  type: {
1429
- name: "String"
1430
- }
1435
+ name: "String",
1436
+ },
1431
1437
  }, severityLevel: {
1432
1438
  serializedName: "severityLevel",
1433
1439
  type: {
1434
- name: "String"
1435
- }
1440
+ name: "String",
1441
+ },
1436
1442
  }, properties: {
1437
1443
  serializedName: "properties",
1438
1444
  type: {
1439
1445
  name: "Dictionary",
1440
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1441
- }
1446
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1447
+ },
1442
1448
  }, measurements: {
1443
1449
  serializedName: "measurements",
1444
1450
  type: {
1445
1451
  name: "Dictionary",
1446
- value: { type: { name: "Number" } }
1447
- }
1448
- } })
1449
- }
1452
+ value: { type: { name: "Number" } },
1453
+ },
1454
+ } }),
1455
+ },
1450
1456
  };
1451
1457
  const MetricsData = {
1452
1458
  type: {
@@ -1461,18 +1467,18 @@ const MetricsData = {
1461
1467
  element: {
1462
1468
  type: {
1463
1469
  name: "Composite",
1464
- className: "MetricDataPoint"
1465
- }
1466
- }
1467
- }
1470
+ className: "MetricDataPoint",
1471
+ },
1472
+ },
1473
+ },
1468
1474
  }, properties: {
1469
1475
  serializedName: "properties",
1470
1476
  type: {
1471
1477
  name: "Dictionary",
1472
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1473
- }
1474
- } })
1475
- }
1478
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1479
+ },
1480
+ } }),
1481
+ },
1476
1482
  };
1477
1483
  const PageViewData = {
1478
1484
  type: {
@@ -1481,57 +1487,57 @@ const PageViewData = {
1481
1487
  additionalProperties: { type: { name: "Object" } },
1482
1488
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1483
1489
  constraints: {
1484
- MaxLength: 512
1490
+ MaxLength: 512,
1485
1491
  },
1486
1492
  serializedName: "id",
1487
1493
  required: true,
1488
1494
  type: {
1489
- name: "String"
1490
- }
1495
+ name: "String",
1496
+ },
1491
1497
  }, name: {
1492
1498
  constraints: {
1493
- MaxLength: 1024
1499
+ MaxLength: 1024,
1494
1500
  },
1495
1501
  serializedName: "name",
1496
1502
  required: true,
1497
1503
  type: {
1498
- name: "String"
1499
- }
1504
+ name: "String",
1505
+ },
1500
1506
  }, url: {
1501
1507
  constraints: {
1502
- MaxLength: 2048
1508
+ MaxLength: 2048,
1503
1509
  },
1504
1510
  serializedName: "url",
1505
1511
  type: {
1506
- name: "String"
1507
- }
1512
+ name: "String",
1513
+ },
1508
1514
  }, duration: {
1509
1515
  serializedName: "duration",
1510
1516
  type: {
1511
- name: "String"
1512
- }
1517
+ name: "String",
1518
+ },
1513
1519
  }, referredUri: {
1514
1520
  constraints: {
1515
- MaxLength: 2048
1521
+ MaxLength: 2048,
1516
1522
  },
1517
1523
  serializedName: "referredUri",
1518
1524
  type: {
1519
- name: "String"
1520
- }
1525
+ name: "String",
1526
+ },
1521
1527
  }, properties: {
1522
1528
  serializedName: "properties",
1523
1529
  type: {
1524
1530
  name: "Dictionary",
1525
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1526
- }
1531
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1532
+ },
1527
1533
  }, measurements: {
1528
1534
  serializedName: "measurements",
1529
1535
  type: {
1530
1536
  name: "Dictionary",
1531
- value: { type: { name: "Number" } }
1532
- }
1533
- } })
1534
- }
1537
+ value: { type: { name: "Number" } },
1538
+ },
1539
+ } }),
1540
+ },
1535
1541
  };
1536
1542
  const PageViewPerfData = {
1537
1543
  type: {
@@ -1540,74 +1546,74 @@ const PageViewPerfData = {
1540
1546
  additionalProperties: { type: { name: "Object" } },
1541
1547
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1542
1548
  constraints: {
1543
- MaxLength: 512
1549
+ MaxLength: 512,
1544
1550
  },
1545
1551
  serializedName: "id",
1546
1552
  required: true,
1547
1553
  type: {
1548
- name: "String"
1549
- }
1554
+ name: "String",
1555
+ },
1550
1556
  }, name: {
1551
1557
  constraints: {
1552
- MaxLength: 1024
1558
+ MaxLength: 1024,
1553
1559
  },
1554
1560
  serializedName: "name",
1555
1561
  required: true,
1556
1562
  type: {
1557
- name: "String"
1558
- }
1563
+ name: "String",
1564
+ },
1559
1565
  }, url: {
1560
1566
  constraints: {
1561
- MaxLength: 2048
1567
+ MaxLength: 2048,
1562
1568
  },
1563
1569
  serializedName: "url",
1564
1570
  type: {
1565
- name: "String"
1566
- }
1571
+ name: "String",
1572
+ },
1567
1573
  }, duration: {
1568
1574
  serializedName: "duration",
1569
1575
  type: {
1570
- name: "String"
1571
- }
1576
+ name: "String",
1577
+ },
1572
1578
  }, perfTotal: {
1573
1579
  serializedName: "perfTotal",
1574
1580
  type: {
1575
- name: "String"
1576
- }
1581
+ name: "String",
1582
+ },
1577
1583
  }, networkConnect: {
1578
1584
  serializedName: "networkConnect",
1579
1585
  type: {
1580
- name: "String"
1581
- }
1586
+ name: "String",
1587
+ },
1582
1588
  }, sentRequest: {
1583
1589
  serializedName: "sentRequest",
1584
1590
  type: {
1585
- name: "String"
1586
- }
1591
+ name: "String",
1592
+ },
1587
1593
  }, receivedResponse: {
1588
1594
  serializedName: "receivedResponse",
1589
1595
  type: {
1590
- name: "String"
1591
- }
1596
+ name: "String",
1597
+ },
1592
1598
  }, domProcessing: {
1593
1599
  serializedName: "domProcessing",
1594
1600
  type: {
1595
- name: "String"
1596
- }
1601
+ name: "String",
1602
+ },
1597
1603
  }, properties: {
1598
1604
  serializedName: "properties",
1599
1605
  type: {
1600
1606
  name: "Dictionary",
1601
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1602
- }
1607
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1608
+ },
1603
1609
  }, measurements: {
1604
1610
  serializedName: "measurements",
1605
1611
  type: {
1606
1612
  name: "Dictionary",
1607
- value: { type: { name: "Number" } }
1608
- }
1609
- } })
1610
- }
1613
+ value: { type: { name: "Number" } },
1614
+ },
1615
+ } }),
1616
+ },
1611
1617
  };
1612
1618
  const RemoteDependencyData = {
1613
1619
  type: {
@@ -1616,79 +1622,79 @@ const RemoteDependencyData = {
1616
1622
  additionalProperties: { type: { name: "Object" } },
1617
1623
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1618
1624
  constraints: {
1619
- MaxLength: 512
1625
+ MaxLength: 512,
1620
1626
  },
1621
1627
  serializedName: "id",
1622
1628
  type: {
1623
- name: "String"
1624
- }
1629
+ name: "String",
1630
+ },
1625
1631
  }, name: {
1626
1632
  constraints: {
1627
- MaxLength: 1024
1633
+ MaxLength: 1024,
1628
1634
  },
1629
1635
  serializedName: "name",
1630
1636
  required: true,
1631
1637
  type: {
1632
- name: "String"
1633
- }
1638
+ name: "String",
1639
+ },
1634
1640
  }, resultCode: {
1635
1641
  constraints: {
1636
- MaxLength: 1024
1642
+ MaxLength: 1024,
1637
1643
  },
1638
1644
  serializedName: "resultCode",
1639
1645
  type: {
1640
- name: "String"
1641
- }
1646
+ name: "String",
1647
+ },
1642
1648
  }, data: {
1643
1649
  constraints: {
1644
- MaxLength: 8192
1650
+ MaxLength: 8192,
1645
1651
  },
1646
1652
  serializedName: "data",
1647
1653
  type: {
1648
- name: "String"
1649
- }
1654
+ name: "String",
1655
+ },
1650
1656
  }, type: {
1651
1657
  constraints: {
1652
- MaxLength: 1024
1658
+ MaxLength: 1024,
1653
1659
  },
1654
1660
  serializedName: "type",
1655
1661
  type: {
1656
- name: "String"
1657
- }
1662
+ name: "String",
1663
+ },
1658
1664
  }, target: {
1659
1665
  constraints: {
1660
- MaxLength: 1024
1666
+ MaxLength: 1024,
1661
1667
  },
1662
1668
  serializedName: "target",
1663
1669
  type: {
1664
- name: "String"
1665
- }
1670
+ name: "String",
1671
+ },
1666
1672
  }, duration: {
1667
1673
  serializedName: "duration",
1668
1674
  required: true,
1669
1675
  type: {
1670
- name: "String"
1671
- }
1676
+ name: "String",
1677
+ },
1672
1678
  }, success: {
1673
1679
  defaultValue: true,
1674
1680
  serializedName: "success",
1675
1681
  type: {
1676
- name: "Boolean"
1677
- }
1682
+ name: "Boolean",
1683
+ },
1678
1684
  }, properties: {
1679
1685
  serializedName: "properties",
1680
1686
  type: {
1681
1687
  name: "Dictionary",
1682
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1683
- }
1688
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1689
+ },
1684
1690
  }, measurements: {
1685
1691
  serializedName: "measurements",
1686
1692
  type: {
1687
1693
  name: "Dictionary",
1688
- value: { type: { name: "Number" } }
1689
- }
1690
- } })
1691
- }
1694
+ value: { type: { name: "Number" } },
1695
+ },
1696
+ } }),
1697
+ },
1692
1698
  };
1693
1699
  const RequestData = {
1694
1700
  type: {
@@ -1697,73 +1703,73 @@ const RequestData = {
1697
1703
  additionalProperties: { type: { name: "Object" } },
1698
1704
  modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1699
1705
  constraints: {
1700
- MaxLength: 512
1706
+ MaxLength: 512,
1701
1707
  },
1702
1708
  serializedName: "id",
1703
1709
  required: true,
1704
1710
  type: {
1705
- name: "String"
1706
- }
1711
+ name: "String",
1712
+ },
1707
1713
  }, name: {
1708
1714
  constraints: {
1709
- MaxLength: 1024
1715
+ MaxLength: 1024,
1710
1716
  },
1711
1717
  serializedName: "name",
1712
1718
  type: {
1713
- name: "String"
1714
- }
1719
+ name: "String",
1720
+ },
1715
1721
  }, duration: {
1716
1722
  serializedName: "duration",
1717
1723
  required: true,
1718
1724
  type: {
1719
- name: "String"
1720
- }
1725
+ name: "String",
1726
+ },
1721
1727
  }, success: {
1722
1728
  defaultValue: true,
1723
1729
  serializedName: "success",
1724
1730
  required: true,
1725
1731
  type: {
1726
- name: "Boolean"
1727
- }
1732
+ name: "Boolean",
1733
+ },
1728
1734
  }, responseCode: {
1729
1735
  constraints: {
1730
- MaxLength: 1024
1736
+ MaxLength: 1024,
1731
1737
  },
1732
1738
  serializedName: "responseCode",
1733
1739
  required: true,
1734
1740
  type: {
1735
- name: "String"
1736
- }
1741
+ name: "String",
1742
+ },
1737
1743
  }, source: {
1738
1744
  constraints: {
1739
- MaxLength: 1024
1745
+ MaxLength: 1024,
1740
1746
  },
1741
1747
  serializedName: "source",
1742
1748
  type: {
1743
- name: "String"
1744
- }
1749
+ name: "String",
1750
+ },
1745
1751
  }, url: {
1746
1752
  constraints: {
1747
- MaxLength: 2048
1753
+ MaxLength: 2048,
1748
1754
  },
1749
1755
  serializedName: "url",
1750
1756
  type: {
1751
- name: "String"
1752
- }
1757
+ name: "String",
1758
+ },
1753
1759
  }, properties: {
1754
1760
  serializedName: "properties",
1755
1761
  type: {
1756
1762
  name: "Dictionary",
1757
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } }
1758
- }
1763
+ value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1764
+ },
1759
1765
  }, measurements: {
1760
1766
  serializedName: "measurements",
1761
1767
  type: {
1762
1768
  name: "Dictionary",
1763
- value: { type: { name: "Number" } }
1764
- }
1765
- } })
1766
- }
1769
+ value: { type: { name: "Number" } },
1770
+ },
1771
+ } }),
1772
+ },
1767
1773
  };
1768
1774
 
1769
1775
  var Mappers = /*#__PURE__*/Object.freeze({
@@ -1806,32 +1812,16 @@ class ApplicationInsightsClient extends coreClient__namespace.ServiceClient {
1806
1812
  options = {};
1807
1813
  }
1808
1814
  const defaults = {
1809
- requestContentType: "application/json; charset=utf-8"
1815
+ requestContentType: "application/json; charset=utf-8",
1810
1816
  };
1811
- const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.18`;
1817
+ const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.20`;
1812
1818
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1813
1819
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1814
1820
  : `${packageDetails}`;
1815
1821
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1816
- userAgentPrefix
1817
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{Host}/v2.1" });
1822
+ userAgentPrefix,
1823
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{Host}/v2.1" });
1818
1824
  super(optionsWithDefaults);
1819
- if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
1820
- const pipelinePolicies = options.pipeline.getOrderedPolicies();
1821
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1822
- coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName);
1823
- if (!bearerTokenAuthenticationPolicyFound) {
1824
- this.pipeline.removePolicy({
1825
- name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1826
- });
1827
- this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1828
- scopes: `${optionsWithDefaults.baseUri}/.default`,
1829
- challengeCallbacks: {
1830
- authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1831
- }
1832
- }));
1833
- }
1834
- }
1835
1825
  // Assigning values to Constant parameters
1836
1826
  this.host = options.host || "https://dc.services.visualstudio.com";
1837
1827
  }
@@ -1851,37 +1841,37 @@ const trackOperationSpec = {
1851
1841
  httpMethod: "POST",
1852
1842
  responses: {
1853
1843
  200: {
1854
- bodyMapper: TrackResponse
1844
+ bodyMapper: TrackResponse,
1855
1845
  },
1856
1846
  206: {
1857
- bodyMapper: TrackResponse
1847
+ bodyMapper: TrackResponse,
1858
1848
  },
1859
1849
  400: {
1860
1850
  bodyMapper: TrackResponse,
1861
- isError: true
1851
+ isError: true,
1862
1852
  },
1863
1853
  402: {
1864
1854
  bodyMapper: TrackResponse,
1865
- isError: true
1855
+ isError: true,
1866
1856
  },
1867
1857
  429: {
1868
1858
  bodyMapper: TrackResponse,
1869
- isError: true
1859
+ isError: true,
1870
1860
  },
1871
1861
  500: {
1872
1862
  bodyMapper: TrackResponse,
1873
- isError: true
1863
+ isError: true,
1874
1864
  },
1875
1865
  503: {
1876
1866
  bodyMapper: TrackResponse,
1877
- isError: true
1878
- }
1867
+ isError: true,
1868
+ },
1879
1869
  },
1880
1870
  requestBody: body,
1881
1871
  urlParameters: [host],
1882
1872
  headerParameters: [contentType, accept],
1883
1873
  mediaType: "json",
1884
- serializer
1874
+ serializer,
1885
1875
  };
1886
1876
 
1887
1877
  // Copyright (c) Microsoft Corporation.
@@ -1998,7 +1988,7 @@ class StatsbeatMetrics {
1998
1988
  const method = "GET";
1999
1989
  const options = {
2000
1990
  url: `${AIMS_URI}?${AIMS_API_VERSION}&${AIMS_FORMAT}`,
2001
- timeout: 5000,
1991
+ timeout: 5000, // 5 seconds
2002
1992
  method: method,
2003
1993
  allowInsecureConnection: true,
2004
1994
  };
@@ -2102,7 +2092,7 @@ function resourceMetricsToEnvelope(metrics, ikey, isStatsbeat) {
2102
2092
  const envelope = {
2103
2093
  name: envelopeName,
2104
2094
  time: time,
2105
- sampleRate: 100,
2095
+ sampleRate: 100, // Metrics are never sampled
2106
2096
  instrumentationKey: instrumentationKey,
2107
2097
  tags: tags,
2108
2098
  version: 1,
@@ -2139,6 +2129,7 @@ class AzureMonitorStatsbeatExporter extends AzureMonitorBaseExporter {
2139
2129
  instrumentationKey: this.instrumentationKey,
2140
2130
  trackStatsbeat: this.trackStatsbeat,
2141
2131
  exporterOptions: options,
2132
+ isStatsbeatSender: true,
2142
2133
  });
2143
2134
  }
2144
2135
  /**
@@ -2149,8 +2140,7 @@ class AzureMonitorStatsbeatExporter extends AzureMonitorBaseExporter {
2149
2140
  setTimeout(() => resultCallback({ code: core.ExportResultCode.FAILED }), 0);
2150
2141
  return;
2151
2142
  }
2152
- const envelopes = resourceMetricsToEnvelope(metrics, this.instrumentationKey, true // isStatsbeat flag passed to create a Statsbeat envelope.
2153
- );
2143
+ const envelopes = resourceMetricsToEnvelope(metrics, this.instrumentationKey, true);
2154
2144
  // Supress tracing until OpenTelemetry Metrics SDK support it
2155
2145
  api.context.with(core.suppressTracing(api.context.active()), async () => {
2156
2146
  resultCallback(await this._sender.exportEnvelopes(envelopes));
@@ -2179,7 +2169,7 @@ class NetworkStatsbeatMetrics extends StatsbeatMetrics {
2179
2169
  this.isInitialized = false;
2180
2170
  this.statsCollectionShortInterval = 900000; // 15 minutes
2181
2171
  this.networkStatsbeatCollection = [];
2182
- this.attach = "sdk";
2172
+ this.attach = "Manual";
2183
2173
  this.connectionString = super.getConnectionString(options.endpointUrl);
2184
2174
  this.networkStatsbeatMeterProvider = new sdkMetrics.MeterProvider();
2185
2175
  const exporterConfig = {
@@ -2207,8 +2197,8 @@ class NetworkStatsbeatMetrics extends StatsbeatMetrics {
2207
2197
  this.exceptionCountGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.EXCEPTION_COUNT);
2208
2198
  this.averageDurationGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.AVERAGE_DURATION);
2209
2199
  this.commonProperties = {
2210
- os: super.os,
2211
- rp: super.resourceProvider,
2200
+ os: this.os,
2201
+ rp: this.resourceProvider,
2212
2202
  cikey: this.cikey,
2213
2203
  runtimeVersion: this.runtimeVersion,
2214
2204
  language: this.language,
@@ -2423,7 +2413,7 @@ class LongIntervalStatsbeatMetrics extends StatsbeatMetrics {
2423
2413
  super();
2424
2414
  this.AZURE_MONITOR_STATSBEAT_FEATURES = process.env.AZURE_MONITOR_STATSBEAT_FEATURES;
2425
2415
  this.statsCollectionLongInterval = 86400000; // 1 day
2426
- this.attach = "sdk";
2416
+ this.attach = "Manual";
2427
2417
  this.feature = 0;
2428
2418
  this.instrumentation = 0;
2429
2419
  this.isInitialized = false;
@@ -2458,8 +2448,8 @@ class LongIntervalStatsbeatMetrics extends StatsbeatMetrics {
2458
2448
  this.featureStatsbeatGauge = this.longIntervalStatsbeatMeter.createObservableGauge(StatsbeatCounter.FEATURE);
2459
2449
  this.attachStatsbeatGauge = this.longIntervalStatsbeatMeter.createObservableGauge(StatsbeatCounter.ATTACH);
2460
2450
  this.commonProperties = {
2461
- os: super.os,
2462
- rp: super.resourceProvider,
2451
+ os: this.os,
2452
+ rp: this.resourceProvider,
2463
2453
  cikey: this.cikey,
2464
2454
  runtimeVersion: this.runtimeVersion,
2465
2455
  language: this.language,
@@ -2467,7 +2457,7 @@ class LongIntervalStatsbeatMetrics extends StatsbeatMetrics {
2467
2457
  attach: this.attach,
2468
2458
  };
2469
2459
  this.attachProperties = {
2470
- rpId: super.resourceIdentifier,
2460
+ rpId: this.resourceIdentifier,
2471
2461
  };
2472
2462
  this.isInitialized = true;
2473
2463
  this.initialize();
@@ -2540,24 +2530,20 @@ function isRetriable(statusCode) {
2540
2530
  statusCode === 504 // Gateway Timeout
2541
2531
  );
2542
2532
  }
2543
- /**
2544
- * Convert milliseconds to Breeze expected time.
2545
- * @internal
2546
- */
2547
- function msToTimeSpan(ms) {
2548
- let totalms = ms;
2549
- if (Number.isNaN(totalms) || totalms < 0 || !Number.isFinite(ms)) {
2533
+ // Convert ms to c# time span format DD.HH:MM:SS.MMMMMM
2534
+ function msToTimeSpan(totalms) {
2535
+ if (isNaN(totalms) || totalms < 0) {
2550
2536
  totalms = 0;
2551
2537
  }
2552
- let sec = ((totalms / 1000) % 60).toFixed(7).replace(/0{0,4}$/, "");
2553
- let min = `${Math.floor(totalms / (1000 * 60)) % 60}`;
2554
- let hour = `${Math.floor(totalms / (1000 * 60 * 60)) % 24}`;
2555
- const days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2556
- sec = sec.indexOf(".") < 2 ? `0${sec}` : sec;
2557
- min = min.length < 2 ? `0${min}` : min;
2558
- hour = hour.length < 2 ? `0${hour}` : hour;
2559
- const daysText = days > 0 ? `${days}.` : "";
2560
- return `${daysText + hour}:${min}:${sec}`;
2538
+ var sec = ((totalms / 1000) % 60).toFixed(7).replace(/0{0,4}$/, "");
2539
+ var min = "" + (Math.floor(totalms / (1000 * 60)) % 60);
2540
+ var hour = "" + (Math.floor(totalms / (1000 * 60 * 60)) % 24);
2541
+ var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2542
+ sec = sec.indexOf(".") < 2 ? "0" + sec : sec;
2543
+ min = min.length < 2 ? "0" + min : min;
2544
+ hour = hour.length < 2 ? "0" + hour : hour;
2545
+ var daysText = days > 0 ? days + "." : "";
2546
+ return daysText + hour + ":" + min + ":" + sec;
2561
2547
  }
2562
2548
 
2563
2549
  // Copyright (c) Microsoft Corporation.
@@ -2585,6 +2571,7 @@ class BaseSender {
2585
2571
  });
2586
2572
  }
2587
2573
  this.retryTimer = null;
2574
+ this.isStatsbeatSender = options.isStatsbeatSender || false;
2588
2575
  }
2589
2576
  /**
2590
2577
  * Export envelopes
@@ -2691,15 +2678,25 @@ class BaseSender {
2691
2678
  (_g = this.networkStatsbeatMetrics) === null || _g === void 0 ? void 0 : _g.countRetry(restError.statusCode);
2692
2679
  return this.persist(envelopes);
2693
2680
  }
2681
+ else if (restError.statusCode === 400 &&
2682
+ restError.message.includes("Invalid instrumentation key")) {
2683
+ const invalidInstrumentationKeyError = new Error("Invalid instrumentation key");
2684
+ this.shutdownStatsbeat();
2685
+ return { code: core.ExportResultCode.FAILED, error: invalidInstrumentationKeyError };
2686
+ }
2694
2687
  if (this.isNetworkError(restError)) {
2695
2688
  if (restError.statusCode) {
2696
2689
  (_h = this.networkStatsbeatMetrics) === null || _h === void 0 ? void 0 : _h.countRetry(restError.statusCode);
2697
2690
  }
2698
- api.diag.error("Retrying due to transient client side error. Error message:", restError.message);
2691
+ if (!this.isStatsbeatSender) {
2692
+ api.diag.error("Retrying due to transient client side error. Error message:", restError.message);
2693
+ }
2699
2694
  return this.persist(envelopes);
2700
2695
  }
2701
2696
  (_j = this.networkStatsbeatMetrics) === null || _j === void 0 ? void 0 : _j.countException(restError);
2702
- api.diag.error("Envelopes could not be exported and are not retriable. Error message:", restError.message);
2697
+ if (!this.isStatsbeatSender) {
2698
+ api.diag.error("Envelopes could not be exported and are not retriable. Error message:", restError.message);
2699
+ }
2703
2700
  return { code: core.ExportResultCode.FAILED, error: restError };
2704
2701
  }
2705
2702
  }
@@ -2720,17 +2717,25 @@ class BaseSender {
2720
2717
  return { code: core.ExportResultCode.FAILED, error: ex };
2721
2718
  }
2722
2719
  }
2723
- // Disable collection of statsbeat metrics after max failures
2720
+ /**
2721
+ * Disable collection of statsbeat metrics after max failures
2722
+ */
2724
2723
  incrementStatsbeatFailure() {
2725
- var _a, _b;
2726
2724
  this.statsbeatFailureCount++;
2727
2725
  if (this.statsbeatFailureCount > MAX_STATSBEAT_FAILURES) {
2728
- (_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.shutdown();
2729
- (_b = this.longIntervalStatsbeatMetrics) === null || _b === void 0 ? void 0 : _b.shutdown();
2730
- this.networkStatsbeatMetrics = undefined;
2731
- this.statsbeatFailureCount = 0;
2726
+ this.shutdownStatsbeat();
2732
2727
  }
2733
2728
  }
2729
+ /**
2730
+ * Shutdown statsbeat metrics
2731
+ */
2732
+ shutdownStatsbeat() {
2733
+ var _a, _b;
2734
+ (_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.shutdown();
2735
+ (_b = this.longIntervalStatsbeatMetrics) === null || _b === void 0 ? void 0 : _b.shutdown();
2736
+ this.networkStatsbeatMetrics = undefined;
2737
+ this.statsbeatFailureCount = 0;
2738
+ }
2734
2739
  async sendFirstPersistedFile() {
2735
2740
  try {
2736
2741
  const envelopes = (await this.persister.shift());
@@ -2831,11 +2836,9 @@ class Context {
2831
2836
  [Context.nodeVersion] = node.split(".");
2832
2837
  Context.opentelemetryVersion = core.SDK_INFO[semanticConventions.SemanticResourceAttributes.TELEMETRY_SDK_VERSION];
2833
2838
  Context.sdkVersion = packageVersion;
2834
- const prefix = process.env["AZURE_MONITOR_AGENT_PREFIX"]
2835
- ? process.env["AZURE_MONITOR_AGENT_PREFIX"]
2836
- : "";
2839
+ const prefix = process.env["AZURE_MONITOR_PREFIX"] ? process.env["AZURE_MONITOR_PREFIX"] : "";
2837
2840
  const version = process.env["AZURE_MONITOR_DISTRO_VERSION"]
2838
- ? `dst${process.env["AZURE_MONITOR_DISTRO_VERSION"]}`
2841
+ ? `ext${process.env["AZURE_MONITOR_DISTRO_VERSION"]}`
2839
2842
  : `ext${Context.sdkVersion}`;
2840
2843
  const internalSdkVersion = `${prefix}node${Context.nodeVersion}:otel${Context.opentelemetryVersion}:${version}`;
2841
2844
  this.tags[KnownContextTagKeys.AiInternalSdkVersion] = internalSdkVersion;
@@ -2857,6 +2860,9 @@ function getInstance() {
2857
2860
 
2858
2861
  // Copyright (c) Microsoft Corporation.
2859
2862
  // Licensed under the MIT license.
2863
+ function hrTimeToDate(hrTime) {
2864
+ return new Date(core.hrTimeToNanoseconds(hrTime) / 1000000);
2865
+ }
2860
2866
  function createTagsFromResource(resource) {
2861
2867
  const context = getInstance();
2862
2868
  const tags = Object.assign({}, context.tags);
@@ -3034,7 +3040,7 @@ function createResourceMetricEnvelope(resource, instrumentationKey) {
3034
3040
  const envelope = {
3035
3041
  name: "Microsoft.ApplicationInsights.Metric",
3036
3042
  time: new Date(),
3037
- sampleRate: 100,
3043
+ sampleRate: 100, // Metrics are never sampled
3038
3044
  instrumentationKey: instrumentationKey,
3039
3045
  version: 1,
3040
3046
  data: {
@@ -3203,12 +3209,12 @@ function createPropertiesFromSpan(span) {
3203
3209
  }
3204
3210
  function createDependencyData(span) {
3205
3211
  const remoteDependencyData = {
3206
- name: span.name,
3212
+ name: span.name, // Default
3207
3213
  id: `${span.spanContext().spanId}`,
3208
3214
  success: span.status.code !== api.SpanStatusCode.ERROR,
3209
3215
  resultCode: "0",
3210
3216
  type: "Dependency",
3211
- duration: msToTimeSpan(core.hrTimeToMilliseconds(span.duration)),
3217
+ duration: msToTimeSpan(core.hrTimeToMilliseconds(core.addHrTimes(span.duration, core.hrTime()))),
3212
3218
  version: 2,
3213
3219
  };
3214
3220
  if (span.kind === api.SpanKind.PRODUCER) {
@@ -3296,7 +3302,12 @@ function createDependencyData(span) {
3296
3302
  }
3297
3303
  // grpc Dependency
3298
3304
  else if (rpcSystem) {
3299
- remoteDependencyData.type = DependencyTypes.Grpc;
3305
+ if (rpcSystem == DependencyTypes.Wcf) {
3306
+ remoteDependencyData.type = DependencyTypes.Wcf;
3307
+ }
3308
+ else {
3309
+ remoteDependencyData.type = DependencyTypes.Grpc;
3310
+ }
3300
3311
  const grpcStatusCode = span.attributes[semanticConventions.SemanticAttributes.RPC_GRPC_STATUS_CODE];
3301
3312
  if (grpcStatusCode) {
3302
3313
  remoteDependencyData.resultCode = String(grpcStatusCode);
@@ -3316,7 +3327,7 @@ function createRequestData(span) {
3316
3327
  id: `${span.spanContext().spanId}`,
3317
3328
  success: span.status.code !== api.SpanStatusCode.ERROR,
3318
3329
  responseCode: "0",
3319
- duration: msToTimeSpan(core.hrTimeToMilliseconds(span.duration)),
3330
+ duration: msToTimeSpan(core.hrTimeToMilliseconds(core.addHrTimes(span.duration, core.hrTime()))),
3320
3331
  version: 2,
3321
3332
  source: undefined,
3322
3333
  };
@@ -3342,7 +3353,7 @@ function readableSpanToEnvelope(span, ikey) {
3342
3353
  let name;
3343
3354
  let baseType;
3344
3355
  let baseData;
3345
- const time = new Date(core.hrTimeToMilliseconds(span.startTime));
3356
+ const time = hrTimeToDate(span.startTime);
3346
3357
  const instrumentationKey = ikey;
3347
3358
  const tags = createTagsFromSpan(span);
3348
3359
  const [properties, measurements] = createPropertiesFromSpan(span);
@@ -3403,7 +3414,7 @@ function spanEventsToEnvelopes(span, ikey) {
3403
3414
  span.events.forEach((event) => {
3404
3415
  var _a;
3405
3416
  let baseType;
3406
- const time = new Date(core.hrTimeToMilliseconds(event.time));
3417
+ const time = hrTimeToDate(event.time);
3407
3418
  let name = "";
3408
3419
  let baseData;
3409
3420
  const properties = createPropertiesFromSpanAttributes(event.attributes);
@@ -3622,7 +3633,7 @@ class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
3622
3633
  * @internal
3623
3634
  */
3624
3635
  function logToEnvelope(log, ikey) {
3625
- const time = log.hrTime ? new Date(core.hrTimeToMilliseconds(log.hrTime)) : new Date();
3636
+ const time = hrTimeToDate(log.hrTime);
3626
3637
  const sampleRate = 100;
3627
3638
  const instrumentationKey = ikey;
3628
3639
  const tags = createTagsFromLog(log);