openlit 1.10.0 → 1.12.0

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 (195) hide show
  1. package/README.md +35 -1
  2. package/dist/config.d.ts +12 -4
  3. package/dist/config.js +7 -17
  4. package/dist/config.js.map +1 -1
  5. package/dist/evals/llm/anthropic.js +10 -6
  6. package/dist/evals/llm/anthropic.js.map +1 -1
  7. package/dist/evals/llm/openai.js +9 -5
  8. package/dist/evals/llm/openai.js.map +1 -1
  9. package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
  10. package/dist/features/__tests__/rule-engine.test.js +146 -0
  11. package/dist/features/__tests__/rule-engine.test.js.map +1 -0
  12. package/dist/features/base.d.ts +2 -0
  13. package/dist/features/base.js +2 -0
  14. package/dist/features/base.js.map +1 -1
  15. package/dist/features/rule-engine.d.ts +6 -0
  16. package/dist/features/rule-engine.js +60 -0
  17. package/dist/features/rule-engine.js.map +1 -0
  18. package/dist/features/vault.js +1 -1
  19. package/dist/features/vault.js.map +1 -1
  20. package/dist/helpers.d.ts +93 -1
  21. package/dist/helpers.js +270 -8
  22. package/dist/helpers.js.map +1 -1
  23. package/dist/index.d.ts +6 -5
  24. package/dist/index.js +95 -50
  25. package/dist/index.js.map +1 -1
  26. package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +215 -27
  27. package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -1
  28. package/dist/instrumentation/__tests__/base-wrapper.test.js +19 -23
  29. package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -1
  30. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
  31. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
  32. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
  33. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +1 -1
  34. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -1
  35. package/dist/instrumentation/__tests__/cohere-wrapper.test.js +150 -25
  36. package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -1
  37. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +152 -33
  38. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -1
  39. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +391 -45
  40. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -1
  41. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +2 -2
  42. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +323 -31
  43. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -1
  44. package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
  45. package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
  46. package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
  47. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +1 -1
  48. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -1
  49. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +0 -3
  50. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +275 -68
  51. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -1
  52. package/dist/instrumentation/__tests__/openai-wrapper.test.js +7 -9
  53. package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -1
  54. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +1 -1
  55. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -1
  56. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +2 -1
  57. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +209 -21
  58. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -1
  59. package/dist/instrumentation/__tests__/together-trace-comparison.test.js +231 -51
  60. package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -1
  61. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
  62. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
  63. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
  64. package/dist/instrumentation/anthropic/index.d.ts +2 -3
  65. package/dist/instrumentation/anthropic/index.js.map +1 -1
  66. package/dist/instrumentation/anthropic/wrapper.d.ts +1 -3
  67. package/dist/instrumentation/anthropic/wrapper.js +211 -91
  68. package/dist/instrumentation/anthropic/wrapper.js.map +1 -1
  69. package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
  70. package/dist/instrumentation/azure-ai-inference/index.js +76 -0
  71. package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
  72. package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +42 -0
  73. package/dist/instrumentation/azure-ai-inference/wrapper.js +515 -0
  74. package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
  75. package/dist/instrumentation/base-wrapper.d.ts +2 -1
  76. package/dist/instrumentation/base-wrapper.js +35 -23
  77. package/dist/instrumentation/base-wrapper.js.map +1 -1
  78. package/dist/instrumentation/bedrock/wrapper.d.ts +21 -3
  79. package/dist/instrumentation/bedrock/wrapper.js +318 -265
  80. package/dist/instrumentation/bedrock/wrapper.js.map +1 -1
  81. package/dist/instrumentation/chroma/wrapper.js +1 -1
  82. package/dist/instrumentation/chroma/wrapper.js.map +1 -1
  83. package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
  84. package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
  85. package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
  86. package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
  87. package/dist/instrumentation/claude-agent-sdk/wrapper.js +1031 -0
  88. package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
  89. package/dist/instrumentation/cohere/index.d.ts +2 -3
  90. package/dist/instrumentation/cohere/index.js.map +1 -1
  91. package/dist/instrumentation/cohere/wrapper.d.ts +1 -1
  92. package/dist/instrumentation/cohere/wrapper.js +215 -56
  93. package/dist/instrumentation/cohere/wrapper.js.map +1 -1
  94. package/dist/instrumentation/google-adk/index.d.ts +57 -0
  95. package/dist/instrumentation/google-adk/index.js +371 -0
  96. package/dist/instrumentation/google-adk/index.js.map +1 -0
  97. package/dist/instrumentation/google-adk/utils.d.ts +45 -0
  98. package/dist/instrumentation/google-adk/utils.js +663 -0
  99. package/dist/instrumentation/google-adk/utils.js.map +1 -0
  100. package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
  101. package/dist/instrumentation/google-adk/wrapper.js +391 -0
  102. package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
  103. package/dist/instrumentation/google-ai/wrapper.d.ts +7 -4
  104. package/dist/instrumentation/google-ai/wrapper.js +197 -61
  105. package/dist/instrumentation/google-ai/wrapper.js.map +1 -1
  106. package/dist/instrumentation/groq/wrapper.js +137 -65
  107. package/dist/instrumentation/groq/wrapper.js.map +1 -1
  108. package/dist/instrumentation/huggingface/wrapper.js +241 -39
  109. package/dist/instrumentation/huggingface/wrapper.js.map +1 -1
  110. package/dist/instrumentation/index.d.ts +2 -2
  111. package/dist/instrumentation/index.js +64 -6
  112. package/dist/instrumentation/index.js.map +1 -1
  113. package/dist/instrumentation/langchain/index.d.ts +0 -7
  114. package/dist/instrumentation/langchain/index.js +2 -20
  115. package/dist/instrumentation/langchain/index.js.map +1 -1
  116. package/dist/instrumentation/langchain/wrapper.d.ts +35 -0
  117. package/dist/instrumentation/langchain/wrapper.js +1098 -184
  118. package/dist/instrumentation/langchain/wrapper.js.map +1 -1
  119. package/dist/instrumentation/langgraph/index.d.ts +12 -0
  120. package/dist/instrumentation/langgraph/index.js +99 -0
  121. package/dist/instrumentation/langgraph/index.js.map +1 -0
  122. package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
  123. package/dist/instrumentation/langgraph/wrapper.js +619 -0
  124. package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
  125. package/dist/instrumentation/llamaindex/index.d.ts +31 -6
  126. package/dist/instrumentation/llamaindex/index.js +180 -61
  127. package/dist/instrumentation/llamaindex/index.js.map +1 -1
  128. package/dist/instrumentation/llamaindex/wrapper.d.ts +15 -3
  129. package/dist/instrumentation/llamaindex/wrapper.js +670 -179
  130. package/dist/instrumentation/llamaindex/wrapper.js.map +1 -1
  131. package/dist/instrumentation/milvus/wrapper.js +1 -1
  132. package/dist/instrumentation/milvus/wrapper.js.map +1 -1
  133. package/dist/instrumentation/mistral/wrapper.js +154 -79
  134. package/dist/instrumentation/mistral/wrapper.js.map +1 -1
  135. package/dist/instrumentation/ollama/index.js +33 -4
  136. package/dist/instrumentation/ollama/index.js.map +1 -1
  137. package/dist/instrumentation/ollama/wrapper.d.ts +28 -2
  138. package/dist/instrumentation/ollama/wrapper.js +432 -48
  139. package/dist/instrumentation/ollama/wrapper.js.map +1 -1
  140. package/dist/instrumentation/openai/index.d.ts +2 -3
  141. package/dist/instrumentation/openai/index.js.map +1 -1
  142. package/dist/instrumentation/openai/wrapper.js +293 -194
  143. package/dist/instrumentation/openai/wrapper.js.map +1 -1
  144. package/dist/instrumentation/openai-agents/index.d.ts +20 -0
  145. package/dist/instrumentation/openai-agents/index.js +174 -0
  146. package/dist/instrumentation/openai-agents/index.js.map +1 -0
  147. package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
  148. package/dist/instrumentation/openai-agents/processor.js +249 -0
  149. package/dist/instrumentation/openai-agents/processor.js.map +1 -0
  150. package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
  151. package/dist/instrumentation/openai-agents/utils.js +624 -0
  152. package/dist/instrumentation/openai-agents/utils.js.map +1 -0
  153. package/dist/instrumentation/pinecone/wrapper.js +2 -2
  154. package/dist/instrumentation/pinecone/wrapper.js.map +1 -1
  155. package/dist/instrumentation/qdrant/wrapper.js +1 -1
  156. package/dist/instrumentation/qdrant/wrapper.js.map +1 -1
  157. package/dist/instrumentation/replicate/wrapper.js +103 -21
  158. package/dist/instrumentation/replicate/wrapper.js.map +1 -1
  159. package/dist/instrumentation/strands/index.d.ts +21 -0
  160. package/dist/instrumentation/strands/index.js +83 -0
  161. package/dist/instrumentation/strands/index.js.map +1 -0
  162. package/dist/instrumentation/strands/processor.d.ts +45 -0
  163. package/dist/instrumentation/strands/processor.js +545 -0
  164. package/dist/instrumentation/strands/processor.js.map +1 -0
  165. package/dist/instrumentation/strands/utils.d.ts +24 -0
  166. package/dist/instrumentation/strands/utils.js +360 -0
  167. package/dist/instrumentation/strands/utils.js.map +1 -0
  168. package/dist/instrumentation/together/wrapper.js +125 -51
  169. package/dist/instrumentation/together/wrapper.js.map +1 -1
  170. package/dist/instrumentation/vercel-ai/wrapper.d.ts +28 -2
  171. package/dist/instrumentation/vercel-ai/wrapper.js +314 -164
  172. package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -1
  173. package/dist/llm/anthropic.js +10 -6
  174. package/dist/llm/anthropic.js.map +1 -1
  175. package/dist/llm/openai.js +9 -5
  176. package/dist/llm/openai.js.map +1 -1
  177. package/dist/otel/__tests__/metrics.test.js +16 -27
  178. package/dist/otel/__tests__/metrics.test.js.map +1 -1
  179. package/dist/otel/events.d.ts +11 -0
  180. package/dist/otel/events.js +74 -0
  181. package/dist/otel/events.js.map +1 -0
  182. package/dist/otel/metrics.d.ts +5 -6
  183. package/dist/otel/metrics.js +66 -48
  184. package/dist/otel/metrics.js.map +1 -1
  185. package/dist/otel/tracing.d.ts +6 -2
  186. package/dist/otel/tracing.js +71 -24
  187. package/dist/otel/tracing.js.map +1 -1
  188. package/dist/otel/utils.d.ts +11 -0
  189. package/dist/otel/utils.js +34 -0
  190. package/dist/otel/utils.js.map +1 -0
  191. package/dist/semantic-convention.d.ts +44 -5
  192. package/dist/semantic-convention.js +51 -8
  193. package/dist/semantic-convention.js.map +1 -1
  194. package/dist/types.d.ts +74 -22
  195. package/package.json +41 -9
@@ -1,11 +1,36 @@
1
+ /**
2
+ * OpenLIT LlamaIndex Instrumentation
3
+ *
4
+ * Monkey-patches LlamaIndex JS classes to emit OTel-compliant telemetry.
5
+ * Mirrors the Python SDK: sdk/python/src/openlit/instrumentation/llamaindex/__init__.py
6
+ *
7
+ * Targets the `llamaindex` npm package (>=0.3.0).
8
+ * Patches: LLM classes, query engines, chat engines, retrievers, embeddings,
9
+ * index construction, document loaders, splitters, and synthesizers.
10
+ */
1
11
  import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
2
- import { InstrumentationConfig } from '@opentelemetry/instrumentation';
3
- export interface LlamaIndexInstrumentationConfig extends InstrumentationConfig {
4
- }
12
+ import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
5
13
  export default class OpenlitLlamaIndexInstrumentation extends InstrumentationBase {
6
- constructor(config?: LlamaIndexInstrumentationConfig);
14
+ constructor(config?: InstrumentationConfig);
7
15
  protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
8
16
  manualPatch(llamaindex: any): void;
9
- protected _patch(moduleExports: any): void;
10
- protected _unpatch(moduleExports: any): void;
17
+ /**
18
+ * Wrap an instance method on the first class found that exposes it.
19
+ * Silently skips classes that aren't exported or don't have the method.
20
+ */
21
+ private _patchProto;
22
+ /**
23
+ * Wrap a static method on a class.
24
+ */
25
+ private _patchStatic;
26
+ /**
27
+ * Unwrap an instance method if it's wrapped.
28
+ */
29
+ private _unwrapProto;
30
+ /**
31
+ * Unwrap a static method if it's wrapped.
32
+ */
33
+ private _unwrapStatic;
34
+ protected _patch(m: any): void;
35
+ protected _unpatch(m: any): void;
11
36
  }
@@ -1,4 +1,14 @@
1
1
  "use strict";
2
+ /**
3
+ * OpenLIT LlamaIndex Instrumentation
4
+ *
5
+ * Monkey-patches LlamaIndex JS classes to emit OTel-compliant telemetry.
6
+ * Mirrors the Python SDK: sdk/python/src/openlit/instrumentation/llamaindex/__init__.py
7
+ *
8
+ * Targets the `llamaindex` npm package (>=0.3.0).
9
+ * Patches: LLM classes, query engines, chat engines, retrievers, embeddings,
10
+ * index construction, document loaders, splitters, and synthesizers.
11
+ */
2
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
14
  };
@@ -11,89 +21,198 @@ class OpenlitLlamaIndexInstrumentation extends instrumentation_1.Instrumentation
11
21
  super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-llamaindex`, '1.0.0', config);
12
22
  }
13
23
  init() {
14
- const module = new instrumentation_1.InstrumentationNodeModuleDefinition('llamaindex', ['>=0.3.0'], (moduleExports) => {
24
+ const mainModule = new instrumentation_1.InstrumentationNodeModuleDefinition('llamaindex', ['>=0.3.0'], (moduleExports) => {
15
25
  this._patch(moduleExports);
16
26
  return moduleExports;
17
27
  }, (moduleExports) => {
18
- if (moduleExports !== undefined) {
28
+ if (moduleExports)
19
29
  this._unpatch(moduleExports);
20
- }
21
30
  });
22
- return [module];
31
+ return [mainModule];
23
32
  }
24
33
  manualPatch(llamaindex) {
25
34
  this._patch(llamaindex);
26
35
  }
27
- _patch(moduleExports) {
36
+ // ---------------------------------------------------------------------------
37
+ // Patch helpers
38
+ // ---------------------------------------------------------------------------
39
+ /**
40
+ * Wrap an instance method on the first class found that exposes it.
41
+ * Silently skips classes that aren't exported or don't have the method.
42
+ */
43
+ _patchProto(moduleExports, classNames, method, wrapper) {
44
+ for (const name of classNames) {
45
+ const Cls = moduleExports[name];
46
+ if (Cls?.prototype?.[method] && !(0, instrumentation_1.isWrapped)(Cls.prototype[method])) {
47
+ try {
48
+ this._wrap(Cls.prototype, method, wrapper);
49
+ }
50
+ catch { /* skip silently */ }
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Wrap a static method on a class.
56
+ */
57
+ _patchStatic(Cls, method, wrapper) {
58
+ if (typeof Cls?.[method] === 'function' && !(0, instrumentation_1.isWrapped)(Cls[method])) {
59
+ try {
60
+ this._wrap(Cls, method, wrapper);
61
+ }
62
+ catch { /* skip silently */ }
63
+ }
64
+ }
65
+ /**
66
+ * Unwrap an instance method if it's wrapped.
67
+ */
68
+ _unwrapProto(moduleExports, classNames, method) {
69
+ for (const name of classNames) {
70
+ const Cls = moduleExports[name];
71
+ if (Cls?.prototype?.[method] && (0, instrumentation_1.isWrapped)(Cls.prototype[method])) {
72
+ try {
73
+ this._unwrap(Cls.prototype, method);
74
+ }
75
+ catch { /* ignore */ }
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * Unwrap a static method if it's wrapped.
81
+ */
82
+ _unwrapStatic(Cls, method) {
83
+ if (Cls && typeof Cls[method] === 'function' && (0, instrumentation_1.isWrapped)(Cls[method])) {
84
+ try {
85
+ this._unwrap(Cls, method);
86
+ }
87
+ catch { /* ignore */ }
88
+ }
89
+ }
90
+ // ---------------------------------------------------------------------------
91
+ // Main patch — mirrors Python _instrument() operation lists
92
+ // ---------------------------------------------------------------------------
93
+ _patch(m) {
28
94
  try {
29
- // Patch query engines
95
+ const tracer = this.tracer;
96
+ // === LLM OPERATIONS (chat spans) ===
97
+ // Mirrors Python: LLM.chat, LLM.complete
98
+ const llmClasses = [
99
+ 'OpenAI', 'Anthropic', 'Ollama', 'Gemini', 'Groq',
100
+ 'HuggingFaceInference', 'Replicate', 'DeepSeek', 'Portkey',
101
+ 'BaseLLM', 'LLM',
102
+ ];
103
+ this._patchProto(m, llmClasses, 'chat', wrapper_1.default._patchLLMChat(tracer));
104
+ this._patchProto(m, llmClasses, 'complete', wrapper_1.default._patchLLMComplete(tracer));
105
+ // === QUERY ENGINE OPERATIONS (retrieval spans) ===
106
+ // Mirrors Python: RetrieverQueryEngine.query, TransformQueryEngine.query
30
107
  const queryEngineClasses = [
31
- 'RetrieverQueryEngine',
32
- 'BaseQueryEngine',
33
- 'QueryEngine',
108
+ 'RetrieverQueryEngine', 'TransformQueryEngine',
109
+ 'SubQuestionQueryEngine', 'BaseQueryEngine', 'QueryEngine',
34
110
  ];
35
- for (const className of queryEngineClasses) {
36
- const QueryEngineClass = moduleExports[className];
37
- if (QueryEngineClass?.prototype?.query) {
38
- if ((0, instrumentation_1.isWrapped)(QueryEngineClass.prototype.query)) {
39
- this._unwrap(QueryEngineClass.prototype, 'query');
40
- }
41
- this._wrap(QueryEngineClass.prototype, 'query', wrapper_1.default._patchQueryEngineQuery(this.tracer));
42
- break; // Only patch the first one found to avoid duplicates
43
- }
44
- }
45
- // Patch chat engines
111
+ this._patchProto(m, queryEngineClasses, 'query', wrapper_1.default._patchQueryEngineQuery(tracer));
112
+ // === CHAT ENGINE OPERATIONS (invoke_workflow spans) ===
46
113
  const chatEngineClasses = [
47
- 'ContextChatEngine',
48
- 'SimpleChatEngine',
49
- 'BaseChatEngine',
114
+ 'ContextChatEngine', 'SimpleChatEngine',
115
+ 'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
50
116
  ];
51
- for (const className of chatEngineClasses) {
52
- const ChatEngineClass = moduleExports[className];
53
- if (ChatEngineClass?.prototype?.chat) {
54
- if ((0, instrumentation_1.isWrapped)(ChatEngineClass.prototype.chat)) {
55
- this._unwrap(ChatEngineClass.prototype, 'chat');
56
- }
57
- this._wrap(ChatEngineClass.prototype, 'chat', wrapper_1.default._patchChatEngineChat(this.tracer));
58
- break; // Only patch the first one found
59
- }
60
- }
61
- // Patch base LLM chat and complete methods for lower-level tracing
62
- const llmClasses = ['OpenAI', 'Anthropic', 'Ollama', 'LLM', 'BaseLLM'];
63
- for (const className of llmClasses) {
64
- const LLMClass = moduleExports[className];
65
- if (!LLMClass?.prototype)
66
- continue;
67
- if (LLMClass.prototype.chat && !(0, instrumentation_1.isWrapped)(LLMClass.prototype.chat)) {
68
- this._wrap(LLMClass.prototype, 'chat', wrapper_1.default._patchLLMChat(this.tracer));
69
- }
70
- if (LLMClass.prototype.complete && !(0, instrumentation_1.isWrapped)(LLMClass.prototype.complete)) {
71
- this._wrap(LLMClass.prototype, 'complete', wrapper_1.default._patchLLMComplete(this.tracer));
117
+ this._patchProto(m, chatEngineClasses, 'chat', wrapper_1.default._patchChatEngineChat(tracer));
118
+ // === RETRIEVER OPERATIONS (retrieval spans) ===
119
+ // Mirrors Python: VectorIndexRetriever.retrieve, BaseRetriever.retrieve
120
+ const retrieverClasses = [
121
+ 'VectorIndexRetriever', 'BaseRetriever', 'Retriever',
122
+ ];
123
+ this._patchProto(m, retrieverClasses, 'retrieve', wrapper_1.default._patchRetrieverRetrieve(tracer));
124
+ // === EMBEDDING OPERATIONS (embeddings spans) ===
125
+ // Mirrors Python: BaseEmbedding.get_text_embedding_batch
126
+ const embeddingClasses = [
127
+ 'OpenAIEmbedding', 'BaseEmbedding', 'HuggingFaceEmbedding',
128
+ ];
129
+ this._patchProto(m, embeddingClasses, 'getTextEmbedding', wrapper_1.default._patchEmbedding(tracer, 'embedding_generate'));
130
+ this._patchProto(m, embeddingClasses, 'getQueryEmbedding', wrapper_1.default._patchEmbedding(tracer, 'embedding_generate'));
131
+ this._patchProto(m, embeddingClasses, 'getTextEmbeddingsBatch', wrapper_1.default._patchEmbedding(tracer, 'embedding_generate'));
132
+ // === INDEX OPERATIONS (invoke_workflow spans) ===
133
+ // Mirrors Python: VectorStoreIndex.from_documents, from_vector_store
134
+ const indexClasses = ['VectorStoreIndex', 'ListIndex', 'TreeIndex'];
135
+ for (const name of indexClasses) {
136
+ const Cls = m[name];
137
+ if (Cls) {
138
+ this._patchStatic(Cls, 'fromDocuments', wrapper_1.default._patchFrameworkMethod(tracer, 'index_construct'));
139
+ this._patchStatic(Cls, 'fromVectorStore', wrapper_1.default._patchFrameworkMethod(tracer, 'index_construct'));
72
140
  }
73
141
  }
142
+ // Mirrors Python: BaseIndex.as_query_engine, BaseIndex.as_retriever
143
+ const indexProtoClasses = [
144
+ 'VectorStoreIndex', 'ListIndex', 'TreeIndex', 'BaseIndex',
145
+ ];
146
+ this._patchProto(m, indexProtoClasses, 'asQueryEngine', wrapper_1.default._patchFrameworkMethod(tracer, 'query_engine_create'));
147
+ this._patchProto(m, indexProtoClasses, 'asRetriever', wrapper_1.default._patchFrameworkMethod(tracer, 'retriever_create'));
148
+ // === DOCUMENT OPERATIONS (framework / retrieval spans) ===
149
+ // Mirrors Python: SimpleDirectoryReader.load_data
150
+ this._patchProto(m, ['SimpleDirectoryReader'], 'loadData', wrapper_1.default._patchFrameworkMethod(tracer, 'document_load'));
151
+ // Mirrors Python: SentenceSplitter.get_nodes_from_documents
152
+ this._patchProto(m, ['SentenceSplitter', 'NodeParser'], 'getNodesFromDocuments', wrapper_1.default._patchFrameworkMethod(tracer, 'document_split'));
153
+ // Mirrors Python: SentenceSplitter.split_text
154
+ this._patchProto(m, ['SentenceSplitter'], 'splitText', wrapper_1.default._patchFrameworkMethod(tracer, 'text_splitter_split'));
155
+ // === SYNTHESIZER OPERATIONS (chat spans) ===
156
+ // Mirrors Python: BaseSynthesizer.synthesize
157
+ const synthesizerClasses = [
158
+ 'ResponseSynthesizer', 'CompactAndRefine', 'TreeSummarize',
159
+ 'BaseSynthesizer',
160
+ ];
161
+ this._patchProto(m, synthesizerClasses, 'synthesize', wrapper_1.default._patchFrameworkMethod(tracer, 'response_synthesize'));
162
+ // === POSTPROCESSOR OPERATIONS (framework spans) ===
163
+ this._patchProto(m, ['BaseNodePostprocessor', 'NodePostprocessor'], 'postprocessNodes', wrapper_1.default._patchFrameworkMethod(tracer, 'postprocessor_process'));
74
164
  }
75
- catch (e) {
76
- console.error('Error in LlamaIndex _patch method:', e);
77
- }
165
+ catch { /* graceful degradation — do not break the application */ }
78
166
  }
79
- _unpatch(moduleExports) {
167
+ // ---------------------------------------------------------------------------
168
+ // Unpatch
169
+ // ---------------------------------------------------------------------------
170
+ _unpatch(m) {
80
171
  try {
81
- const allClasses = [
82
- 'RetrieverQueryEngine', 'BaseQueryEngine', 'QueryEngine',
83
- 'ContextChatEngine', 'SimpleChatEngine', 'BaseChatEngine',
84
- 'OpenAI', 'Anthropic', 'Ollama', 'LLM', 'BaseLLM',
172
+ const llmClasses = [
173
+ 'OpenAI', 'Anthropic', 'Ollama', 'Gemini', 'Groq',
174
+ 'HuggingFaceInference', 'Replicate', 'DeepSeek', 'Portkey',
175
+ 'BaseLLM', 'LLM',
176
+ ];
177
+ this._unwrapProto(m, llmClasses, 'chat');
178
+ this._unwrapProto(m, llmClasses, 'complete');
179
+ const queryEngineClasses = [
180
+ 'RetrieverQueryEngine', 'TransformQueryEngine',
181
+ 'SubQuestionQueryEngine', 'BaseQueryEngine', 'QueryEngine',
85
182
  ];
86
- for (const className of allClasses) {
87
- const Cls = moduleExports[className];
88
- if (Cls?.prototype) {
89
- if ((0, instrumentation_1.isWrapped)(Cls.prototype.query))
90
- this._unwrap(Cls.prototype, 'query');
91
- if ((0, instrumentation_1.isWrapped)(Cls.prototype.chat))
92
- this._unwrap(Cls.prototype, 'chat');
93
- if ((0, instrumentation_1.isWrapped)(Cls.prototype.complete))
94
- this._unwrap(Cls.prototype, 'complete');
183
+ this._unwrapProto(m, queryEngineClasses, 'query');
184
+ const chatEngineClasses = [
185
+ 'ContextChatEngine', 'SimpleChatEngine',
186
+ 'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
187
+ ];
188
+ this._unwrapProto(m, chatEngineClasses, 'chat');
189
+ const retrieverClasses = ['VectorIndexRetriever', 'BaseRetriever', 'Retriever'];
190
+ this._unwrapProto(m, retrieverClasses, 'retrieve');
191
+ const embeddingClasses = ['OpenAIEmbedding', 'BaseEmbedding', 'HuggingFaceEmbedding'];
192
+ this._unwrapProto(m, embeddingClasses, 'getTextEmbedding');
193
+ this._unwrapProto(m, embeddingClasses, 'getQueryEmbedding');
194
+ this._unwrapProto(m, embeddingClasses, 'getTextEmbeddingsBatch');
195
+ const indexClasses = ['VectorStoreIndex', 'ListIndex', 'TreeIndex'];
196
+ for (const name of indexClasses) {
197
+ const Cls = m[name];
198
+ if (Cls) {
199
+ this._unwrapStatic(Cls, 'fromDocuments');
200
+ this._unwrapStatic(Cls, 'fromVectorStore');
95
201
  }
96
202
  }
203
+ const indexProtoClasses = [
204
+ 'VectorStoreIndex', 'ListIndex', 'TreeIndex', 'BaseIndex',
205
+ ];
206
+ this._unwrapProto(m, indexProtoClasses, 'asQueryEngine');
207
+ this._unwrapProto(m, indexProtoClasses, 'asRetriever');
208
+ this._unwrapProto(m, ['SimpleDirectoryReader'], 'loadData');
209
+ this._unwrapProto(m, ['SentenceSplitter', 'NodeParser'], 'getNodesFromDocuments');
210
+ this._unwrapProto(m, ['SentenceSplitter'], 'splitText');
211
+ const synthesizerClasses = [
212
+ 'ResponseSynthesizer', 'CompactAndRefine', 'TreeSummarize', 'BaseSynthesizer',
213
+ ];
214
+ this._unwrapProto(m, synthesizerClasses, 'synthesize');
215
+ this._unwrapProto(m, ['BaseNodePostprocessor', 'NodePostprocessor'], 'postprocessNodes');
97
216
  }
98
217
  catch { /* ignore */ }
99
218
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/llamaindex/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAKwC;AAExC,6CAAwD;AACxD,wDAA0C;AAI1C,MAAqB,gCAAiC,SAAQ,qCAAmB;IAC/E,YAAY,SAA0C,EAAE;QACtD,KAAK,CAAC,GAAG,iCAAsB,6BAA6B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjF,CAAC;IAES,IAAI;QACZ,MAAM,MAAM,GAAG,IAAI,qDAAmC,CACpD,YAAY,EACZ,CAAC,SAAS,CAAC,EACX,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC3B,OAAO,aAAa,CAAC;QACvB,CAAC,EACD,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CACF,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAEM,WAAW,CAAC,UAAe;Q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BACxB,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW;aAC1D,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;YACzD,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAEvD,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,EAAE,UAAU,CAAC,CAAC;YAC5D,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC,EAAE,uBAAuB,CAAC,CAAC;YAClF,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,CAAC;YAExD,MAAM,kBAAkB,GAAG;gBACzB,qBAAqB,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB;aAC9E,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;YAEvD,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,EAAE,kBAAkB,CAAC,CAAC;QAC3F,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;CACF;AAzQD,mDAyQC"}
@@ -1,11 +1,23 @@
1
+ /**
2
+ * OpenLIT LlamaIndex Wrapper
3
+ *
4
+ * Mirrors Python SDK: sdk/python/src/openlit/instrumentation/llamaindex/
5
+ * Uses the same OPERATION_MAP and span semantics as the Python implementation.
6
+ *
7
+ * LLM operations get full provider-style telemetry (attributes, events, metrics).
8
+ * Framework operations (query engine, retriever, index, etc.) get framework-level spans.
9
+ */
1
10
  import { Tracer } from '@opentelemetry/api';
2
- import BaseWrapper from '../base-wrapper';
3
- declare class LlamaIndexWrapper extends BaseWrapper {
11
+ export default class LlamaIndexWrapper {
4
12
  static aiSystem: string;
13
+ private static _extractModel;
5
14
  private static _extractServerInfo;
6
15
  static _patchLLMChat(tracer: Tracer): any;
7
16
  static _patchLLMComplete(tracer: Tracer): any;
17
+ private static _processLLMResponse;
8
18
  static _patchQueryEngineQuery(tracer: Tracer): any;
9
19
  static _patchChatEngineChat(tracer: Tracer): any;
20
+ static _patchRetrieverRetrieve(tracer: Tracer): any;
21
+ static _patchEmbedding(tracer: Tracer, endpoint?: string): any;
22
+ static _patchFrameworkMethod(tracer: Tracer, endpoint: string): any;
10
23
  }
11
- export default LlamaIndexWrapper;