@introspection-sdk/introspection-node 0.4.3 → 0.4.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 (122) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/otel/anthropic.d.ts +14 -12
  3. package/dist/otel/anthropic.d.ts.map +1 -1
  4. package/dist/otel/anthropic.js +89 -47
  5. package/dist/otel/anthropic.js.map +1 -1
  6. package/dist/otel/gemini.d.ts +15 -7
  7. package/dist/otel/gemini.d.ts.map +1 -1
  8. package/dist/otel/gemini.js +88 -37
  9. package/dist/otel/gemini.js.map +1 -1
  10. package/dist/otel/index.d.ts +5 -0
  11. package/dist/otel/index.d.ts.map +1 -1
  12. package/dist/otel/index.js +8 -0
  13. package/dist/otel/index.js.map +1 -1
  14. package/dist/otel/init.d.ts +126 -0
  15. package/dist/otel/init.d.ts.map +1 -0
  16. package/dist/otel/init.js +259 -0
  17. package/dist/otel/init.js.map +1 -0
  18. package/dist/otel/integrations/anthropic.d.ts +10 -0
  19. package/dist/otel/integrations/anthropic.d.ts.map +1 -0
  20. package/dist/otel/integrations/anthropic.js +22 -0
  21. package/dist/otel/integrations/anthropic.js.map +1 -0
  22. package/dist/otel/integrations/base.d.ts +83 -0
  23. package/dist/otel/integrations/base.d.ts.map +1 -0
  24. package/dist/otel/integrations/base.js +23 -0
  25. package/dist/otel/integrations/base.js.map +1 -0
  26. package/dist/otel/integrations/claude-agent.d.ts +13 -0
  27. package/dist/otel/integrations/claude-agent.d.ts.map +1 -0
  28. package/dist/otel/integrations/claude-agent.js +27 -0
  29. package/dist/otel/integrations/claude-agent.js.map +1 -0
  30. package/dist/otel/integrations/gemini.d.ts +11 -0
  31. package/dist/otel/integrations/gemini.d.ts.map +1 -0
  32. package/dist/otel/integrations/gemini.js +21 -0
  33. package/dist/otel/integrations/gemini.js.map +1 -0
  34. package/dist/otel/integrations/index.d.ts +39 -0
  35. package/dist/otel/integrations/index.d.ts.map +1 -0
  36. package/dist/otel/integrations/index.js +131 -0
  37. package/dist/otel/integrations/index.js.map +1 -0
  38. package/dist/otel/integrations/langchain.d.ts +16 -0
  39. package/dist/otel/integrations/langchain.d.ts.map +1 -0
  40. package/dist/otel/integrations/langchain.js +41 -0
  41. package/dist/otel/integrations/langchain.js.map +1 -0
  42. package/dist/otel/integrations/mastra.d.ts +14 -0
  43. package/dist/otel/integrations/mastra.d.ts.map +1 -0
  44. package/dist/otel/integrations/mastra.js +27 -0
  45. package/dist/otel/integrations/mastra.js.map +1 -0
  46. package/dist/otel/integrations/openai-agents.d.ts +11 -0
  47. package/dist/otel/integrations/openai-agents.d.ts.map +1 -0
  48. package/dist/otel/integrations/openai-agents.js +25 -0
  49. package/dist/otel/integrations/openai-agents.js.map +1 -0
  50. package/dist/otel/integrations/pi.d.ts +12 -0
  51. package/dist/otel/integrations/pi.d.ts.map +1 -0
  52. package/dist/otel/integrations/pi.js +20 -0
  53. package/dist/otel/integrations/pi.js.map +1 -0
  54. package/dist/otel/integrations/vercel.d.ts +15 -0
  55. package/dist/otel/integrations/vercel.d.ts.map +1 -0
  56. package/dist/otel/integrations/vercel.js +20 -0
  57. package/dist/otel/integrations/vercel.js.map +1 -0
  58. package/dist/otel/register.d.ts +8 -0
  59. package/dist/otel/register.d.ts.map +1 -0
  60. package/dist/otel/register.js +48 -0
  61. package/dist/otel/register.js.map +1 -0
  62. package/dist/otel/setup.d.ts +29 -0
  63. package/dist/otel/setup.d.ts.map +1 -1
  64. package/dist/otel/setup.js +22 -3
  65. package/dist/otel/setup.js.map +1 -1
  66. package/dist/utils.d.ts +10 -0
  67. package/dist/utils.d.ts.map +1 -1
  68. package/dist/utils.js +12 -4
  69. package/dist/utils.js.map +1 -1
  70. package/package.json +17 -5
  71. package/src/otel/anthropic.ts +128 -63
  72. package/src/otel/gemini.ts +139 -45
  73. package/src/otel/index.ts +41 -0
  74. package/src/otel/init.ts +411 -0
  75. package/src/otel/integrations/anthropic.ts +26 -0
  76. package/src/otel/integrations/base.ts +95 -0
  77. package/src/otel/integrations/claude-agent.ts +32 -0
  78. package/src/otel/integrations/gemini.ts +25 -0
  79. package/src/otel/integrations/index.ts +151 -0
  80. package/src/otel/integrations/langchain.ts +45 -0
  81. package/src/otel/integrations/mastra.ts +30 -0
  82. package/src/otel/integrations/openai-agents.ts +31 -0
  83. package/src/otel/integrations/pi.ts +24 -0
  84. package/src/otel/integrations/vercel.ts +24 -0
  85. package/src/otel/register.ts +50 -0
  86. package/src/otel/setup.ts +44 -3
  87. package/src/utils.ts +12 -5
  88. package/.turbo/turbo-check-types.log +0 -4
  89. package/.turbo/turbo-lint.log +0 -5
  90. package/dist/ai-sdk-integration.d.ts +0 -123
  91. package/dist/ai-sdk-integration.d.ts.map +0 -1
  92. package/dist/ai-sdk-integration.js +0 -475
  93. package/dist/anthropic.d.ts +0 -54
  94. package/dist/anthropic.d.ts.map +0 -1
  95. package/dist/anthropic.js +0 -375
  96. package/dist/claude-hooks.d.ts +0 -328
  97. package/dist/claude-hooks.d.ts.map +0 -1
  98. package/dist/claude-hooks.js +0 -571
  99. package/dist/claude-wrapper.d.ts +0 -93
  100. package/dist/claude-wrapper.d.ts.map +0 -1
  101. package/dist/claude-wrapper.js +0 -154
  102. package/dist/converters/ai-sdk.d.ts +0 -65
  103. package/dist/converters/ai-sdk.d.ts.map +0 -1
  104. package/dist/converters/ai-sdk.js +0 -261
  105. package/dist/converters/openclaw.d.ts +0 -16
  106. package/dist/converters/openclaw.d.ts.map +0 -1
  107. package/dist/converters/openclaw.js +0 -49
  108. package/dist/langchain-handler.d.ts +0 -103
  109. package/dist/langchain-handler.d.ts.map +0 -1
  110. package/dist/langchain-handler.js +0 -518
  111. package/dist/mastra-exporter.d.ts +0 -85
  112. package/dist/mastra-exporter.d.ts.map +0 -1
  113. package/dist/mastra-exporter.js +0 -471
  114. package/dist/span-processor.d.ts +0 -62
  115. package/dist/span-processor.d.ts.map +0 -1
  116. package/dist/span-processor.js +0 -313
  117. package/dist/tracing-processor.d.ts +0 -136
  118. package/dist/tracing-processor.d.ts.map +0 -1
  119. package/dist/tracing-processor.js +0 -368
  120. package/dist/types/genai.d.ts +0 -165
  121. package/dist/types/genai.d.ts.map +0 -1
  122. package/dist/types/genai.js +0 -82
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/otel/integrations/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,QAAQ;IACpB,SAAS,CAAC,EAAE,cAAc,EAAE;QAC1B,MAAM,YAAY,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC9C,YAAY,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QACxD,0EAA0E;QAC1E,2EAA2E;QAC3E,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;IAC3C,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Integration discovery + setup loader for `introspection.init()`.
3
+ *
4
+ * Mirrors the Python SDK's registry: built-in integrations are resolved
5
+ * lazily (a missing framework just skips its shim), `setupOnce` runs at most
6
+ * once per identifier per process, and an integration may `deactivate` others.
7
+ */
8
+ import { DidNotEnable, type Integration, type IntegrationHandles, type IntegrationSetupContext } from "./base.js";
9
+ export { DidNotEnable };
10
+ export type { Integration, IntegrationHandles, IntegrationSetupContext };
11
+ /**
12
+ * Distinguish "framework package not installed" (expected — skip quietly) from
13
+ * a real error inside an installed integration (a bug we shouldn't hide).
14
+ */
15
+ export declare function isModuleNotFound(e: unknown): boolean;
16
+ /**
17
+ * Return the built-in integrations whose framework is importable.
18
+ *
19
+ * Each module's top-level framework import determines availability: a missing
20
+ * package makes the dynamic import reject, which we log at debug and skip. Any
21
+ * OTHER failure (a real error inside an installed integration) is surfaced at
22
+ * warn level rather than silently swallowed — it's a bug, not an absent peer.
23
+ */
24
+ export declare function discoverIntegrations(): Promise<Integration[]>;
25
+ /**
26
+ * Run each integration's `setupOnce` once, honouring `deactivates`.
27
+ *
28
+ * @returns the set of identifiers installed so far this process.
29
+ */
30
+ export declare function setupIntegrations(integrations: Integration[], ctx: IntegrationSetupContext): Set<string>;
31
+ /**
32
+ * Run every integration teardown and clear the run-once guard, so the next
33
+ * `setupIntegrations()` (e.g. after `introspection.shutdown()` + a fresh
34
+ * `init()`) re-installs against the rebuilt provider instead of being skipped.
35
+ */
36
+ export declare function teardownIntegrations(): void;
37
+ /** Clear the run-once guard (running teardowns). Test-only utility. */
38
+ export declare function resetInstalledForTests(): void;
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;AA0BzE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAOpD;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAmBnE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,WAAW,EAAE,EAC3B,GAAG,EAAE,uBAAuB,GAC3B,GAAG,CAAC,MAAM,CAAC,CAoCb;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Integration discovery + setup loader for `introspection.init()`.
3
+ *
4
+ * Mirrors the Python SDK's registry: built-in integrations are resolved
5
+ * lazily (a missing framework just skips its shim), `setupOnce` runs at most
6
+ * once per identifier per process, and an integration may `deactivate` others.
7
+ */
8
+ import { logger } from "../../utils.js";
9
+ import { DidNotEnable, } from "./base.js";
10
+ export { DidNotEnable };
11
+ /**
12
+ * Built-in integrations, loaded lazily. Each thunk dynamically imports an
13
+ * integration module; that module imports its framework at the top level, so
14
+ * if the framework is not installed the import rejects and the integration is
15
+ * skipped. Order matters only for `deactivates` resolution (handled below).
16
+ */
17
+ const BUILTIN_INTEGRATIONS = [
18
+ () => import("./anthropic.js"),
19
+ () => import("./gemini.js"),
20
+ () => import("./openai-agents.js"),
21
+ () => import("./vercel.js"),
22
+ () => import("./claude-agent.js"),
23
+ () => import("./langchain.js"),
24
+ () => import("./mastra.js"),
25
+ () => import("./pi.js"),
26
+ ];
27
+ const installed = new Set();
28
+ // Teardown callbacks returned by integration setupOnce (e.g. uninstrument a
29
+ // prototype patch), run by teardownIntegrations() on shutdown.
30
+ const teardowns = [];
31
+ /**
32
+ * Distinguish "framework package not installed" (expected — skip quietly) from
33
+ * a real error inside an installed integration (a bug we shouldn't hide).
34
+ */
35
+ export function isModuleNotFound(e) {
36
+ const code = e?.code;
37
+ if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
38
+ return true;
39
+ }
40
+ const msg = e instanceof Error ? e.message : String(e);
41
+ return /Cannot find (module|package)|Failed to resolve/i.test(msg);
42
+ }
43
+ /**
44
+ * Return the built-in integrations whose framework is importable.
45
+ *
46
+ * Each module's top-level framework import determines availability: a missing
47
+ * package makes the dynamic import reject, which we log at debug and skip. Any
48
+ * OTHER failure (a real error inside an installed integration) is surfaced at
49
+ * warn level rather than silently swallowed — it's a bug, not an absent peer.
50
+ */
51
+ export async function discoverIntegrations() {
52
+ const found = [];
53
+ for (const load of BUILTIN_INTEGRATIONS) {
54
+ try {
55
+ const mod = await load();
56
+ if (mod.default)
57
+ found.push(mod.default);
58
+ }
59
+ catch (e) {
60
+ if (isModuleNotFound(e)) {
61
+ logger.debug(`Skipping integration (framework not installed): ${String(e)}`);
62
+ }
63
+ else {
64
+ logger.warn(`Integration failed to load with an unexpected error (skipping): ${String(e)}`);
65
+ }
66
+ }
67
+ }
68
+ return found;
69
+ }
70
+ /**
71
+ * Run each integration's `setupOnce` once, honouring `deactivates`.
72
+ *
73
+ * @returns the set of identifiers installed so far this process.
74
+ */
75
+ export function setupIntegrations(integrations, ctx) {
76
+ // First-wins de-dupe by identifier.
77
+ const byId = new Map();
78
+ for (const integration of integrations) {
79
+ if (!byId.has(integration.identifier)) {
80
+ byId.set(integration.identifier, integration);
81
+ }
82
+ }
83
+ const disabled = new Set();
84
+ for (const integration of byId.values()) {
85
+ for (const id of integration.deactivates ?? [])
86
+ disabled.add(id);
87
+ }
88
+ for (const [identifier, integration] of byId) {
89
+ if (disabled.has(identifier)) {
90
+ logger.debug(`Skipping ${identifier} (deactivated by another integration)`);
91
+ continue;
92
+ }
93
+ if (installed.has(identifier))
94
+ continue;
95
+ try {
96
+ const teardown = integration.setupOnce(ctx);
97
+ if (typeof teardown === "function")
98
+ teardowns.push(teardown);
99
+ installed.add(identifier);
100
+ }
101
+ catch (e) {
102
+ if (e instanceof DidNotEnable) {
103
+ logger.debug(`Could not enable ${identifier}: ${e.message}`);
104
+ continue;
105
+ }
106
+ throw e;
107
+ }
108
+ }
109
+ return new Set(installed);
110
+ }
111
+ /**
112
+ * Run every integration teardown and clear the run-once guard, so the next
113
+ * `setupIntegrations()` (e.g. after `introspection.shutdown()` + a fresh
114
+ * `init()`) re-installs against the rebuilt provider instead of being skipped.
115
+ */
116
+ export function teardownIntegrations() {
117
+ for (const teardown of teardowns.splice(0)) {
118
+ try {
119
+ teardown();
120
+ }
121
+ catch (e) {
122
+ logger.debug(`Error tearing down integration: ${String(e)}`);
123
+ }
124
+ }
125
+ installed.clear();
126
+ }
127
+ /** Clear the run-once guard (running teardowns). Test-only utility. */
128
+ export function resetInstalledForTests() {
129
+ teardownIntegrations();
130
+ }
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,YAAY,GAIb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,CAAC;AAGxB;;;;;GAKG;AACH,MAAM,oBAAoB,GAEtB;IACF,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC9B,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;IAC3B,GAAG,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC;IAClC,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;IAC3B,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC;IACjC,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC9B,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;IAC3B,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;AACpC,4EAA4E;AAC5E,+DAA+D;AAC/D,MAAM,SAAS,GAAsB,EAAE,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,MAAM,IAAI,GAAI,CAA8B,EAAE,IAAI,CAAC;IACnD,IAAI,IAAI,KAAK,sBAAsB,IAAI,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CA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CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IACD,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB;IACpC,oBAAoB,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LangChain / LangGraph integration.
3
+ *
4
+ * The callback handler is attached per-invoke (`chain.invoke(input, { callbacks
5
+ * })`), so this integration builds the handler — pre-bound to the `init()`
6
+ * token — and publishes it via `introspection.getLangchainHandler()`.
7
+ *
8
+ * Deactivates the Anthropic integration: when LangChain drives the Anthropic
9
+ * model, the handler already traces the call, so the prototype-level Anthropic
10
+ * patch would double-trace it.
11
+ */
12
+ import "@langchain/core/callbacks/base";
13
+ import type { Integration } from "./base.js";
14
+ declare const integration: Integration;
15
+ export default integration;
16
+ //# sourceMappingURL=langchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,QAAA,MAAM,WAAW,EAAE,WAwBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * LangChain / LangGraph integration.
3
+ *
4
+ * The callback handler is attached per-invoke (`chain.invoke(input, { callbacks
5
+ * })`), so this integration builds the handler — pre-bound to the `init()`
6
+ * token — and publishes it via `introspection.getLangchainHandler()`.
7
+ *
8
+ * Deactivates the Anthropic integration: when LangChain drives the Anthropic
9
+ * model, the handler already traces the call, so the prototype-level Anthropic
10
+ * patch would double-trace it.
11
+ */
12
+ // Presence gate.
13
+ import "@langchain/core/callbacks/base";
14
+ import { IntrospectionCallbackHandler } from "../langchain-handler.js";
15
+ const integration = {
16
+ identifier: "langchain",
17
+ // Intentional, and matches the Python SDK: when @langchain/core is present,
18
+ // auto-discovery skips the always-on raw-Anthropic prototype patch so a
19
+ // LangChain → ChatAnthropic call isn't traced twice (once by LangChain's
20
+ // callback handler, once by the raw `messages.create` patch).
21
+ //
22
+ // Trade-off (by design): if an app has BOTH @langchain/core installed AND
23
+ // makes raw `@anthropic-ai/sdk` calls outside LangChain, those raw calls
24
+ // won't be auto-traced. To trace them, instrument explicitly with
25
+ // `new AnthropicInstrumentor().instrumentClass(...)`, or call
26
+ // `init({ autoDiscover: false, integrations: [anthropicIntegration] })`.
27
+ deactivates: ["anthropic"],
28
+ setupOnce({ token, serviceName, baseUrl, advanced, handles }) {
29
+ handles.langchainHandler = new IntrospectionCallbackHandler({
30
+ token,
31
+ serviceName,
32
+ baseUrl,
33
+ additionalHeaders: advanced?.additionalHeaders,
34
+ advanced: advanced?.spanExporter
35
+ ? { spanExporter: advanced.spanExporter }
36
+ : undefined,
37
+ });
38
+ },
39
+ };
40
+ export default integration;
41
+ //# sourceMappingURL=langchain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../../src/otel/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,iBAAiB;AACjB,OAAO,gCAAgC,CAAC;AAExC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAGvE,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,WAAW;IACvB,4EAA4E;IAC5E,wEAAwE;IACxE,yEAAyE;IACzE,8DAA8D;IAC9D,EAAE;IACF,0EAA0E;IAC1E,yEAAyE;IACzE,kEAAkE;IAClE,8DAA8D;IAC9D,yEAAyE;IACzE,WAAW,EAAE,CAAC,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC1D,OAAO,CAAC,gBAAgB,GAAG,IAAI,4BAA4B,CAAC;YAC1D,KAAK;YACL,WAAW;YACX,OAAO;YACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;YAC9C,QAAQ,EAAE,QAAQ,EAAE,YAAY;gBAC9B,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACzC,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Mastra integration.
3
+ *
4
+ * The Mastra exporter is wired into Mastra's `observability.configs` rather
5
+ * than globally, so this integration builds the exporter — pre-bound to the
6
+ * `init()` token — and publishes it via `introspection.getMastraExporter()`.
7
+ *
8
+ * Importing `../mastra-exporter.js` (which requires `@mastra/observability`)
9
+ * is the presence gate: a missing Mastra makes discovery skip this shim.
10
+ */
11
+ import type { Integration } from "./base.js";
12
+ declare const integration: Integration;
13
+ export default integration;
14
+ //# sourceMappingURL=mastra.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,QAAA,MAAM,WAAW,EAAE,WAalB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Mastra integration.
3
+ *
4
+ * The Mastra exporter is wired into Mastra's `observability.configs` rather
5
+ * than globally, so this integration builds the exporter — pre-bound to the
6
+ * `init()` token — and publishes it via `introspection.getMastraExporter()`.
7
+ *
8
+ * Importing `../mastra-exporter.js` (which requires `@mastra/observability`)
9
+ * is the presence gate: a missing Mastra makes discovery skip this shim.
10
+ */
11
+ import { IntrospectionMastraExporter } from "../mastra-exporter.js";
12
+ const integration = {
13
+ identifier: "mastra",
14
+ setupOnce({ token, baseUrl, advanced, handles }) {
15
+ handles.mastraExporter = new IntrospectionMastraExporter({
16
+ token,
17
+ baseUrl,
18
+ additionalHeaders: advanced?.additionalHeaders,
19
+ debug: advanced?.debug,
20
+ advanced: advanced?.spanExporter
21
+ ? { spanExporter: advanced.spanExporter }
22
+ : undefined,
23
+ });
24
+ },
25
+ };
26
+ export default integration;
27
+ //# sourceMappingURL=mastra.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra.js","sourceRoot":"","sources":["../../../src/otel/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAGpE,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,QAAQ;IACpB,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC7C,OAAO,CAAC,cAAc,GAAG,IAAI,2BAA2B,CAAC;YACvD,KAAK;YACL,OAAO;YACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;YAC9C,KAAK,EAAE,QAAQ,EAAE,KAAK;YACtB,QAAQ,EAAE,QAAQ,EAAE,YAAY;gBAC9B,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACzC,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * OpenAI Agents SDK integration.
3
+ *
4
+ * Registers an {@link IntrospectionTracingProcessor} with the Agents SDK's
5
+ * global trace pipeline. `addTraceProcessor` appends, preserving any processors
6
+ * other integrations (e.g. a vendor exporter) already registered.
7
+ */
8
+ import type { Integration } from "./base.js";
9
+ declare const integration: Integration;
10
+ export default integration;
11
+ //# sourceMappingURL=openai-agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,QAAA,MAAM,WAAW,EAAE,WAelB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * OpenAI Agents SDK integration.
3
+ *
4
+ * Registers an {@link IntrospectionTracingProcessor} with the Agents SDK's
5
+ * global trace pipeline. `addTraceProcessor` appends, preserving any processors
6
+ * other integrations (e.g. a vendor exporter) already registered.
7
+ */
8
+ import { addTraceProcessor } from "@openai/agents";
9
+ import { IntrospectionTracingProcessor } from "../tracing-processor.js";
10
+ const integration = {
11
+ identifier: "openai_agents",
12
+ setupOnce({ token, serviceName, baseUrl, advanced }) {
13
+ addTraceProcessor(new IntrospectionTracingProcessor({
14
+ token,
15
+ serviceName,
16
+ baseUrl,
17
+ additionalHeaders: advanced?.additionalHeaders,
18
+ advanced: advanced?.spanExporter
19
+ ? { spanExporter: advanced.spanExporter }
20
+ : undefined,
21
+ }));
22
+ },
23
+ };
24
+ export default integration;
25
+ //# sourceMappingURL=openai-agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-agents.js","sourceRoot":"","sources":["../../../src/otel/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAGxE,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,eAAe;IAC3B,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE;QACjD,iBAAiB,CACf,IAAI,6BAA6B,CAAC;YAChC,KAAK;YACL,WAAW;YACX,OAAO;YACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;YAC9C,QAAQ,EAAE,QAAQ,EAAE,YAAY;gBAC9B,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACzC,CAAC,CAAC,SAAS;SACd,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Pi Agent SDK integration.
3
+ *
4
+ * The Pi instrumentor wraps a specific `Agent` instance, so this integration
5
+ * builds the instrumentor — bound to the shared provider's global tracer — and
6
+ * publishes it via `introspection.instrumentPi(agent, meta)`.
7
+ */
8
+ import "@mariozechner/pi-agent-core";
9
+ import type { Integration } from "./base.js";
10
+ declare const integration: Integration;
11
+ export default integration;
12
+ //# sourceMappingURL=pi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,QAAA,MAAM,WAAW,EAAE,WAOlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Pi Agent SDK integration.
3
+ *
4
+ * The Pi instrumentor wraps a specific `Agent` instance, so this integration
5
+ * builds the instrumentor — bound to the shared provider's global tracer — and
6
+ * publishes it via `introspection.instrumentPi(agent, meta)`.
7
+ */
8
+ // Presence gate.
9
+ import "@mariozechner/pi-agent-core";
10
+ import { IntrospectionPiInstrumentor } from "../pi.js";
11
+ const integration = {
12
+ identifier: "pi",
13
+ setupOnce({ handles }) {
14
+ // The instrumentor emits onto the global tracer, which `init()` has just
15
+ // registered with the shared IntrospectionSpanProcessor.
16
+ handles.piInstrumentor = new IntrospectionPiInstrumentor();
17
+ },
18
+ };
19
+ export default integration;
20
+ //# sourceMappingURL=pi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.js","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iBAAiB;AACjB,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAGvD,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,IAAI;IAChB,SAAS,CAAC,EAAE,OAAO,EAAE;QACnB,yEAAyE;QACzE,yDAAyD;QACzD,OAAO,CAAC,cAAc,GAAG,IAAI,2BAA2B,EAAE,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Vercel AI SDK integration.
3
+ *
4
+ * The AI SDK emits `ai.*` / `gen_ai.*` attributes natively via OTel when
5
+ * `experimental_telemetry` is enabled. The shared provider already carries an
6
+ * {@link IntrospectionSpanProcessor}, which converts those `ai.*` attributes to
7
+ * canonical `gen_ai.*` semconv at span end — so there is nothing to patch here.
8
+ * This integration exists so auto-discovery reports the AI SDK as detected and
9
+ * (via its top-level import) is skipped when `ai` is not installed.
10
+ */
11
+ import "ai";
12
+ import type { Integration } from "./base.js";
13
+ declare const integration: Integration;
14
+ export default integration;
15
+ //# sourceMappingURL=vercel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,IAAI,CAAC;AAEZ,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,QAAA,MAAM,WAAW,EAAE,WAKlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Vercel AI SDK integration.
3
+ *
4
+ * The AI SDK emits `ai.*` / `gen_ai.*` attributes natively via OTel when
5
+ * `experimental_telemetry` is enabled. The shared provider already carries an
6
+ * {@link IntrospectionSpanProcessor}, which converts those `ai.*` attributes to
7
+ * canonical `gen_ai.*` semconv at span end — so there is nothing to patch here.
8
+ * This integration exists so auto-discovery reports the AI SDK as detected and
9
+ * (via its top-level import) is skipped when `ai` is not installed.
10
+ */
11
+ // Presence gate: a missing `ai` package makes this module's import reject.
12
+ import "ai";
13
+ const integration = {
14
+ identifier: "vercel",
15
+ setupOnce() {
16
+ // No-op: the shared IntrospectionSpanProcessor converts AI SDK spans.
17
+ },
18
+ };
19
+ export default integration;
20
+ //# sourceMappingURL=vercel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../../src/otel/integrations/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,2EAA2E;AAC3E,OAAO,IAAI,CAAC;AAIZ,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,QAAQ;IACpB,SAAS;QACP,sEAAsE;IACxE,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Run `init()` if a token is configured. Exported (and awaited at module load)
3
+ * so tests can invoke it deterministically; the module-level `await` below
4
+ * guarantees the preload finishes — including framework auto-discovery and the
5
+ * prototype patch — before Node evaluates the application entry point.
6
+ */
7
+ export declare function registerFromEnv(): Promise<void>;
8
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/otel/register.ts"],"names":[],"mappings":"AA2BA;;;;;GAKG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAcrD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Zero-code preload entry point for Introspection tracing.
3
+ *
4
+ * Usage (ESM):
5
+ *
6
+ * ```bash
7
+ * node --import @introspection-sdk/introspection-node/otel/register app.js
8
+ * ```
9
+ *
10
+ * Runs `introspection.init()` from the environment **before** the app's module
11
+ * graph executes, so no `init()` call is needed in application source. Because
12
+ * the Anthropic / Gemini one-liner works by prototype-patching the SDK classes
13
+ * (see `AnthropicInstrumentor.instrumentClass`), every client constructed after
14
+ * this preload is traced with zero code changes.
15
+ *
16
+ * Configuration is read from the usual environment variables
17
+ * (`INTROSPECTION_TOKEN`, `INTROSPECTION_SERVICE_NAME`,
18
+ * `INTROSPECTION_BASE_OTEL_URL`). If no token is configured the preload logs a
19
+ * warning and does nothing, so it never crashes the host application.
20
+ *
21
+ * This is the counterpart to the private SDK's `register.ts`, adapted to the
22
+ * `src/otel` surface: it drives the existing `init()` rather than registering an
23
+ * import-in-the-middle loader hook (the prototype-patch path does not need one).
24
+ */
25
+ import { logger } from "../utils.js";
26
+ import { init } from "./init.js";
27
+ /**
28
+ * Run `init()` if a token is configured. Exported (and awaited at module load)
29
+ * so tests can invoke it deterministically; the module-level `await` below
30
+ * guarantees the preload finishes — including framework auto-discovery and the
31
+ * prototype patch — before Node evaluates the application entry point.
32
+ */
33
+ export async function registerFromEnv() {
34
+ if (!process.env.INTROSPECTION_TOKEN) {
35
+ logger.warn("[introspection] register: INTROSPECTION_TOKEN not set; tracing not initialised.");
36
+ return;
37
+ }
38
+ try {
39
+ await init();
40
+ logger.debug("[introspection] register: tracing initialised from preload.");
41
+ }
42
+ catch (err) {
43
+ // Never let a preload failure take down the host application.
44
+ logger.warn(`[introspection] register: init failed: ${String(err)}`);
45
+ }
46
+ }
47
+ await registerFromEnv();
48
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/otel/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CACT,iFAAiF,CAClF,CAAC;QACF,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,MAAM,IAAI,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC9E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,8DAA8D;QAC9D,MAAM,CAAC,IAAI,CAAC,0CAA0C,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED,MAAM,eAAe,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
2
+ import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
2
3
  import { type IntrospectionSpanProcessorOptions } from "./span-processor.js";
3
4
  export type ConflictBehavior = "warn" | "throw" | "replace";
4
5
  export interface SetupTracingOptions extends IntrospectionSpanProcessorOptions {
@@ -15,7 +16,35 @@ export interface SetupTracingOptions extends IntrospectionSpanProcessorOptions {
15
16
  * other libraries that relied on the previous registration.
16
17
  */
17
18
  onConflict?: ConflictBehavior;
19
+ /**
20
+ * Extra span processors attached to the same `NodeTracerProvider`, so a
21
+ * single set of spans fans out to other backends (Langfuse, Arize, …).
22
+ * This is the low-level dual-export hook:
23
+ *
24
+ * ```ts
25
+ * setupTracing({
26
+ * serviceName: "my-app",
27
+ * additionalSpanProcessors: [new BatchSpanProcessor(langfuseExporter)],
28
+ * });
29
+ * ```
30
+ *
31
+ * Note: the {@link IntrospectionSpanProcessor} forwards its *own* converted
32
+ * copy of each span to Introspection — it does not mutate the shared span —
33
+ * so these processors receive the raw span and run independently of it.
34
+ * Order is therefore irrelevant. `introspection.init({ spanProcessors })`
35
+ * is the equivalent for the one-liner surface.
36
+ */
37
+ additionalSpanProcessors?: SpanProcessor[];
18
38
  }
39
+ /**
40
+ * Install the OTel context manager + W3C (trace-context + baggage) propagator
41
+ * that Introspection's baggage scopes depend on.
42
+ *
43
+ * Shared by {@link setupTracing} and `introspection.init()`. `behavior`
44
+ * controls what happens when a manager / propagator is already registered
45
+ * (see {@link ConflictBehavior}).
46
+ */
47
+ export declare function registerOTelGlobals(behavior?: ConflictBehavior): void;
19
48
  /**
20
49
  * Initialise Introspection tracing for a Node.js process.
21
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/otel/setup.ts"],"names":[],"mappings":"AA8DA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5D,MAAM,WAAW,mBAAoB,SAAQ,iCAAiC;IAC5E;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AA8DD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,kBAAkB,CAkBpB"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/otel/setup.ts"],"names":[],"mappings":"AA8DA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5D,MAAM,WAAW,mBAAoB,SAAQ,iCAAiC;IAC5E;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B;;;;;;;;;;;;;;;;;OAiBG;IACH,wBAAwB,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5C;AA8DD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAIrE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,kBAAkB,CAwBpB"}
@@ -107,6 +107,19 @@ function registerPropagator(behavior) {
107
107
  }
108
108
  logger.warn(msg);
109
109
  }
110
+ /**
111
+ * Install the OTel context manager + W3C (trace-context + baggage) propagator
112
+ * that Introspection's baggage scopes depend on.
113
+ *
114
+ * Shared by {@link setupTracing} and `introspection.init()`. `behavior`
115
+ * controls what happens when a manager / propagator is already registered
116
+ * (see {@link ConflictBehavior}).
117
+ */
118
+ export function registerOTelGlobals(behavior) {
119
+ const resolved = behavior ?? defaultConflictBehavior();
120
+ registerContextManager(resolved);
121
+ registerPropagator(resolved);
122
+ }
110
123
  /**
111
124
  * Initialise Introspection tracing for a Node.js process.
112
125
  */
@@ -115,10 +128,16 @@ export function setupTracing(options) {
115
128
  return registeredProvider;
116
129
  }
117
130
  const behavior = options?.onConflict ?? defaultConflictBehavior();
118
- registerContextManager(behavior);
119
- registerPropagator(behavior);
131
+ registerOTelGlobals(behavior);
120
132
  const provider = new NodeTracerProvider({
121
- spanProcessors: [new IntrospectionSpanProcessor(options)],
133
+ // Order is irrelevant: IntrospectionSpanProcessor exports its own converted
134
+ // copy and does not mutate the shared span, so co-located dual-export
135
+ // processors receive the raw span regardless of position. Listed first here
136
+ // (and in init()) purely for a consistent, readable ordering story.
137
+ spanProcessors: [
138
+ new IntrospectionSpanProcessor(options),
139
+ ...(options?.additionalSpanProcessors ?? []),
140
+ ],
122
141
  });
123
142
  provider.register();
124
143
  registeredProvider = provider;
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/otel/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACp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kBAAkB,CAAC;QACtC,4EAA4E;QAC5E,sEAAsE;QACtE,4EAA4E;QAC5E,oEAAoE;QACpE,cAAc,EAAE;YACd,IAAI,0BAA0B,CAAC,OAAO,CAAC;YACvC,GAAG,CAAC,OAAO,EAAE,wBAAwB,IAAI,EAAE,CAAC;SAC7C;KACF,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEpB,kBAAkB,GAAG,QAAQ,CAAC;IAC9B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,14 @@
1
1
  import { DiagLogger } from "@opentelemetry/api";
2
+ /**
3
+ * Attach a forward-proxy agent to OTLP exporter options when a proxy is
4
+ * configured in the environment.
5
+ *
6
+ * Note: the OTLP proto exporters use Node's `http`/`https` stack, so this uses
7
+ * `HttpsProxyAgent` (an `http.Agent`) rather than the undici dispatcher from
8
+ * `./proxy.js` — a dispatcher only applies to `fetch`. The proxy *URL* is
9
+ * resolved by the shared {@link resolveForwardProxyUrl} so fetch and OTLP
10
+ * traffic agree on which proxy to use.
11
+ */
2
12
  export declare function withOtlpHttpsProxy<T extends object>(options: T): T;
3
13
  /**
4
14
  * Logger for introspection-sdk package.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAO9D,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAQlE;AAED;;;GAGG;AACH,cAAM,mBAAoB,YAAW,UAAU;IAC7C,OAAO,CAAC,QAAQ,CAAe;;IAS/B,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,SAAS;IAIjB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,I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