@microsoft/opentelemetry 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (347) hide show
  1. package/README.md +69 -4
  2. package/dist/commonjs/a365/configuration/A365Configuration.d.ts +42 -0
  3. package/dist/commonjs/a365/configuration/A365Configuration.d.ts.map +1 -0
  4. package/dist/commonjs/a365/configuration/A365Configuration.js +162 -0
  5. package/dist/commonjs/a365/configuration/A365Configuration.js.map +1 -0
  6. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.d.ts +53 -0
  7. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.d.ts.map +1 -0
  8. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.js +5 -0
  9. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.js.map +1 -0
  10. package/dist/commonjs/a365/configuration/index.d.ts +3 -0
  11. package/dist/commonjs/a365/configuration/index.d.ts.map +1 -0
  12. package/dist/commonjs/a365/configuration/index.js +9 -0
  13. package/dist/commonjs/a365/configuration/index.js.map +1 -0
  14. package/dist/commonjs/a365/constants.d.ts +93 -0
  15. package/dist/commonjs/a365/constants.d.ts.map +1 -0
  16. package/dist/commonjs/a365/constants.js +120 -0
  17. package/dist/commonjs/a365/constants.js.map +1 -0
  18. package/dist/commonjs/a365/context/tokenContext.d.ts +25 -0
  19. package/dist/commonjs/a365/context/tokenContext.d.ts.map +1 -0
  20. package/dist/commonjs/a365/context/tokenContext.js +67 -0
  21. package/dist/commonjs/a365/context/tokenContext.js.map +1 -0
  22. package/dist/commonjs/a365/context.d.ts +31 -0
  23. package/dist/commonjs/a365/context.d.ts.map +1 -0
  24. package/dist/commonjs/a365/context.js +109 -0
  25. package/dist/commonjs/a365/context.js.map +1 -0
  26. package/dist/commonjs/a365/contracts.d.ts +250 -0
  27. package/dist/commonjs/a365/contracts.d.ts.map +1 -0
  28. package/dist/commonjs/a365/contracts.js +52 -0
  29. package/dist/commonjs/a365/contracts.js.map +1 -0
  30. package/dist/commonjs/a365/exporter/Agent365Exporter.d.ts +25 -0
  31. package/dist/commonjs/a365/exporter/Agent365Exporter.d.ts.map +1 -0
  32. package/dist/commonjs/a365/exporter/Agent365Exporter.js +219 -0
  33. package/dist/commonjs/a365/exporter/Agent365Exporter.js.map +1 -0
  34. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.d.ts +43 -0
  35. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.d.ts.map +1 -0
  36. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.js +30 -0
  37. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.js.map +1 -0
  38. package/dist/commonjs/a365/exporter/ExporterEventNames.d.ts +9 -0
  39. package/dist/commonjs/a365/exporter/ExporterEventNames.d.ts.map +1 -0
  40. package/dist/commonjs/a365/exporter/ExporterEventNames.js +15 -0
  41. package/dist/commonjs/a365/exporter/ExporterEventNames.js.map +1 -0
  42. package/dist/commonjs/a365/exporter/index.d.ts +6 -0
  43. package/dist/commonjs/a365/exporter/index.d.ts.map +1 -0
  44. package/dist/commonjs/a365/exporter/index.js +15 -0
  45. package/dist/commonjs/a365/exporter/index.js.map +1 -0
  46. package/dist/commonjs/a365/exporter/utils.d.ts +41 -0
  47. package/dist/commonjs/a365/exporter/utils.d.ts.map +1 -0
  48. package/dist/commonjs/a365/exporter/utils.js +410 -0
  49. package/dist/commonjs/a365/exporter/utils.js.map +1 -0
  50. package/dist/commonjs/a365/hosting/baggageBuilderUtils.d.ts +22 -0
  51. package/dist/commonjs/a365/hosting/baggageBuilderUtils.d.ts.map +1 -0
  52. package/dist/commonjs/a365/hosting/baggageBuilderUtils.js +47 -0
  53. package/dist/commonjs/a365/hosting/baggageBuilderUtils.js.map +1 -0
  54. package/dist/commonjs/a365/hosting/baggageMiddleware.d.ts +9 -0
  55. package/dist/commonjs/a365/hosting/baggageMiddleware.d.ts.map +1 -0
  56. package/dist/commonjs/a365/hosting/baggageMiddleware.js +38 -0
  57. package/dist/commonjs/a365/hosting/baggageMiddleware.js.map +1 -0
  58. package/dist/commonjs/a365/hosting/index.d.ts +9 -0
  59. package/dist/commonjs/a365/hosting/index.d.ts.map +1 -0
  60. package/dist/commonjs/a365/hosting/index.js +25 -0
  61. package/dist/commonjs/a365/hosting/index.js.map +1 -0
  62. package/dist/commonjs/a365/hosting/observabilityHostingManager.d.ts +30 -0
  63. package/dist/commonjs/a365/hosting/observabilityHostingManager.d.ts.map +1 -0
  64. package/dist/commonjs/a365/hosting/observabilityHostingManager.js +49 -0
  65. package/dist/commonjs/a365/hosting/observabilityHostingManager.js.map +1 -0
  66. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.d.ts +24 -0
  67. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.d.ts.map +1 -0
  68. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.js +82 -0
  69. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.js.map +1 -0
  70. package/dist/commonjs/a365/hosting/scopeUtils.d.ts +56 -0
  71. package/dist/commonjs/a365/hosting/scopeUtils.d.ts.map +1 -0
  72. package/dist/commonjs/a365/hosting/scopeUtils.js +161 -0
  73. package/dist/commonjs/a365/hosting/scopeUtils.js.map +1 -0
  74. package/dist/commonjs/a365/hosting/turnContextUtils.d.ts +32 -0
  75. package/dist/commonjs/a365/hosting/turnContextUtils.d.ts.map +1 -0
  76. package/dist/commonjs/a365/hosting/turnContextUtils.js +141 -0
  77. package/dist/commonjs/a365/hosting/turnContextUtils.js.map +1 -0
  78. package/dist/commonjs/a365/hosting/types.d.ts +52 -0
  79. package/dist/commonjs/a365/hosting/types.d.ts.map +1 -0
  80. package/dist/commonjs/a365/hosting/types.js +5 -0
  81. package/dist/commonjs/a365/hosting/types.js.map +1 -0
  82. package/dist/commonjs/a365/index.d.ts +18 -0
  83. package/dist/commonjs/a365/index.d.ts.map +1 -0
  84. package/dist/commonjs/a365/index.js +69 -0
  85. package/dist/commonjs/a365/index.js.map +1 -0
  86. package/dist/commonjs/a365/message-utils.d.ts +42 -0
  87. package/dist/commonjs/a365/message-utils.d.ts.map +1 -0
  88. package/dist/commonjs/a365/message-utils.js +116 -0
  89. package/dist/commonjs/a365/message-utils.js.map +1 -0
  90. package/dist/commonjs/a365/middleware/BaggageBuilder.d.ts +112 -0
  91. package/dist/commonjs/a365/middleware/BaggageBuilder.d.ts.map +1 -0
  92. package/dist/commonjs/a365/middleware/BaggageBuilder.js +248 -0
  93. package/dist/commonjs/a365/middleware/BaggageBuilder.js.map +1 -0
  94. package/dist/commonjs/a365/middleware/index.d.ts +2 -0
  95. package/dist/commonjs/a365/middleware/index.d.ts.map +1 -0
  96. package/dist/commonjs/a365/middleware/index.js +9 -0
  97. package/dist/commonjs/a365/middleware/index.js.map +1 -0
  98. package/dist/commonjs/a365/processors/A365SpanProcessor.d.ts +32 -0
  99. package/dist/commonjs/a365/processors/A365SpanProcessor.d.ts.map +1 -0
  100. package/dist/commonjs/a365/processors/A365SpanProcessor.js +104 -0
  101. package/dist/commonjs/a365/processors/A365SpanProcessor.js.map +1 -0
  102. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.d.ts +44 -0
  103. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.d.ts.map +1 -0
  104. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.js +260 -0
  105. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.js.map +1 -0
  106. package/dist/commonjs/a365/processors/index.d.ts +5 -0
  107. package/dist/commonjs/a365/processors/index.d.ts.map +1 -0
  108. package/dist/commonjs/a365/processors/index.js +13 -0
  109. package/dist/commonjs/a365/processors/index.js.map +1 -0
  110. package/dist/commonjs/a365/processors/util.d.ts +10 -0
  111. package/dist/commonjs/a365/processors/util.d.ts.map +1 -0
  112. package/dist/commonjs/a365/processors/util.js +56 -0
  113. package/dist/commonjs/a365/processors/util.js.map +1 -0
  114. package/dist/commonjs/a365/scopes/ExecuteToolScope.d.ts +24 -0
  115. package/dist/commonjs/a365/scopes/ExecuteToolScope.d.ts.map +1 -0
  116. package/dist/commonjs/a365/scopes/ExecuteToolScope.js +60 -0
  117. package/dist/commonjs/a365/scopes/ExecuteToolScope.js.map +1 -0
  118. package/dist/commonjs/a365/scopes/InferenceScope.d.ts +29 -0
  119. package/dist/commonjs/a365/scopes/InferenceScope.d.ts.map +1 -0
  120. package/dist/commonjs/a365/scopes/InferenceScope.js +75 -0
  121. package/dist/commonjs/a365/scopes/InferenceScope.js.map +1 -0
  122. package/dist/commonjs/a365/scopes/InvokeAgentScope.d.ts +25 -0
  123. package/dist/commonjs/a365/scopes/InvokeAgentScope.d.ts.map +1 -0
  124. package/dist/commonjs/a365/scopes/InvokeAgentScope.js +84 -0
  125. package/dist/commonjs/a365/scopes/InvokeAgentScope.js.map +1 -0
  126. package/dist/commonjs/a365/scopes/OpenTelemetryScope.d.ts +69 -0
  127. package/dist/commonjs/a365/scopes/OpenTelemetryScope.d.ts.map +1 -0
  128. package/dist/commonjs/a365/scopes/OpenTelemetryScope.js +211 -0
  129. package/dist/commonjs/a365/scopes/OpenTelemetryScope.js.map +1 -0
  130. package/dist/commonjs/a365/scopes/OutputScope.d.ts +26 -0
  131. package/dist/commonjs/a365/scopes/OutputScope.d.ts.map +1 -0
  132. package/dist/commonjs/a365/scopes/OutputScope.js +73 -0
  133. package/dist/commonjs/a365/scopes/OutputScope.js.map +1 -0
  134. package/dist/commonjs/a365/scopes/index.d.ts +6 -0
  135. package/dist/commonjs/a365/scopes/index.d.ts.map +1 -0
  136. package/dist/commonjs/a365/scopes/index.js +16 -0
  137. package/dist/commonjs/a365/scopes/index.js.map +1 -0
  138. package/dist/commonjs/a365/utils/utils.d.ts +6 -0
  139. package/dist/commonjs/a365/utils/utils.d.ts.map +1 -0
  140. package/dist/commonjs/a365/utils/utils.js +14 -0
  141. package/dist/commonjs/a365/utils/utils.js.map +1 -0
  142. package/dist/commonjs/azureMonitor/index.d.ts +14 -0
  143. package/dist/commonjs/azureMonitor/index.d.ts.map +1 -1
  144. package/dist/commonjs/azureMonitor/index.js +29 -0
  145. package/dist/commonjs/azureMonitor/index.js.map +1 -1
  146. package/dist/commonjs/azureMonitor/metrics/handler.js +2 -2
  147. package/dist/commonjs/azureMonitor/metrics/handler.js.map +1 -1
  148. package/dist/commonjs/azureMonitor/metrics/quickpulse/types.d.ts +1 -1
  149. package/dist/commonjs/azureMonitor/traces/handler.d.ts +0 -3
  150. package/dist/commonjs/azureMonitor/traces/handler.d.ts.map +1 -1
  151. package/dist/commonjs/azureMonitor/traces/handler.js +8 -19
  152. package/dist/commonjs/azureMonitor/traces/handler.js.map +1 -1
  153. package/dist/commonjs/distro/distro.d.ts +3 -1
  154. package/dist/commonjs/distro/distro.d.ts.map +1 -1
  155. package/dist/commonjs/distro/distro.js +88 -92
  156. package/dist/commonjs/distro/distro.js.map +1 -1
  157. package/dist/commonjs/distro/instrumentations.d.ts +31 -0
  158. package/dist/commonjs/distro/instrumentations.d.ts.map +1 -0
  159. package/dist/commonjs/distro/instrumentations.js +131 -0
  160. package/dist/commonjs/distro/instrumentations.js.map +1 -0
  161. package/dist/commonjs/distro/types.d.ts +2 -1
  162. package/dist/commonjs/distro/types.d.ts.map +1 -1
  163. package/dist/commonjs/index.d.ts +8 -12
  164. package/dist/commonjs/index.d.ts.map +1 -1
  165. package/dist/commonjs/index.js +48 -20
  166. package/dist/commonjs/index.js.map +1 -1
  167. package/dist/commonjs/package.json +1 -0
  168. package/dist/commonjs/shared/jsonConfig.d.ts +2 -1
  169. package/dist/commonjs/shared/jsonConfig.d.ts.map +1 -1
  170. package/dist/commonjs/shared/module.js +15 -11
  171. package/dist/commonjs/shared/module.js.map +1 -1
  172. package/dist/commonjs/types.d.ts +8 -32
  173. package/dist/commonjs/types.d.ts.map +1 -1
  174. package/dist/commonjs/types.js +1 -1
  175. package/dist/commonjs/types.js.map +1 -1
  176. package/dist/esm/a365/configuration/A365Configuration.d.ts +42 -0
  177. package/dist/esm/a365/configuration/A365Configuration.d.ts.map +1 -0
  178. package/dist/esm/a365/configuration/A365Configuration.js +158 -0
  179. package/dist/esm/a365/configuration/A365Configuration.js.map +1 -0
  180. package/dist/esm/a365/configuration/A365ConfigurationOptions.d.ts +53 -0
  181. package/dist/esm/a365/configuration/A365ConfigurationOptions.d.ts.map +1 -0
  182. package/dist/esm/a365/configuration/A365ConfigurationOptions.js +4 -0
  183. package/dist/esm/a365/configuration/A365ConfigurationOptions.js.map +1 -0
  184. package/dist/esm/a365/configuration/index.d.ts +3 -0
  185. package/dist/esm/a365/configuration/index.d.ts.map +1 -0
  186. package/dist/esm/a365/configuration/index.js +4 -0
  187. package/dist/esm/a365/configuration/index.js.map +1 -0
  188. package/dist/esm/a365/constants.d.ts +93 -0
  189. package/dist/esm/a365/constants.d.ts.map +1 -0
  190. package/dist/esm/a365/constants.js +116 -0
  191. package/dist/esm/a365/constants.js.map +1 -0
  192. package/dist/esm/a365/context/tokenContext.d.ts +25 -0
  193. package/dist/esm/a365/context/tokenContext.d.ts.map +1 -0
  194. package/dist/esm/a365/context/tokenContext.js +62 -0
  195. package/dist/esm/a365/context/tokenContext.js.map +1 -0
  196. package/dist/esm/a365/context.d.ts +31 -0
  197. package/dist/esm/a365/context.d.ts.map +1 -0
  198. package/dist/esm/a365/context.js +101 -0
  199. package/dist/esm/a365/context.js.map +1 -0
  200. package/dist/esm/a365/contracts.d.ts +250 -0
  201. package/dist/esm/a365/contracts.d.ts.map +1 -0
  202. package/dist/esm/a365/contracts.js +49 -0
  203. package/dist/esm/a365/contracts.js.map +1 -0
  204. package/dist/esm/a365/exporter/Agent365Exporter.d.ts +25 -0
  205. package/dist/esm/a365/exporter/Agent365Exporter.d.ts.map +1 -0
  206. package/dist/esm/a365/exporter/Agent365Exporter.js +215 -0
  207. package/dist/esm/a365/exporter/Agent365Exporter.js.map +1 -0
  208. package/dist/esm/a365/exporter/Agent365ExporterOptions.d.ts +43 -0
  209. package/dist/esm/a365/exporter/Agent365ExporterOptions.d.ts.map +1 -0
  210. package/dist/esm/a365/exporter/Agent365ExporterOptions.js +26 -0
  211. package/dist/esm/a365/exporter/Agent365ExporterOptions.js.map +1 -0
  212. package/dist/esm/a365/exporter/ExporterEventNames.d.ts +9 -0
  213. package/dist/esm/a365/exporter/ExporterEventNames.d.ts.map +1 -0
  214. package/dist/esm/a365/exporter/ExporterEventNames.js +12 -0
  215. package/dist/esm/a365/exporter/ExporterEventNames.js.map +1 -0
  216. package/dist/esm/a365/exporter/index.d.ts +6 -0
  217. package/dist/esm/a365/exporter/index.d.ts.map +1 -0
  218. package/dist/esm/a365/exporter/index.js +7 -0
  219. package/dist/esm/a365/exporter/index.js.map +1 -0
  220. package/dist/esm/a365/exporter/utils.d.ts +41 -0
  221. package/dist/esm/a365/exporter/utils.d.ts.map +1 -0
  222. package/dist/esm/a365/exporter/utils.js +398 -0
  223. package/dist/esm/a365/exporter/utils.js.map +1 -0
  224. package/dist/esm/a365/hosting/baggageBuilderUtils.d.ts +22 -0
  225. package/dist/esm/a365/hosting/baggageBuilderUtils.d.ts.map +1 -0
  226. package/dist/esm/a365/hosting/baggageBuilderUtils.js +43 -0
  227. package/dist/esm/a365/hosting/baggageBuilderUtils.js.map +1 -0
  228. package/dist/esm/a365/hosting/baggageMiddleware.d.ts +9 -0
  229. package/dist/esm/a365/hosting/baggageMiddleware.d.ts.map +1 -0
  230. package/dist/esm/a365/hosting/baggageMiddleware.js +34 -0
  231. package/dist/esm/a365/hosting/baggageMiddleware.js.map +1 -0
  232. package/dist/esm/a365/hosting/index.d.ts +9 -0
  233. package/dist/esm/a365/hosting/index.d.ts.map +1 -0
  234. package/dist/esm/a365/hosting/index.js +9 -0
  235. package/dist/esm/a365/hosting/index.js.map +1 -0
  236. package/dist/esm/a365/hosting/observabilityHostingManager.d.ts +30 -0
  237. package/dist/esm/a365/hosting/observabilityHostingManager.d.ts.map +1 -0
  238. package/dist/esm/a365/hosting/observabilityHostingManager.js +45 -0
  239. package/dist/esm/a365/hosting/observabilityHostingManager.js.map +1 -0
  240. package/dist/esm/a365/hosting/outputLoggingMiddleware.d.ts +24 -0
  241. package/dist/esm/a365/hosting/outputLoggingMiddleware.d.ts.map +1 -0
  242. package/dist/esm/a365/hosting/outputLoggingMiddleware.js +78 -0
  243. package/dist/esm/a365/hosting/outputLoggingMiddleware.js.map +1 -0
  244. package/dist/esm/a365/hosting/scopeUtils.d.ts +56 -0
  245. package/dist/esm/a365/hosting/scopeUtils.d.ts.map +1 -0
  246. package/dist/esm/a365/hosting/scopeUtils.js +157 -0
  247. package/dist/esm/a365/hosting/scopeUtils.js.map +1 -0
  248. package/dist/esm/a365/hosting/turnContextUtils.d.ts +32 -0
  249. package/dist/esm/a365/hosting/turnContextUtils.d.ts.map +1 -0
  250. package/dist/esm/a365/hosting/turnContextUtils.js +133 -0
  251. package/dist/esm/a365/hosting/turnContextUtils.js.map +1 -0
  252. package/dist/esm/a365/hosting/types.d.ts +52 -0
  253. package/dist/esm/a365/hosting/types.d.ts.map +1 -0
  254. package/dist/esm/a365/hosting/types.js +4 -0
  255. package/dist/esm/a365/hosting/types.js.map +1 -0
  256. package/dist/esm/a365/index.d.ts +18 -0
  257. package/dist/esm/a365/index.d.ts.map +1 -0
  258. package/dist/esm/a365/index.js +22 -0
  259. package/dist/esm/a365/index.js.map +1 -0
  260. package/dist/esm/a365/message-utils.d.ts +42 -0
  261. package/dist/esm/a365/message-utils.d.ts.map +1 -0
  262. package/dist/esm/a365/message-utils.js +107 -0
  263. package/dist/esm/a365/message-utils.js.map +1 -0
  264. package/dist/esm/a365/middleware/BaggageBuilder.d.ts +112 -0
  265. package/dist/esm/a365/middleware/BaggageBuilder.d.ts.map +1 -0
  266. package/dist/esm/a365/middleware/BaggageBuilder.js +243 -0
  267. package/dist/esm/a365/middleware/BaggageBuilder.js.map +1 -0
  268. package/dist/esm/a365/middleware/index.d.ts +2 -0
  269. package/dist/esm/a365/middleware/index.d.ts.map +1 -0
  270. package/dist/esm/a365/middleware/index.js +4 -0
  271. package/dist/esm/a365/middleware/index.js.map +1 -0
  272. package/dist/esm/a365/processors/A365SpanProcessor.d.ts +32 -0
  273. package/dist/esm/a365/processors/A365SpanProcessor.d.ts.map +1 -0
  274. package/dist/esm/a365/processors/A365SpanProcessor.js +100 -0
  275. package/dist/esm/a365/processors/A365SpanProcessor.js.map +1 -0
  276. package/dist/esm/a365/processors/PerRequestSpanProcessor.d.ts +44 -0
  277. package/dist/esm/a365/processors/PerRequestSpanProcessor.d.ts.map +1 -0
  278. package/dist/esm/a365/processors/PerRequestSpanProcessor.js +256 -0
  279. package/dist/esm/a365/processors/PerRequestSpanProcessor.js.map +1 -0
  280. package/dist/esm/a365/processors/index.d.ts +5 -0
  281. package/dist/esm/a365/processors/index.d.ts.map +1 -0
  282. package/dist/esm/a365/processors/index.js +6 -0
  283. package/dist/esm/a365/processors/index.js.map +1 -0
  284. package/dist/esm/a365/processors/util.d.ts +10 -0
  285. package/dist/esm/a365/processors/util.d.ts.map +1 -0
  286. package/dist/esm/a365/processors/util.js +53 -0
  287. package/dist/esm/a365/processors/util.js.map +1 -0
  288. package/dist/esm/a365/scopes/ExecuteToolScope.d.ts +24 -0
  289. package/dist/esm/a365/scopes/ExecuteToolScope.d.ts.map +1 -0
  290. package/dist/esm/a365/scopes/ExecuteToolScope.js +56 -0
  291. package/dist/esm/a365/scopes/ExecuteToolScope.js.map +1 -0
  292. package/dist/esm/a365/scopes/InferenceScope.d.ts +29 -0
  293. package/dist/esm/a365/scopes/InferenceScope.d.ts.map +1 -0
  294. package/dist/esm/a365/scopes/InferenceScope.js +71 -0
  295. package/dist/esm/a365/scopes/InferenceScope.js.map +1 -0
  296. package/dist/esm/a365/scopes/InvokeAgentScope.d.ts +25 -0
  297. package/dist/esm/a365/scopes/InvokeAgentScope.d.ts.map +1 -0
  298. package/dist/esm/a365/scopes/InvokeAgentScope.js +80 -0
  299. package/dist/esm/a365/scopes/InvokeAgentScope.js.map +1 -0
  300. package/dist/esm/a365/scopes/OpenTelemetryScope.d.ts +69 -0
  301. package/dist/esm/a365/scopes/OpenTelemetryScope.d.ts.map +1 -0
  302. package/dist/esm/a365/scopes/OpenTelemetryScope.js +207 -0
  303. package/dist/esm/a365/scopes/OpenTelemetryScope.js.map +1 -0
  304. package/dist/esm/a365/scopes/OutputScope.d.ts +26 -0
  305. package/dist/esm/a365/scopes/OutputScope.d.ts.map +1 -0
  306. package/dist/esm/a365/scopes/OutputScope.js +69 -0
  307. package/dist/esm/a365/scopes/OutputScope.js.map +1 -0
  308. package/dist/esm/a365/scopes/index.d.ts +6 -0
  309. package/dist/esm/a365/scopes/index.d.ts.map +1 -0
  310. package/dist/esm/a365/scopes/index.js +8 -0
  311. package/dist/esm/a365/scopes/index.js.map +1 -0
  312. package/dist/esm/a365/utils/utils.d.ts +6 -0
  313. package/dist/esm/a365/utils/utils.d.ts.map +1 -0
  314. package/dist/esm/a365/utils/utils.js +11 -0
  315. package/dist/esm/a365/utils/utils.js.map +1 -0
  316. package/dist/esm/azureMonitor/index.d.ts +14 -0
  317. package/dist/esm/azureMonitor/index.d.ts.map +1 -1
  318. package/dist/esm/azureMonitor/index.js +27 -0
  319. package/dist/esm/azureMonitor/index.js.map +1 -1
  320. package/dist/esm/azureMonitor/metrics/handler.js +2 -2
  321. package/dist/esm/azureMonitor/metrics/handler.js.map +1 -1
  322. package/dist/esm/azureMonitor/metrics/quickpulse/types.d.ts +1 -1
  323. package/dist/esm/azureMonitor/traces/handler.d.ts +0 -3
  324. package/dist/esm/azureMonitor/traces/handler.d.ts.map +1 -1
  325. package/dist/esm/azureMonitor/traces/handler.js +6 -19
  326. package/dist/esm/azureMonitor/traces/handler.js.map +1 -1
  327. package/dist/esm/distro/distro.d.ts +3 -1
  328. package/dist/esm/distro/distro.d.ts.map +1 -1
  329. package/dist/esm/distro/distro.js +89 -93
  330. package/dist/esm/distro/distro.js.map +1 -1
  331. package/dist/esm/distro/instrumentations.d.ts +31 -0
  332. package/dist/esm/distro/instrumentations.d.ts.map +1 -0
  333. package/dist/esm/distro/instrumentations.js +126 -0
  334. package/dist/esm/distro/instrumentations.js.map +1 -0
  335. package/dist/esm/distro/types.d.ts +2 -1
  336. package/dist/esm/distro/types.d.ts.map +1 -1
  337. package/dist/esm/index.d.ts +8 -12
  338. package/dist/esm/index.d.ts.map +1 -1
  339. package/dist/esm/index.js +6 -17
  340. package/dist/esm/index.js.map +1 -1
  341. package/dist/esm/shared/jsonConfig.d.ts +2 -1
  342. package/dist/esm/shared/jsonConfig.d.ts.map +1 -1
  343. package/dist/esm/types.d.ts +8 -32
  344. package/dist/esm/types.d.ts.map +1 -1
  345. package/dist/esm/types.js +1 -1
  346. package/dist/esm/types.js.map +1 -1
  347. package/package.json +7 -8
@@ -0,0 +1,18 @@
1
+ export { A365Configuration, A365_ENV_VARS } from "./configuration/index.js";
2
+ export type { A365Options, ClusterCategory, A365BaggageOptions, A365HostingOptions, } from "./configuration/index.js";
3
+ export { Agent365Exporter } from "./exporter/index.js";
4
+ export type { Agent365ExporterOptions, TokenResolver } from "./exporter/index.js";
5
+ export { ResolvedExporterOptions } from "./exporter/index.js";
6
+ export { OpenTelemetryScope, InvokeAgentScope, ExecuteToolScope, InferenceScope, OutputScope, } from "./scopes/index.js";
7
+ export { OpenTelemetryConstants } from "./constants.js";
8
+ export { MessageRole, FinishReason, Modality, InvocationRole, InferenceOperationType, A365_MESSAGE_SCHEMA_VERSION, } from "./contracts.js";
9
+ export type { ChatMessage, InputMessages, OutputMessage, OutputMessages, InputMessagesParam, OutputMessagesParam, ResponseMessagesParam, MessagePart, TextPart, ToolCallRequestPart, ToolCallResponsePart, ReasoningPart, AgentDetails, UserDetails, CallerDetails, Request, Channel, ServiceEndpoint, InvokeAgentScopeDetails, ToolCallDetails, InferenceDetails, InferenceResponse, OutputResponse, SpanDetails, ParentSpanRef, ParentContext, } from "./contracts.js";
10
+ export { isParentSpanRef, createContextWithParentSpanRef, runWithParentSpanRef, injectContextToHeaders, extractContextFromHeaders, runWithExtractedTraceContext, } from "./context.js";
11
+ export type { HeadersCarrier } from "./context.js";
12
+ export { BaggageBuilder, BaggageScope } from "./middleware/index.js";
13
+ export { A365SpanProcessor, PerRequestSpanProcessor, GENERIC_ATTRIBUTES, INVOKE_AGENT_ATTRIBUTES, } from "./processors/index.js";
14
+ export type { PerRequestSpanProcessorOptions } from "./processors/index.js";
15
+ export { runWithExportToken, updateExportToken, getExportToken } from "./context/tokenContext.js";
16
+ export { BaggageBuilderUtils, ScopeUtils, getCallerBaggagePairs, getTargetAgentBaggagePairs, getTenantIdPair, getChannelBaggagePairs, getConversationIdAndItemLinkPairs, resolveEmbodiedAgentIds, BaggageMiddleware, OutputLoggingMiddleware, A365_PARENT_SPAN_KEY, A365_AUTH_TOKEN_KEY, ObservabilityHostingManager, } from "./hosting/index.js";
17
+ export type { ObservabilityHostingOptions, TurnContextLike, ActivityLike, MiddlewareLike, SendActivitiesHandler, } from "./hosting/index.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/a365/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EACV,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,2B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under the MIT License.
3
+ export { A365Configuration, A365_ENV_VARS } from "./configuration/index.js";
4
+ export { Agent365Exporter } from "./exporter/index.js";
5
+ export { ResolvedExporterOptions } from "./exporter/index.js";
6
+ // ── Scopes (manual telemetry API) ───────────────────────────────────────────
7
+ export { OpenTelemetryScope, InvokeAgentScope, ExecuteToolScope, InferenceScope, OutputScope, } from "./scopes/index.js";
8
+ // ── Constants ───────────────────────────────────────────────────────────────
9
+ export { OpenTelemetryConstants } from "./constants.js";
10
+ // ── Contracts (types & enums) ───────────────────────────────────────────────
11
+ export { MessageRole, FinishReason, Modality, InvocationRole, InferenceOperationType, A365_MESSAGE_SCHEMA_VERSION, } from "./contracts.js";
12
+ // ── Context propagation ─────────────────────────────────────────────────────
13
+ export { isParentSpanRef, createContextWithParentSpanRef, runWithParentSpanRef, injectContextToHeaders, extractContextFromHeaders, runWithExtractedTraceContext, } from "./context.js";
14
+ // ── Middleware (BaggageBuilder) ──────────────────────────────────────────────
15
+ export { BaggageBuilder, BaggageScope } from "./middleware/index.js";
16
+ // ── Processors ──────────────────────────────────────────────────────────────
17
+ export { A365SpanProcessor, PerRequestSpanProcessor, GENERIC_ATTRIBUTES, INVOKE_AGENT_ATTRIBUTES, } from "./processors/index.js";
18
+ // ── Token context ───────────────────────────────────────────────────────────
19
+ export { runWithExportToken, updateExportToken, getExportToken } from "./context/tokenContext.js";
20
+ // ── Hosting utilities ───────────────────────────────────────────────────────
21
+ export { BaggageBuilderUtils, ScopeUtils, getCallerBaggagePairs, getTargetAgentBaggagePairs, getTenantIdPair, getChannelBaggagePairs, getConversationIdAndItemLinkPairs, resolveEmbodiedAgentIds, BaggageMiddleware, OutputLoggingMiddleware, A365_PARENT_SPAN_KEY, A365_AUTH_TOKEN_KEY, ObservabilityHostingManager, } from "./hosting/index.js";
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/a365/index.ts"],"names":[],"mappings":"AAAA,uC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ages.
3
+ *
4
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/message-utils.ts
5
+ */
6
+ import type { ChatMessage, OutputMessage, InputMessages, OutputMessages, InputMessagesParam, OutputMessagesParam } from "./contracts.js";
7
+ /**
8
+ * Type guard that returns `true` when the input is a versioned wrapper
9
+ * object (`InputMessages` or `OutputMessages`).
10
+ */
11
+ export declare function isWrappedMessages(input: InputMessagesParam | OutputMessagesParam): input is InputMessages | OutputMessages;
12
+ /** Converts plain input strings into OTEL input messages. */
13
+ export declare function toInputMessages(messages: string[]): ChatMessage[];
14
+ /** Converts plain output strings into OTEL output messages. */
15
+ export declare function toOutputMessages(messages: string[]): OutputMessage[];
16
+ /**
17
+ * Normalizes an `InputMessagesParam` to a versioned `InputMessages` wrapper.
18
+ * - `string` / `string[]` → converted to `ChatMessage[]` and wrapped
19
+ * - `InputMessages` → returned as-is
20
+ */
21
+ export declare function normalizeInputMessages(param: InputMessagesParam): InputMessages;
22
+ /**
23
+ * Normalizes an `OutputMessagesParam` to a versioned `OutputMessages` wrapper.
24
+ * - `string` / `string[]` → converted to `OutputMessage[]` and wrapped
25
+ * - `OutputMessages` → returned as-is
26
+ */
27
+ export declare function normalizeOutputMessages(param: OutputMessagesParam): OutputMessages;
28
+ /**
29
+ * Serializes a versioned message wrapper to JSON.
30
+ *
31
+ * The try/catch ensures telemetry recording is non-throwing even when
32
+ * message parts contain non-JSON-serializable values.
33
+ */
34
+ export declare function serializeMessages(wrapper: InputMessages | OutputMessages): string;
35
+ /**
36
+ * Ensures the value is always a JSON-parseable string.
37
+ * - Objects are serialized via JSON.stringify.
38
+ * - Strings that are already valid JSON objects/arrays are passed through.
39
+ * - All other strings are wrapped: `{ [key]: value }`.
40
+ */
41
+ export declare function safeSerializeToJson(value: Record<string, unknown> | string, key: string): string;
42
+ //# sourceMappingURL=message-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-utils.d.ts","sourceRoot":"","sources":["../../../src/a365/message-utils.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAGxB;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,GAC9C,KAAK,IAAI,aAAa,GAAG,cAAc,CAQzC;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAKjE;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAKpE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAM/E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAMlF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,GAAG,MAAM,CAmBjF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBhG"}
@@ -0,0 +1,107 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { MessageRole, A365_MESSAGE_SCHEMA_VERSION } from "./contracts.js";
4
+ /**
5
+ * Type guard that returns `true` when the input is a versioned wrapper
6
+ * object (`InputMessages` or `OutputMessages`).
7
+ */
8
+ export function isWrappedMessages(input) {
9
+ return (!Array.isArray(input) &&
10
+ typeof input === "object" &&
11
+ input !== null &&
12
+ "version" in input &&
13
+ "messages" in input);
14
+ }
15
+ /** Converts plain input strings into OTEL input messages. */
16
+ export function toInputMessages(messages) {
17
+ return messages.map((content) => ({
18
+ role: MessageRole.USER,
19
+ parts: [{ type: "text", content }],
20
+ }));
21
+ }
22
+ /** Converts plain output strings into OTEL output messages. */
23
+ export function toOutputMessages(messages) {
24
+ return messages.map((content) => ({
25
+ role: MessageRole.ASSISTANT,
26
+ parts: [{ type: "text", content }],
27
+ }));
28
+ }
29
+ /**
30
+ * Normalizes an `InputMessagesParam` to a versioned `InputMessages` wrapper.
31
+ * - `string` / `string[]` → converted to `ChatMessage[]` and wrapped
32
+ * - `InputMessages` → returned as-is
33
+ */
34
+ export function normalizeInputMessages(param) {
35
+ if (typeof param === "string" || Array.isArray(param)) {
36
+ const arr = typeof param === "string" ? [param] : param;
37
+ return { version: A365_MESSAGE_SCHEMA_VERSION, messages: toInputMessages(arr) };
38
+ }
39
+ return param;
40
+ }
41
+ /**
42
+ * Normalizes an `OutputMessagesParam` to a versioned `OutputMessages` wrapper.
43
+ * - `string` / `string[]` → converted to `OutputMessage[]` and wrapped
44
+ * - `OutputMessages` → returned as-is
45
+ */
46
+ export function normalizeOutputMessages(param) {
47
+ if (typeof param === "string" || Array.isArray(param)) {
48
+ const arr = typeof param === "string" ? [param] : param;
49
+ return { version: A365_MESSAGE_SCHEMA_VERSION, messages: toOutputMessages(arr) };
50
+ }
51
+ return param;
52
+ }
53
+ /**
54
+ * Serializes a versioned message wrapper to JSON.
55
+ *
56
+ * The try/catch ensures telemetry recording is non-throwing even when
57
+ * message parts contain non-JSON-serializable values.
58
+ */
59
+ export function serializeMessages(wrapper) {
60
+ try {
61
+ return JSON.stringify(wrapper);
62
+ }
63
+ catch {
64
+ return JSON.stringify({
65
+ version: A365_MESSAGE_SCHEMA_VERSION,
66
+ messages: [
67
+ {
68
+ role: MessageRole.SYSTEM,
69
+ parts: [
70
+ {
71
+ type: "text",
72
+ content: `[serialization failed: ${wrapper.messages.length} ${wrapper.messages.length === 1 ? "message" : "messages"}]`,
73
+ },
74
+ ],
75
+ },
76
+ ],
77
+ });
78
+ }
79
+ }
80
+ /**
81
+ * Ensures the value is always a JSON-parseable string.
82
+ * - Objects are serialized via JSON.stringify.
83
+ * - Strings that are already valid JSON objects/arrays are passed through.
84
+ * - All other strings are wrapped: `{ [key]: value }`.
85
+ */
86
+ export function safeSerializeToJson(value, key) {
87
+ if (typeof value === "object" && value !== null) {
88
+ try {
89
+ return JSON.stringify(value);
90
+ }
91
+ catch {
92
+ return JSON.stringify({ error: "serialization failed" });
93
+ }
94
+ }
95
+ const str = value;
96
+ try {
97
+ const parsed = JSON.parse(str);
98
+ if (parsed !== null && typeof parsed === "object") {
99
+ return str;
100
+ }
101
+ }
102
+ catch {
103
+ // not valid JSON — fall through to wrap
104
+ }
105
+ return JSON.stringify({ [key]: str });
106
+ }
107
+ //# sourceMappingURL=message-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-utils.js","sourceRoot":"","sources":["../../../src/a365/message-utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAgBlC,OAAO,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA+C;IAE/C,OAAO,CACL,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,UAAU,IAAI,KAAK,CACpB,CAAC;AACJ,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,eAAe,CAAC,QAAkB;IAChD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,CAAC;KAC5C,CAAC,CAAC,CAAC;AACN,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,gBAAgB,CAAC,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AAE,2BAA2B;YACpC,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,WAAW,CAAC,MAAM;oBACxB,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,MAAM;4BACZ,OAAO,EAAE,0BAA0B,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG;yBACxH;qBACF;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAuC,EAAE,GAAW;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IACD,MAAM,GAAG,GAAG,KAAe,CAAC;IAC5B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;QAC1C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAClD,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wCAAwC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import type { Context } from "@opentelemetry/api";
2
+ /**
3
+ * Fluent builder for setting OpenTelemetry baggage values.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const scope = new BaggageBuilder()
8
+ * .tenantId("tenant-123")
9
+ * .agentId("agent-456")
10
+ * .build();
11
+ *
12
+ * scope.run(() => {
13
+ * // Baggage is active in this context
14
+ * });
15
+ * ```
16
+ */
17
+ export declare class BaggageBuilder {
18
+ private pairs;
19
+ /** Set the operation source baggage value (e.g., ATG, ACF). */
20
+ operationSource(value: string | null | undefined): BaggageBuilder;
21
+ /** Set the tenant ID baggage value. */
22
+ tenantId(value: string | null | undefined): BaggageBuilder;
23
+ /** Set the agent ID baggage value. */
24
+ agentId(value: string | null | undefined): BaggageBuilder;
25
+ /** Set the agent AUID baggage value. */
26
+ agentAuid(value: string | null | undefined): BaggageBuilder;
27
+ /** Set the agent email baggage value. */
28
+ agentEmail(value: string | null | undefined): BaggageBuilder;
29
+ /** Set the agent blueprint ID baggage value. */
30
+ agentBlueprintId(value: string | null | undefined): BaggageBuilder;
31
+ /** Set the session ID baggage value. */
32
+ sessionId(value: string): BaggageBuilder;
33
+ /** Set the user ID baggage value. */
34
+ userId(value: string | null | undefined): BaggageBuilder;
35
+ /** Set the agent name baggage value. */
36
+ agentName(value: string | null | undefined): BaggageBuilder;
37
+ /** Set the agent description baggage value. */
38
+ agentDescription(value: string | null | undefined): BaggageBuilder;
39
+ /** Set the agent platform ID baggage value. */
40
+ agentPlatformId(value: string | null | undefined): BaggageBuilder;
41
+ /** Set the agent version baggage value. */
42
+ agentVersion(value: string | null | undefined): BaggageBuilder;
43
+ /** Set the session description baggage value. */
44
+ sessionDescription(value: string | null | undefined): BaggageBuilder;
45
+ /** Set the user name baggage value. */
46
+ userName(value: string | null | undefined): BaggageBuilder;
47
+ /** Set the user email baggage value. */
48
+ userEmail(value: string | null | undefined): BaggageBuilder;
49
+ /** Set the caller client IP baggage value. */
50
+ callerClientIp(value: string | null | undefined): BaggageBuilder;
51
+ /** Set the caller agent platform ID baggage value. */
52
+ callerAgentPlatformId(value: string | null | undefined): BaggageBuilder;
53
+ /** Set the conversation ID baggage value. */
54
+ conversationId(value: string | null | undefined): BaggageBuilder;
55
+ /** Set the conversation item link baggage value. */
56
+ conversationItemLink(value: string | null | undefined): BaggageBuilder;
57
+ /** Set the channel name (e.g., Teams, Slack). */
58
+ channelName(value: string | null | undefined): BaggageBuilder;
59
+ /** Set the channel link/URL. */
60
+ channelLink(value: string | null | undefined): BaggageBuilder;
61
+ /**
62
+ * Sets the invoke agent server address and port baggage values.
63
+ * @param address The server address (hostname) of the target agent service.
64
+ * @param port Optional server port. Only recorded when different from 443.
65
+ */
66
+ invokeAgentServer(address: string | null | undefined, port?: number): BaggageBuilder;
67
+ /**
68
+ * Set multiple baggage pairs from a dictionary or iterable.
69
+ * @param pairs Dictionary or iterable of key-value pairs
70
+ */
71
+ setPairs(pairs: Record<string, any> | Iterable<[string, any]> | null | undefined): BaggageBuilder;
72
+ /**
73
+ * Apply the collected baggage to the current context.
74
+ * @returns A BaggageScope that can run callbacks under the baggage context
75
+ */
76
+ build(): BaggageScope;
77
+ /**
78
+ * Add a baggage key/value if the value is not null or whitespace.
79
+ */
80
+ private set;
81
+ /**
82
+ * Convenience method to begin a request baggage scope with common fields.
83
+ * @param tenantId The tenant ID
84
+ * @param agentId The agent ID
85
+ * @returns A BaggageScope with tenant and agent ID set
86
+ */
87
+ static setRequestContext(tenantId?: string | null, agentId?: string | null): BaggageScope;
88
+ }
89
+ /**
90
+ * Context manager for baggage scope.
91
+ *
92
+ * Manages the lifecycle of baggage values, setting them in the OTel context
93
+ * and restoring the previous context when the scope ends.
94
+ */
95
+ export declare class BaggageScope {
96
+ /** @internal Exposed for testing. */
97
+ readonly contextWithBaggage: Context;
98
+ constructor(pairs: Map<string, string>);
99
+ /**
100
+ * Execute a synchronous function under this baggage scope.
101
+ * Automatically restores previous context afterward.
102
+ */
103
+ run<T>(fn: () => T): T;
104
+ /**
105
+ * Dispose is a no-op because OpenTelemetry JS automatically restores
106
+ * the previous context after `context.with()` completes.
107
+ */
108
+ [Symbol.dispose](): void;
109
+ /** Manual cleanup alternative if caller isn't using `using`. */
110
+ dispose(): void;
111
+ }
112
+ //# sourceMappingURL=BaggageBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaggageBuilder.d.ts","sourceRoot":"","sources":["../../../../src/a365/middleware/BaggageBuilder.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAkC;IAE/C,+DAA+D;IAC/D,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAKjE,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAK1D,sCAAsC;IACtC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAKzD,wCAAwC;IACxC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAK3D,yCAAyC;IACzC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAK5D,gDAAgD;IAChD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAKlE,wCAAwC;IACxC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;IAKxC,qCAAqC;IACrC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAKxD,wCAAwC;IACxC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAK3D,+CAA+C;IAC/C,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAKlE,+CAA+C;IAC/C,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAA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YAAY;IAIrB;;OAEG;IACH,OAAO,CAAC,GAAG;IASX;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY;CAG1F;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,qCAAqC;IACrC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;gBAEzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAgBtC;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAItB;;;OAGG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,gEAAgE;IAChE,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,243 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Per-request baggage builder for OpenTelemetry context propagation.
5
+ *
6
+ * Provides a fluent API for setting baggage values that will be propagated
7
+ * in the OpenTelemetry context and stamped onto spans by the SpanProcessor.
8
+ *
9
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts
10
+ */
11
+ import { propagation, context as otelContext } from "@opentelemetry/api";
12
+ import { OpenTelemetryConstants } from "../constants.js";
13
+ /**
14
+ * Fluent builder for setting OpenTelemetry baggage values.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const scope = new BaggageBuilder()
19
+ * .tenantId("tenant-123")
20
+ * .agentId("agent-456")
21
+ * .build();
22
+ *
23
+ * scope.run(() => {
24
+ * // Baggage is active in this context
25
+ * });
26
+ * ```
27
+ */
28
+ export class BaggageBuilder {
29
+ pairs = new Map();
30
+ /** Set the operation source baggage value (e.g., ATG, ACF). */
31
+ operationSource(value) {
32
+ this.set(OpenTelemetryConstants.SERVICE_NAME_KEY, value);
33
+ return this;
34
+ }
35
+ /** Set the tenant ID baggage value. */
36
+ tenantId(value) {
37
+ this.set(OpenTelemetryConstants.TENANT_ID_KEY, value);
38
+ return this;
39
+ }
40
+ /** Set the agent ID baggage value. */
41
+ agentId(value) {
42
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, value);
43
+ return this;
44
+ }
45
+ /** Set the agent AUID baggage value. */
46
+ agentAuid(value) {
47
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY, value);
48
+ return this;
49
+ }
50
+ /** Set the agent email baggage value. */
51
+ agentEmail(value) {
52
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_EMAIL_KEY, value);
53
+ return this;
54
+ }
55
+ /** Set the agent blueprint ID baggage value. */
56
+ agentBlueprintId(value) {
57
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_BLUEPRINT_ID_KEY, value);
58
+ return this;
59
+ }
60
+ /** Set the session ID baggage value. */
61
+ sessionId(value) {
62
+ this.set(OpenTelemetryConstants.SESSION_ID_KEY, value);
63
+ return this;
64
+ }
65
+ /** Set the user ID baggage value. */
66
+ userId(value) {
67
+ this.set(OpenTelemetryConstants.USER_ID_KEY, value);
68
+ return this;
69
+ }
70
+ /** Set the agent name baggage value. */
71
+ agentName(value) {
72
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, value);
73
+ return this;
74
+ }
75
+ /** Set the agent description baggage value. */
76
+ agentDescription(value) {
77
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, value);
78
+ return this;
79
+ }
80
+ /** Set the agent platform ID baggage value. */
81
+ agentPlatformId(value) {
82
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_PLATFORM_ID_KEY, value);
83
+ return this;
84
+ }
85
+ /** Set the agent version baggage value. */
86
+ agentVersion(value) {
87
+ this.set(OpenTelemetryConstants.GEN_AI_AGENT_VERSION_KEY, value);
88
+ return this;
89
+ }
90
+ /** Set the session description baggage value. */
91
+ sessionDescription(value) {
92
+ this.set(OpenTelemetryConstants.SESSION_DESCRIPTION_KEY, value);
93
+ return this;
94
+ }
95
+ /** Set the user name baggage value. */
96
+ userName(value) {
97
+ this.set(OpenTelemetryConstants.USER_NAME_KEY, value);
98
+ return this;
99
+ }
100
+ /** Set the user email baggage value. */
101
+ userEmail(value) {
102
+ this.set(OpenTelemetryConstants.USER_EMAIL_KEY, value);
103
+ return this;
104
+ }
105
+ /** Set the caller client IP baggage value. */
106
+ callerClientIp(value) {
107
+ this.set(OpenTelemetryConstants.GEN_AI_CALLER_CLIENT_IP_KEY, value);
108
+ return this;
109
+ }
110
+ /** Set the caller agent platform ID baggage value. */
111
+ callerAgentPlatformId(value) {
112
+ this.set(OpenTelemetryConstants.GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY, value);
113
+ return this;
114
+ }
115
+ /** Set the conversation ID baggage value. */
116
+ conversationId(value) {
117
+ this.set(OpenTelemetryConstants.GEN_AI_CONVERSATION_ID_KEY, value);
118
+ return this;
119
+ }
120
+ /** Set the conversation item link baggage value. */
121
+ conversationItemLink(value) {
122
+ this.set(OpenTelemetryConstants.GEN_AI_CONVERSATION_ITEM_LINK_KEY, value);
123
+ return this;
124
+ }
125
+ /** Set the channel name (e.g., Teams, Slack). */
126
+ channelName(value) {
127
+ this.set(OpenTelemetryConstants.CHANNEL_NAME_KEY, value);
128
+ return this;
129
+ }
130
+ /** Set the channel link/URL. */
131
+ channelLink(value) {
132
+ this.set(OpenTelemetryConstants.CHANNEL_LINK_KEY, value);
133
+ return this;
134
+ }
135
+ /**
136
+ * Sets the invoke agent server address and port baggage values.
137
+ * @param address The server address (hostname) of the target agent service.
138
+ * @param port Optional server port. Only recorded when different from 443.
139
+ */
140
+ invokeAgentServer(address, port) {
141
+ this.set(OpenTelemetryConstants.SERVER_ADDRESS_KEY, address);
142
+ if (port !== undefined && port !== 443) {
143
+ this.set(OpenTelemetryConstants.SERVER_PORT_KEY, port.toString());
144
+ }
145
+ else {
146
+ this.pairs.delete(OpenTelemetryConstants.SERVER_PORT_KEY);
147
+ }
148
+ return this;
149
+ }
150
+ /**
151
+ * Set multiple baggage pairs from a dictionary or iterable.
152
+ * @param pairs Dictionary or iterable of key-value pairs
153
+ */
154
+ setPairs(pairs) {
155
+ if (!pairs) {
156
+ return this;
157
+ }
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
+ let entries;
160
+ if (Symbol.iterator in Object(pairs)) {
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
+ entries = pairs;
163
+ }
164
+ else {
165
+ entries = Object.entries(pairs);
166
+ }
167
+ for (const [key, value] of entries) {
168
+ if (value !== null && value !== undefined) {
169
+ this.set(key, String(value));
170
+ }
171
+ }
172
+ return this;
173
+ }
174
+ /**
175
+ * Apply the collected baggage to the current context.
176
+ * @returns A BaggageScope that can run callbacks under the baggage context
177
+ */
178
+ build() {
179
+ return new BaggageScope(this.pairs);
180
+ }
181
+ /**
182
+ * Add a baggage key/value if the value is not null or whitespace.
183
+ */
184
+ set(key, value) {
185
+ if (value !== null && value !== undefined) {
186
+ const trimmed = value.trim();
187
+ if (trimmed) {
188
+ this.pairs.set(key, trimmed);
189
+ }
190
+ }
191
+ }
192
+ /**
193
+ * Convenience method to begin a request baggage scope with common fields.
194
+ * @param tenantId The tenant ID
195
+ * @param agentId The agent ID
196
+ * @returns A BaggageScope with tenant and agent ID set
197
+ */
198
+ static setRequestContext(tenantId, agentId) {
199
+ return new BaggageBuilder().tenantId(tenantId).agentId(agentId).build();
200
+ }
201
+ }
202
+ /**
203
+ * Context manager for baggage scope.
204
+ *
205
+ * Manages the lifecycle of baggage values, setting them in the OTel context
206
+ * and restoring the previous context when the scope ends.
207
+ */
208
+ export class BaggageScope {
209
+ /** @internal Exposed for testing. */
210
+ contextWithBaggage;
211
+ constructor(pairs) {
212
+ // 1. Start from current active context
213
+ const currentCtx = otelContext.active();
214
+ // 2. Build merged baggage
215
+ let bag = propagation.getBaggage(currentCtx) ?? propagation.createBaggage({});
216
+ for (const [key, value] of pairs.entries()) {
217
+ if (value && value.trim()) {
218
+ bag = bag.setEntry(key, { value });
219
+ }
220
+ }
221
+ // 3. Create a new context that carries that baggage
222
+ this.contextWithBaggage = propagation.setBaggage(currentCtx, bag);
223
+ }
224
+ /**
225
+ * Execute a synchronous function under this baggage scope.
226
+ * Automatically restores previous context afterward.
227
+ */
228
+ run(fn) {
229
+ return otelContext.with(this.contextWithBaggage, fn);
230
+ }
231
+ /**
232
+ * Dispose is a no-op because OpenTelemetry JS automatically restores
233
+ * the previous context after `context.with()` completes.
234
+ */
235
+ [Symbol.dispose]() {
236
+ // Nothing to detach manually; context restoration happens automatically.
237
+ }
238
+ /** Manual cleanup alternative if caller isn't using `using`. */
239
+ dispose() {
240
+ this[Symbol.dispose]();
241
+ }
242
+ }
243
+ //# sourceMappingURL=BaggageBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaggageBuilder.js","sourceRoot":"","sources":["../../../../src/a365/middleware/BaggageBuilder.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAc;IACjB,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAE/C,+DAA+D;IAC/D,eAAe,CAAC,KAAgC;QAC9C,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uCAAuC;IACvC,QAAQ,CAAC,KAAgC;QACvC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sCA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,CAAC;YAC3C,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC1B,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,oDAAoD;QACpD,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC;IAED;;;OAGG;IACH,GAAG,CAAI,EAAW;QAChB,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,yEAAyE;IAC3E,CAAC;IAED,gEAAgE;IAChE,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export { BaggageBuilder, BaggageScope } from "./BaggageBuilder.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/a365/middleware/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export { BaggageBuilder, BaggageScope } from "./BaggageBuilder.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/a365/middleware/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Span processor that propagates baggage key/value pairs to span attributes.
3
+ *
4
+ * This processor copies baggage entries onto spans based on the operation type.
5
+ * For `invoke_agent` operations, it applies both generic and invoke-agent-specific attributes.
6
+ * For other operations, it applies only generic attributes.
7
+ *
8
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/processors/SpanProcessor.ts
9
+ */
10
+ import type { Context, Span } from "@opentelemetry/api";
11
+ import type { SpanProcessor as BaseSpanProcessor, ReadableSpan } from "@opentelemetry/sdk-trace-base";
12
+ /**
13
+ * Copies relevant baggage entries to span attributes on span start.
14
+ *
15
+ * This is the "automatic" counterpart to the manual scope API — it ensures
16
+ * every span in the pipeline gets agent identity attributes from baggage
17
+ * without explicitly creating scopes.
18
+ */
19
+ export declare class A365SpanProcessor implements BaseSpanProcessor {
20
+ /**
21
+ * Called when a span is started.
22
+ * Copies relevant baggage entries to span attributes.
23
+ */
24
+ onStart(span: Span, parentContext?: Context): void;
25
+ /** Called when a span is ended. */
26
+ onEnd(_span: ReadableSpan): void;
27
+ /** Shutdown the processor. */
28
+ shutdown(): Promise<void>;
29
+ /** Force flush the processor. */
30
+ forceFlush(): Promise<void>;
31
+ }
32
+ //# sourceMappingURL=A365SpanProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A365SpanProcessor.d.ts","sourceRoot":"","sources":["../../../../src/a365/processors/A365SpanProcessor.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EACV,aAAa,IAAI,iBAAiB,EAClC,YAAY,EACb,MAAM,+BAA+B,CAAC;AAIvC;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,iBAAiB;IACzD;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI;IAyFlD,mCAAmC;IACnC,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAIhC,8BAA8B;IACxB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,iCAAiC;IAC3B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}