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.
- package/README.md +35 -1
- package/dist/config.d.ts +12 -4
- package/dist/config.js +7 -17
- package/dist/config.js.map +1 -1
- package/dist/evals/llm/anthropic.js +10 -6
- package/dist/evals/llm/anthropic.js.map +1 -1
- package/dist/evals/llm/openai.js +9 -5
- package/dist/evals/llm/openai.js.map +1 -1
- package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
- package/dist/features/__tests__/rule-engine.test.js +146 -0
- package/dist/features/__tests__/rule-engine.test.js.map +1 -0
- package/dist/features/base.d.ts +2 -0
- package/dist/features/base.js +2 -0
- package/dist/features/base.js.map +1 -1
- package/dist/features/rule-engine.d.ts +6 -0
- package/dist/features/rule-engine.js +60 -0
- package/dist/features/rule-engine.js.map +1 -0
- package/dist/features/vault.js +1 -1
- package/dist/features/vault.js.map +1 -1
- package/dist/helpers.d.ts +93 -1
- package/dist/helpers.js +270 -8
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +95 -50
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +215 -27
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -1
- package/dist/instrumentation/__tests__/base-wrapper.test.js +19 -23
- package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -1
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +1 -1
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js +150 -25
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -1
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +152 -33
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +391 -45
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +2 -2
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +323 -31
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +1 -1
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +0 -3
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +275 -68
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/openai-wrapper.test.js +7 -9
- package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -1
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +1 -1
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +2 -1
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +209 -21
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js +231 -51
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -1
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/anthropic/index.d.ts +2 -3
- package/dist/instrumentation/anthropic/index.js.map +1 -1
- package/dist/instrumentation/anthropic/wrapper.d.ts +1 -3
- package/dist/instrumentation/anthropic/wrapper.js +211 -91
- package/dist/instrumentation/anthropic/wrapper.js.map +1 -1
- package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
- package/dist/instrumentation/azure-ai-inference/index.js +76 -0
- package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +42 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js +515 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
- package/dist/instrumentation/base-wrapper.d.ts +2 -1
- package/dist/instrumentation/base-wrapper.js +35 -23
- package/dist/instrumentation/base-wrapper.js.map +1 -1
- package/dist/instrumentation/bedrock/wrapper.d.ts +21 -3
- package/dist/instrumentation/bedrock/wrapper.js +318 -265
- package/dist/instrumentation/bedrock/wrapper.js.map +1 -1
- package/dist/instrumentation/chroma/wrapper.js +1 -1
- package/dist/instrumentation/chroma/wrapper.js.map +1 -1
- package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
- package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
- package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js +1031 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/cohere/index.d.ts +2 -3
- package/dist/instrumentation/cohere/index.js.map +1 -1
- package/dist/instrumentation/cohere/wrapper.d.ts +1 -1
- package/dist/instrumentation/cohere/wrapper.js +215 -56
- package/dist/instrumentation/cohere/wrapper.js.map +1 -1
- package/dist/instrumentation/google-adk/index.d.ts +57 -0
- package/dist/instrumentation/google-adk/index.js +371 -0
- package/dist/instrumentation/google-adk/index.js.map +1 -0
- package/dist/instrumentation/google-adk/utils.d.ts +45 -0
- package/dist/instrumentation/google-adk/utils.js +663 -0
- package/dist/instrumentation/google-adk/utils.js.map +1 -0
- package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
- package/dist/instrumentation/google-adk/wrapper.js +391 -0
- package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
- package/dist/instrumentation/google-ai/wrapper.d.ts +7 -4
- package/dist/instrumentation/google-ai/wrapper.js +197 -61
- package/dist/instrumentation/google-ai/wrapper.js.map +1 -1
- package/dist/instrumentation/groq/wrapper.js +137 -65
- package/dist/instrumentation/groq/wrapper.js.map +1 -1
- package/dist/instrumentation/huggingface/wrapper.js +241 -39
- package/dist/instrumentation/huggingface/wrapper.js.map +1 -1
- package/dist/instrumentation/index.d.ts +2 -2
- package/dist/instrumentation/index.js +64 -6
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/instrumentation/langchain/index.d.ts +0 -7
- package/dist/instrumentation/langchain/index.js +2 -20
- package/dist/instrumentation/langchain/index.js.map +1 -1
- package/dist/instrumentation/langchain/wrapper.d.ts +35 -0
- package/dist/instrumentation/langchain/wrapper.js +1098 -184
- package/dist/instrumentation/langchain/wrapper.js.map +1 -1
- package/dist/instrumentation/langgraph/index.d.ts +12 -0
- package/dist/instrumentation/langgraph/index.js +99 -0
- package/dist/instrumentation/langgraph/index.js.map +1 -0
- package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
- package/dist/instrumentation/langgraph/wrapper.js +619 -0
- package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
- package/dist/instrumentation/llamaindex/index.d.ts +31 -6
- package/dist/instrumentation/llamaindex/index.js +180 -61
- package/dist/instrumentation/llamaindex/index.js.map +1 -1
- package/dist/instrumentation/llamaindex/wrapper.d.ts +15 -3
- package/dist/instrumentation/llamaindex/wrapper.js +670 -179
- package/dist/instrumentation/llamaindex/wrapper.js.map +1 -1
- package/dist/instrumentation/milvus/wrapper.js +1 -1
- package/dist/instrumentation/milvus/wrapper.js.map +1 -1
- package/dist/instrumentation/mistral/wrapper.js +154 -79
- package/dist/instrumentation/mistral/wrapper.js.map +1 -1
- package/dist/instrumentation/ollama/index.js +33 -4
- package/dist/instrumentation/ollama/index.js.map +1 -1
- package/dist/instrumentation/ollama/wrapper.d.ts +28 -2
- package/dist/instrumentation/ollama/wrapper.js +432 -48
- package/dist/instrumentation/ollama/wrapper.js.map +1 -1
- package/dist/instrumentation/openai/index.d.ts +2 -3
- package/dist/instrumentation/openai/index.js.map +1 -1
- package/dist/instrumentation/openai/wrapper.js +293 -194
- package/dist/instrumentation/openai/wrapper.js.map +1 -1
- package/dist/instrumentation/openai-agents/index.d.ts +20 -0
- package/dist/instrumentation/openai-agents/index.js +174 -0
- package/dist/instrumentation/openai-agents/index.js.map +1 -0
- package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
- package/dist/instrumentation/openai-agents/processor.js +249 -0
- package/dist/instrumentation/openai-agents/processor.js.map +1 -0
- package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
- package/dist/instrumentation/openai-agents/utils.js +624 -0
- package/dist/instrumentation/openai-agents/utils.js.map +1 -0
- package/dist/instrumentation/pinecone/wrapper.js +2 -2
- package/dist/instrumentation/pinecone/wrapper.js.map +1 -1
- package/dist/instrumentation/qdrant/wrapper.js +1 -1
- package/dist/instrumentation/qdrant/wrapper.js.map +1 -1
- package/dist/instrumentation/replicate/wrapper.js +103 -21
- package/dist/instrumentation/replicate/wrapper.js.map +1 -1
- package/dist/instrumentation/strands/index.d.ts +21 -0
- package/dist/instrumentation/strands/index.js +83 -0
- package/dist/instrumentation/strands/index.js.map +1 -0
- package/dist/instrumentation/strands/processor.d.ts +45 -0
- package/dist/instrumentation/strands/processor.js +545 -0
- package/dist/instrumentation/strands/processor.js.map +1 -0
- package/dist/instrumentation/strands/utils.d.ts +24 -0
- package/dist/instrumentation/strands/utils.js +360 -0
- package/dist/instrumentation/strands/utils.js.map +1 -0
- package/dist/instrumentation/together/wrapper.js +125 -51
- package/dist/instrumentation/together/wrapper.js.map +1 -1
- package/dist/instrumentation/vercel-ai/wrapper.d.ts +28 -2
- package/dist/instrumentation/vercel-ai/wrapper.js +314 -164
- package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -1
- package/dist/llm/anthropic.js +10 -6
- package/dist/llm/anthropic.js.map +1 -1
- package/dist/llm/openai.js +9 -5
- package/dist/llm/openai.js.map +1 -1
- package/dist/otel/__tests__/metrics.test.js +16 -27
- package/dist/otel/__tests__/metrics.test.js.map +1 -1
- package/dist/otel/events.d.ts +11 -0
- package/dist/otel/events.js +74 -0
- package/dist/otel/events.js.map +1 -0
- package/dist/otel/metrics.d.ts +5 -6
- package/dist/otel/metrics.js +66 -48
- package/dist/otel/metrics.js.map +1 -1
- package/dist/otel/tracing.d.ts +6 -2
- package/dist/otel/tracing.js +71 -24
- package/dist/otel/tracing.js.map +1 -1
- package/dist/otel/utils.d.ts +11 -0
- package/dist/otel/utils.js +34 -0
- package/dist/otel/utils.js.map +1 -0
- package/dist/semantic-convention.d.ts +44 -5
- package/dist/semantic-convention.js +51 -8
- package/dist/semantic-convention.js.map +1 -1
- package/dist/types.d.ts +74 -22
- 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?:
|
|
14
|
+
constructor(config?: InstrumentationConfig);
|
|
7
15
|
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
8
16
|
manualPatch(llamaindex: any): void;
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
28
|
+
if (moduleExports)
|
|
19
29
|
this._unpatch(moduleExports);
|
|
20
|
-
}
|
|
21
30
|
});
|
|
22
|
-
return [
|
|
31
|
+
return [mainModule];
|
|
23
32
|
}
|
|
24
33
|
manualPatch(llamaindex) {
|
|
25
34
|
this._patch(llamaindex);
|
|
26
35
|
}
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
'
|
|
49
|
-
'BaseChatEngine',
|
|
114
|
+
'ContextChatEngine', 'SimpleChatEngine',
|
|
115
|
+
'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
|
|
50
116
|
];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
76
|
-
console.error('Error in LlamaIndex _patch method:', e);
|
|
77
|
-
}
|
|
165
|
+
catch { /* graceful degradation — do not break the application */ }
|
|
78
166
|
}
|
|
79
|
-
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
// Unpatch
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
_unpatch(m) {
|
|
80
171
|
try {
|
|
81
|
-
const
|
|
82
|
-
'
|
|
83
|
-
'
|
|
84
|
-
'
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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":";;;;;
|
|
1
|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,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
|
-
|
|
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;
|