@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,116 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { MICROSOFT_OPENTELEMETRY_VERSION } from "../types.js";
4
+ /**
5
+ * OpenTelemetry constants for A365 observability.
6
+ *
7
+ * Attribute keys follow OTel gen-ai semantic conventions plus
8
+ * Microsoft-specific extensions under the `microsoft.*` namespace.
9
+ *
10
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/constants.ts
11
+ */
12
+ export class OpenTelemetryConstants {
13
+ // ── Span operation names ──────────────────────────────────────────
14
+ static INVOKE_AGENT_OPERATION_NAME = "invoke_agent";
15
+ static EXECUTE_TOOL_OPERATION_NAME = "execute_tool";
16
+ static OUTPUT_MESSAGES_OPERATION_NAME = "output_messages";
17
+ static CHAT_OPERATION_NAME = "chat";
18
+ // ── Standard OTel semantic conventions ────────────────────────────
19
+ static ERROR_TYPE_KEY = "error.type";
20
+ static ERROR_TYPE_CANCELLED = "TaskCanceledException";
21
+ static ERROR_MESSAGE_KEY = "error.message";
22
+ static AZ_NAMESPACE_KEY = "az.namespace";
23
+ static SERVER_ADDRESS_KEY = "server.address";
24
+ static SERVER_PORT_KEY = "server.port";
25
+ static AZURE_RP_NAMESPACE_VALUE = "Microsoft.CognitiveServices";
26
+ // ── Source / SDK identity ─────────────────────────────────────────
27
+ static SOURCE_NAME = "Agent365Sdk";
28
+ // ── Feature flags / env var names ─────────────────────────────────
29
+ static ENABLE_OPENTELEMETRY_SWITCH = "Azure.Experimental.EnableActivitySource";
30
+ static TRACE_CONTENTS_SWITCH = "Azure.Experimental.TraceGenAIMessageContent";
31
+ static TRACE_CONTENTS_ENVIRONMENT_VARIABLE = "AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED";
32
+ static ENABLE_OBSERVABILITY = "ENABLE_OBSERVABILITY";
33
+ static ENABLE_A365_OBSERVABILITY_EXPORTER = "ENABLE_A365_OBSERVABILITY_EXPORTER";
34
+ static ENABLE_A365_OBSERVABILITY = "ENABLE_A365_OBSERVABILITY";
35
+ static ENABLE_A365_OBSERVABILITY_PER_REQUEST_EXPORT = "ENABLE_A365_OBSERVABILITY_PER_REQUEST_EXPORT";
36
+ // ── GenAI core attributes ────────────────────────────────────────
37
+ static GEN_AI_OPERATION_NAME_KEY = "gen_ai.operation.name";
38
+ static GEN_AI_REQUEST_MODEL_KEY = "gen_ai.request.model";
39
+ static GEN_AI_RESPONSE_MODEL_KEY = "gen_ai.response.model";
40
+ static GEN_AI_RESPONSE_FINISH_REASONS_KEY = "gen_ai.response.finish_reasons";
41
+ static GEN_AI_PROVIDER_NAME_KEY = "gen_ai.provider.name";
42
+ static GEN_AI_REQUEST_MAX_TOKENS_KEY = "gen_ai.request.max_tokens";
43
+ static GEN_AI_REQUEST_TEMPERATURE_KEY = "gen_ai.request.temperature";
44
+ static GEN_AI_REQUEST_TOP_P_KEY = "gen_ai.request.top_p";
45
+ static GEN_AI_CHOICE = "gen_ai.choice";
46
+ // ── GenAI metrics ────────────────────────────────────────────────
47
+ static GEN_AI_CLIENT_OPERATION_DURATION_METRIC_NAME = "gen_ai.client.operation.duration";
48
+ static GEN_AI_CLIENT_TOKEN_USAGE_METRIC_NAME = "gen_ai.client.token.usage";
49
+ // ── GenAI usage ──────────────────────────────────────────────────
50
+ static GEN_AI_USAGE_INPUT_TOKENS_KEY = "gen_ai.usage.input_tokens";
51
+ static GEN_AI_USAGE_OUTPUT_TOKENS_KEY = "gen_ai.usage.output_tokens";
52
+ // ── GenAI message attributes ─────────────────────────────────────
53
+ static GEN_AI_SYSTEM_INSTRUCTIONS_KEY = "gen_ai.system_instructions";
54
+ static GEN_AI_INPUT_MESSAGES_KEY = "gen_ai.input.messages";
55
+ static GEN_AI_OUTPUT_MESSAGES_KEY = "gen_ai.output.messages";
56
+ static A365_MESSAGES_SCHEMA_VERSION_KEY = "microsoft.a365.messages.schema_version";
57
+ // ── GenAI agent attributes ───────────────────────────────────────
58
+ static GEN_AI_AGENT_ID_KEY = "gen_ai.agent.id";
59
+ static GEN_AI_AGENT_NAME_KEY = "gen_ai.agent.name";
60
+ static GEN_AI_AGENT_DESCRIPTION_KEY = "gen_ai.agent.description";
61
+ static GEN_AI_AGENT_VERSION_KEY = "gen_ai.agent.version";
62
+ static GEN_AI_AGENT_PLATFORM_ID_KEY = "microsoft.a365.agent.platform.id";
63
+ static GEN_AI_AGENT_THOUGHT_PROCESS_KEY = "microsoft.a365.agent.thought.process";
64
+ static GEN_AI_ICON_URI_KEY = "gen_ai.agent365.icon_uri";
65
+ static AGENT_ID_KEY = "gen_ai.agent.id";
66
+ // ── GenAI conversation / session ─────────────────────────────────
67
+ static GEN_AI_CONVERSATION_ID_KEY = "gen_ai.conversation.id";
68
+ static GEN_AI_CONVERSATION_ITEM_LINK_KEY = "microsoft.conversation.item.link";
69
+ static SESSION_ID_KEY = "microsoft.session.id";
70
+ static SESSION_DESCRIPTION_KEY = "microsoft.session.description";
71
+ // ── GenAI tool attributes ────────────────────────────────────────
72
+ static GEN_AI_TOOL_CALL_ID_KEY = "gen_ai.tool.call.id";
73
+ static GEN_AI_TOOL_NAME_KEY = "gen_ai.tool.name";
74
+ static GEN_AI_TOOL_DESCRIPTION_KEY = "gen_ai.tool.description";
75
+ static GEN_AI_TOOL_ARGS_KEY = "gen_ai.tool.call.arguments";
76
+ static GEN_AI_TOOL_CALL_RESULT_KEY = "gen_ai.tool.call.result";
77
+ static GEN_AI_TOOL_TYPE_KEY = "gen_ai.tool.type";
78
+ // ── Tenant ───────────────────────────────────────────────────────
79
+ static TENANT_ID_KEY = "microsoft.tenant.id";
80
+ // ── Human caller dimensions (OTel user.* namespace) ──────────────
81
+ static USER_ID_KEY = "user.id";
82
+ static USER_NAME_KEY = "user.name";
83
+ static USER_EMAIL_KEY = "user.email";
84
+ static GEN_AI_CALLER_CLIENT_IP_KEY = "client.address";
85
+ // ── Agent-to-Agent caller dimensions ─────────────────────────────
86
+ static GEN_AI_CALLER_AGENT_USER_ID_KEY = "microsoft.a365.caller.agent.user.id";
87
+ static GEN_AI_CALLER_AGENT_EMAIL_KEY = "microsoft.a365.caller.agent.user.email";
88
+ static GEN_AI_CALLER_AGENT_NAME_KEY = "microsoft.a365.caller.agent.name";
89
+ static GEN_AI_CALLER_AGENT_ID_KEY = "microsoft.a365.caller.agent.id";
90
+ static GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY = "microsoft.a365.caller.agent.blueprint.id";
91
+ static GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY = "microsoft.a365.caller.agent.platform.id";
92
+ static GEN_AI_CALLER_AGENT_VERSION_KEY = "microsoft.a365.caller.agent.version";
93
+ // ── Baggage keys ─────────────────────────────────────────────────
94
+ static GEN_AI_AGENT_AUID_KEY = "microsoft.agent.user.id";
95
+ static GEN_AI_AGENT_EMAIL_KEY = "microsoft.agent.user.email";
96
+ static GEN_AI_AGENT_BLUEPRINT_ID_KEY = "microsoft.a365.agent.blueprint.id";
97
+ // ── Execution context ────────────────────────────────────────────
98
+ static GEN_AI_TASK_ID_KEY = "gen_ai.task.id";
99
+ static GEN_AI_EXECUTION_PAYLOAD_KEY = "gen_ai.execution.payload";
100
+ // ── Channel dimensions ───────────────────────────────────────────
101
+ static CHANNEL_NAME_KEY = "microsoft.channel.name";
102
+ static CHANNEL_LINK_KEY = "microsoft.channel.link";
103
+ // ── Custom parent / span name ────────────────────────────────────
104
+ static CUSTOM_PARENT_SPAN_ID_KEY = "custom.parent.span.id";
105
+ static CUSTOM_SPAN_NAME_KEY = "custom.span.name";
106
+ // ── Service attributes ───────────────────────────────────────────
107
+ static SERVICE_NAME_KEY = "service.name";
108
+ // ── Telemetry SDK attributes ─────────────────────────────────────
109
+ static TELEMETRY_SDK_NAME_KEY = "telemetry.sdk.name";
110
+ static TELEMETRY_SDK_LANGUAGE_KEY = "telemetry.sdk.language";
111
+ static TELEMETRY_SDK_VERSION_KEY = "telemetry.sdk.version";
112
+ static TELEMETRY_SDK_NAME_VALUE = "A365ObservabilitySDK";
113
+ static TELEMETRY_SDK_LANGUAGE_VALUE = "nodejs";
114
+ static TELEMETRY_SDK_VERSION_VALUE = MICROSOFT_OPENTELEMETRY_VERSION;
115
+ }
116
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/a365/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,OAAO,sBAAsB;IACjC,qEAAqE;IAC9D,MAAM,CAAU,2BAA2B,GAAG,cAAc,CAAC;IAC7D,MAAM,CAAU,2BAA2B,GAAG,cAAc,CAAC;IAC7D,MAAM,CAAU,8BAA8B,GAAG,iBAAiB,CAAC;IACnE,MAAM,CAAU,mBAAmB,GAAG,MAAM,CAAC;IAEpD,qEAAqE;IAC9D,MAAM,CAAU,cAAc,GAAG,YAAY,CAAC;IAC9C,MAAM,CAAU,oBAAoB,GAAG,uBAAuB,CAAC;IAC/D,MAAM,CAAU,iBAAiB,GAAG,eAAe,CAAC;IACpD,MAAM,CAAU,gBAAgB,GAAG,cAAc,CAAC;IAClD,MAAM,CAAU,kBAAkB,GAAG,gBAAgB,CAAC;IACtD,MAAM,CAAU,eA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,0 +1,25 @@
1
+ import type { Context } from "@opentelemetry/api";
2
+ /**
3
+ * Run a function within a Context that carries the per-request export token.
4
+ * This keeps the token only in OTel Context (ALS), never in any registry.
5
+ *
6
+ * The token can be updated later via `updateExportToken()` before the trace
7
+ * is flushed — useful when the callback is long-running and the original
8
+ * token may expire before export.
9
+ */
10
+ export declare function runWithExportToken<T>(token: string, fn: () => T): T;
11
+ /**
12
+ * Update the export token in the active OTel Context.
13
+ * Call this to refresh the token before ending the root span when the
14
+ * original token may have expired during a long-running request.
15
+ *
16
+ * Must be called within the same async context created by `runWithExportToken`.
17
+ * @param token The fresh token to use for export.
18
+ * @returns true if the token was updated successfully, false if no token holder was found.
19
+ */
20
+ export declare function updateExportToken(token: string): boolean;
21
+ /**
22
+ * Retrieve the per-request export token from a given OTel Context (or the active one).
23
+ */
24
+ export declare function getExportToken(ctx?: Context): string | undefined;
25
+ //# sourceMappingURL=tokenContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenContext.d.ts","sourceRoot":"","sources":["../../../../src/a365/context/tokenContext.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAclD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAKnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,OAA0B,GAAG,MAAM,GAAG,SAAS,CAUlF"}
@@ -0,0 +1,62 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Per-request export token context propagation.
5
+ *
6
+ * Uses OpenTelemetry Context (backed by AsyncLocalStorage) to carry and
7
+ * refresh a per-request bearer token that the PerRequestSpanProcessor
8
+ * restores at export time.
9
+ *
10
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/context/token-context.ts
11
+ */
12
+ import { context, createContextKey } from "@opentelemetry/api";
13
+ import { Logger } from "../../shared/logging/index.js";
14
+ const EXPORT_TOKEN_KEY = createContextKey("a365_export_token");
15
+ /**
16
+ * Run a function within a Context that carries the per-request export token.
17
+ * This keeps the token only in OTel Context (ALS), never in any registry.
18
+ *
19
+ * The token can be updated later via `updateExportToken()` before the trace
20
+ * is flushed — useful when the callback is long-running and the original
21
+ * token may expire before export.
22
+ */
23
+ export function runWithExportToken(token, fn) {
24
+ const holder = { token };
25
+ const ctxWithToken = context.active().setValue(EXPORT_TOKEN_KEY, holder);
26
+ Logger.getInstance().info("[TokenContext] Running function with export token in context.");
27
+ return context.with(ctxWithToken, fn);
28
+ }
29
+ /**
30
+ * Update the export token in the active OTel Context.
31
+ * Call this to refresh the token before ending the root span when the
32
+ * original token may have expired during a long-running request.
33
+ *
34
+ * Must be called within the same async context created by `runWithExportToken`.
35
+ * @param token The fresh token to use for export.
36
+ * @returns true if the token was updated successfully, false if no token holder was found.
37
+ */
38
+ export function updateExportToken(token) {
39
+ const value = context.active().getValue(EXPORT_TOKEN_KEY);
40
+ if (value && typeof value === "object" && "token" in value) {
41
+ value.token = token;
42
+ Logger.getInstance().info("[TokenContext] Export token updated in context.");
43
+ return true;
44
+ }
45
+ Logger.getInstance().warn("[TokenContext] updateExportToken called but no token holder found in active context. Was runWithExportToken called?");
46
+ return false;
47
+ }
48
+ /**
49
+ * Retrieve the per-request export token from a given OTel Context (or the active one).
50
+ */
51
+ export function getExportToken(ctx = context.active()) {
52
+ const value = ctx.getValue(EXPORT_TOKEN_KEY);
53
+ if (value && typeof value === "object" && "token" in value) {
54
+ return value.token;
55
+ }
56
+ // Backward compat: support raw string values from older callers
57
+ if (typeof value === "string") {
58
+ return value;
59
+ }
60
+ return undefined;
61
+ }
62
+ //# sourceMappingURL=tokenContext.js.map
@@ -0,0 +1 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E;IAC5D,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;QAC3D,OAAQ,KAAqB,CAAC,KAAK,CAAC;IACtC,CAAC;IACD,gEAAgE;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { Context } from "@opentelemetry/api";
2
+ import type { ParentSpanRef } from "./contracts.js";
3
+ /** Type guard to distinguish a ParentSpanRef from an OTel Context. */
4
+ export declare function isParentSpanRef(value: unknown): value is ParentSpanRef;
5
+ /**
6
+ * Creates a new Context with an explicit parent span reference.
7
+ * This allows child spans to be correctly parented even when async context is broken.
8
+ */
9
+ export declare function createContextWithParentSpanRef(base: Context, parent: ParentSpanRef): Context;
10
+ /**
11
+ * Runs a callback within a context that has an explicit parent span reference.
12
+ */
13
+ export declare function runWithParentSpanRef<T>(parent: ParentSpanRef, callback: () => T): T;
14
+ /** Carrier type for HTTP headers. */
15
+ export type HeadersCarrier = Record<string, string | string[] | undefined>;
16
+ /**
17
+ * Injects the current trace context (`traceparent`/`tracestate` headers) into
18
+ * the provided headers object using the globally registered W3C propagator.
19
+ */
20
+ export declare function injectContextToHeaders(headers: Record<string, string>, ctx?: Context): Record<string, string>;
21
+ /**
22
+ * Extracts trace context from incoming HTTP headers using the globally
23
+ * registered W3C propagator.
24
+ */
25
+ export declare function extractContextFromHeaders(headers: HeadersCarrier, baseCtx?: Context): Context;
26
+ /**
27
+ * Extracts trace context from incoming HTTP headers and runs the callback
28
+ * within that context.
29
+ */
30
+ export declare function runWithExtractedTraceContext<T>(headers: HeadersCarrier, callback: () => T): T;
31
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/a365/context.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAmBpD,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAmBtE;AAMD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CA0B5F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAGnF;AAMD,qCAAqC;AACrC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,GAAG,CAAC,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGxB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAE7F;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAE7F"}
@@ -0,0 +1,101 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Context propagation utilities for A365 observability.
5
+ *
6
+ * Provides:
7
+ * - `ParentSpanRef` for explicit parent-child linking across async boundaries
8
+ * - `createContextWithParentSpanRef` / `runWithParentSpanRef` helpers
9
+ * - `isParentSpanRef` type guard
10
+ * - W3C traceparent inject/extract helpers
11
+ *
12
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/context/
13
+ */
14
+ import { context, trace, propagation } from "@opentelemetry/api";
15
+ import { TraceFlags } from "@opentelemetry/api";
16
+ import { Logger } from "../shared/logging/index.js";
17
+ // ---------------------------------------------------------------------------
18
+ // Validation helpers
19
+ // ---------------------------------------------------------------------------
20
+ function isValidTraceId(traceId) {
21
+ return /^[0-9a-f]{32}$/i.test(traceId) && traceId !== "00000000000000000000000000000000";
22
+ }
23
+ function isValidSpanId(spanId) {
24
+ return /^[0-9a-f]{16}$/i.test(spanId) && spanId !== "0000000000000000";
25
+ }
26
+ // ---------------------------------------------------------------------------
27
+ // Type guard
28
+ // ---------------------------------------------------------------------------
29
+ /** Type guard to distinguish a ParentSpanRef from an OTel Context. */
30
+ export function isParentSpanRef(value) {
31
+ if (typeof value !== "object" || value === null)
32
+ return false;
33
+ const maybeCtx = value;
34
+ if (typeof maybeCtx.getValue === "function" &&
35
+ typeof maybeCtx.setValue === "function" &&
36
+ typeof maybeCtx.deleteValue === "function") {
37
+ return false;
38
+ }
39
+ const maybeRef = value;
40
+ return ("traceId" in maybeRef &&
41
+ typeof maybeRef.traceId === "string" &&
42
+ "spanId" in maybeRef &&
43
+ typeof maybeRef.spanId === "string");
44
+ }
45
+ // ---------------------------------------------------------------------------
46
+ // Parent span context
47
+ // ---------------------------------------------------------------------------
48
+ /**
49
+ * Creates a new Context with an explicit parent span reference.
50
+ * This allows child spans to be correctly parented even when async context is broken.
51
+ */
52
+ export function createContextWithParentSpanRef(base, parent) {
53
+ const logger = Logger.getInstance();
54
+ if (!isValidTraceId(parent.traceId) || !isValidSpanId(parent.spanId)) {
55
+ logger.warn(`[A365] Invalid parent span reference; returning base context. traceId=${parent.traceId}, spanId=${parent.spanId}`);
56
+ return base;
57
+ }
58
+ const activeCtx = trace.getSpan(base)?.spanContext();
59
+ const traceFlags = parent.traceFlags ??
60
+ (activeCtx?.traceId === parent.traceId ? activeCtx.traceFlags : undefined) ??
61
+ TraceFlags.SAMPLED;
62
+ const parentSpanContext = {
63
+ traceId: parent.traceId,
64
+ spanId: parent.spanId,
65
+ traceFlags,
66
+ traceState: parent.traceState,
67
+ isRemote: parent.isRemote ?? true,
68
+ };
69
+ const parentSpan = trace.wrapSpanContext(parentSpanContext);
70
+ return trace.setSpan(base, parentSpan);
71
+ }
72
+ /**
73
+ * Runs a callback within a context that has an explicit parent span reference.
74
+ */
75
+ export function runWithParentSpanRef(parent, callback) {
76
+ const contextWithParent = createContextWithParentSpanRef(context.active(), parent);
77
+ return context.with(contextWithParent, callback);
78
+ }
79
+ /**
80
+ * Injects the current trace context (`traceparent`/`tracestate` headers) into
81
+ * the provided headers object using the globally registered W3C propagator.
82
+ */
83
+ export function injectContextToHeaders(headers, ctx) {
84
+ propagation.inject(ctx ?? context.active(), headers);
85
+ return headers;
86
+ }
87
+ /**
88
+ * Extracts trace context from incoming HTTP headers using the globally
89
+ * registered W3C propagator.
90
+ */
91
+ export function extractContextFromHeaders(headers, baseCtx) {
92
+ return propagation.extract(baseCtx ?? context.active(), headers);
93
+ }
94
+ /**
95
+ * Extracts trace context from incoming HTTP headers and runs the callback
96
+ * within that context.
97
+ */
98
+ export function runWithExtractedTraceContext(headers, callback) {
99
+ return context.with(extractContextFromHeaders(headers), callback);
100
+ }
101
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/a365/context.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,8EAA8E;AAC9E,qBAAqB;AACr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AO,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAI,OAAuB,EAAE,QAAiB;IACxF,OAAO,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,250 @@
1
+ /**
2
+ * A365 observability contracts — types for scopes, messages, and telemetry details.
3
+ *
4
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/contracts.ts
5
+ * following OTel gen-ai semantic conventions.
6
+ */
7
+ import type { SpanKind, TimeInput, Link, Context, TraceState } from "@opentelemetry/api";
8
+ export declare const A365_MESSAGE_SCHEMA_VERSION: "0.1.0";
9
+ /** Role of a message participant per OTEL gen-ai semantic conventions. */
10
+ export declare enum MessageRole {
11
+ SYSTEM = "system",
12
+ USER = "user",
13
+ ASSISTANT = "assistant",
14
+ TOOL = "tool"
15
+ }
16
+ /** Reason a model stopped generating per OTEL gen-ai semantic conventions. */
17
+ export declare enum FinishReason {
18
+ STOP = "stop",
19
+ LENGTH = "length",
20
+ CONTENT_FILTER = "content_filter",
21
+ TOOL_CALL = "tool_call",
22
+ ERROR = "error"
23
+ }
24
+ /** Media modality for blob, file, and URI parts. */
25
+ export declare enum Modality {
26
+ IMAGE = "image",
27
+ VIDEO = "video",
28
+ AUDIO = "audio"
29
+ }
30
+ /** Represents different roles that can invoke an agent. */
31
+ export declare enum InvocationRole {
32
+ Human = "Human",
33
+ Agent = "Agent",
34
+ Event = "Event",
35
+ Unknown = "Unknown"
36
+ }
37
+ /** Represents different operation types for model inference. */
38
+ export declare enum InferenceOperationType {
39
+ CHAT = "Chat",
40
+ TEXT_COMPLETION = "TextCompletion",
41
+ GENERATE_CONTENT = "GenerateContent"
42
+ }
43
+ /** Plain text content. */
44
+ export interface TextPart {
45
+ type: "text";
46
+ content: string;
47
+ }
48
+ /** A tool call requested by the model. */
49
+ export interface ToolCallRequestPart {
50
+ type: "tool_call";
51
+ name: string;
52
+ id?: string;
53
+ arguments?: Record<string, unknown> | unknown[];
54
+ }
55
+ /** Result of a tool call. */
56
+ export interface ToolCallResponsePart {
57
+ type: "tool_call_response";
58
+ id?: string;
59
+ response?: unknown;
60
+ }
61
+ /** Model reasoning / chain-of-thought content. */
62
+ export interface ReasoningPart {
63
+ type: "reasoning";
64
+ content: string;
65
+ }
66
+ /** Inline binary data (base64-encoded). */
67
+ export interface BlobPart {
68
+ type: "blob";
69
+ modality: Modality | string;
70
+ mime_type?: string;
71
+ content: string;
72
+ }
73
+ /** Reference to a pre-uploaded file. */
74
+ export interface FilePart {
75
+ type: "file";
76
+ modality: Modality | string;
77
+ mime_type?: string;
78
+ file_id: string;
79
+ }
80
+ /** External URI reference. */
81
+ export interface UriPart {
82
+ type: "uri";
83
+ modality: Modality | string;
84
+ mime_type?: string;
85
+ uri: string;
86
+ }
87
+ /** Extensible server tool call details. */
88
+ export interface GenericServerToolCall {
89
+ type: string;
90
+ [key: string]: unknown;
91
+ }
92
+ /** Extensible server tool call response. */
93
+ export interface GenericServerToolCallResponse {
94
+ type: string;
95
+ [key: string]: unknown;
96
+ }
97
+ /** Server-side tool invocation. */
98
+ export interface ServerToolCallPart {
99
+ type: "server_tool_call";
100
+ name: string;
101
+ id?: string;
102
+ server_tool_call: GenericServerToolCall;
103
+ }
104
+ /** Server-side tool response. */
105
+ export interface ServerToolCallResponsePart {
106
+ type: "server_tool_call_response";
107
+ id?: string;
108
+ server_tool_call_response: GenericServerToolCallResponse;
109
+ }
110
+ /** Extensible part for custom / future types. */
111
+ export interface GenericPart {
112
+ type: string;
113
+ [key: string]: unknown;
114
+ }
115
+ /** Union of all message part types per OTEL gen-ai semantic conventions. */
116
+ export type MessagePart = TextPart | ToolCallRequestPart | ToolCallResponsePart | ReasoningPart | BlobPart | FilePart | UriPart | ServerToolCallPart | ServerToolCallResponsePart | GenericPart;
117
+ /** An input message sent to a model (OTEL gen-ai semantic conventions). */
118
+ export interface ChatMessage {
119
+ role: MessageRole | string;
120
+ parts: MessagePart[];
121
+ name?: string;
122
+ }
123
+ /** Versioned wrapper for input messages. */
124
+ export interface InputMessages {
125
+ version: typeof A365_MESSAGE_SCHEMA_VERSION;
126
+ messages: ChatMessage[];
127
+ }
128
+ /** An output message produced by a model (OTEL gen-ai semantic conventions). */
129
+ export interface OutputMessage extends ChatMessage {
130
+ finish_reason?: FinishReason | string;
131
+ }
132
+ /** Versioned wrapper for output messages. */
133
+ export interface OutputMessages {
134
+ version: typeof A365_MESSAGE_SCHEMA_VERSION;
135
+ messages: OutputMessage[];
136
+ }
137
+ /** Accepted input for `recordInputMessages`. */
138
+ export type InputMessagesParam = string | string[] | InputMessages;
139
+ /** Accepted input for `recordOutputMessages`. */
140
+ export type OutputMessagesParam = string | string[] | OutputMessages;
141
+ /** Accepted input for `OutputResponse.messages`. */
142
+ export type ResponseMessagesParam = OutputMessagesParam | Record<string, unknown>;
143
+ /** Represents a channel for an invocation. */
144
+ export interface Channel {
145
+ id?: string;
146
+ name?: string;
147
+ iconUri?: string;
148
+ role?: InvocationRole;
149
+ description?: string;
150
+ }
151
+ /** Represents a request with telemetry context. */
152
+ export interface Request {
153
+ content?: InputMessagesParam;
154
+ sessionId?: string;
155
+ channel?: Channel;
156
+ conversationId?: string;
157
+ }
158
+ /** Details about an AI agent. */
159
+ export interface AgentDetails {
160
+ agentId: string;
161
+ agentName?: string;
162
+ agentDescription?: string;
163
+ iconUri?: string;
164
+ platformId?: string;
165
+ agentAUID?: string;
166
+ agentEmail?: string;
167
+ agentBlueprintId?: string;
168
+ tenantId?: string;
169
+ providerName?: string;
170
+ agentVersion?: string;
171
+ }
172
+ /** Details about the human user caller. */
173
+ export interface UserDetails {
174
+ userId?: string;
175
+ userEmail?: string;
176
+ userName?: string;
177
+ tenantId?: string;
178
+ callerClientIp?: string;
179
+ }
180
+ /**
181
+ * Caller details for scope creation.
182
+ * Supports human callers, agent callers, or both (A2A with a human in the chain).
183
+ */
184
+ export interface CallerDetails {
185
+ userDetails?: UserDetails;
186
+ callerAgentDetails?: AgentDetails;
187
+ }
188
+ /** Represents an endpoint for agent invocation. */
189
+ export interface ServiceEndpoint {
190
+ host: string;
191
+ port?: number;
192
+ protocol?: string;
193
+ }
194
+ /** Details for invoking agent scope. */
195
+ export interface InvokeAgentScopeDetails {
196
+ endpoint?: ServiceEndpoint;
197
+ }
198
+ /** Details of a tool call made by an agent. */
199
+ export interface ToolCallDetails {
200
+ toolName: string;
201
+ arguments?: Record<string, unknown> | string;
202
+ toolCallId?: string;
203
+ description?: string;
204
+ toolType?: string;
205
+ endpoint?: ServiceEndpoint;
206
+ }
207
+ /** Details for an inference call. */
208
+ export interface InferenceDetails {
209
+ operationName: InferenceOperationType;
210
+ model: string;
211
+ providerName?: string;
212
+ inputTokens?: number;
213
+ outputTokens?: number;
214
+ finishReasons?: string[];
215
+ thoughtProcess?: string;
216
+ endpoint?: ServiceEndpoint;
217
+ }
218
+ /** Details for recording the response from an inference call. */
219
+ export interface InferenceResponse {
220
+ content: string;
221
+ responseId?: string;
222
+ finishReason?: string;
223
+ inputTokens?: number;
224
+ outputTokens?: number;
225
+ }
226
+ /** Represents a response containing output messages from an agent. */
227
+ export interface OutputResponse {
228
+ messages: ResponseMessagesParam;
229
+ }
230
+ /** Parent context — either an OTel Context or a manual ParentSpanRef. */
231
+ export type ParentContext = Context | ParentSpanRef;
232
+ /** Manual parent span reference for cross-async-boundary tracing. */
233
+ export interface ParentSpanRef {
234
+ traceId: string;
235
+ spanId: string;
236
+ traceFlags?: number;
237
+ traceState?: TraceState;
238
+ isRemote?: boolean;
239
+ }
240
+ /**
241
+ * Span configuration details for scope creation.
242
+ */
243
+ export interface SpanDetails {
244
+ parentContext?: ParentContext;
245
+ startTime?: TimeInput;
246
+ endTime?: TimeInput;
247
+ spanKind?: SpanKind;
248
+ spanLinks?: Link[];
249
+ }
250
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +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