monocle-apptrace 0.1.1__py3-none-any.whl → 0.3.0__py3-none-any.whl
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.
Potentially problematic release.
This version of monocle-apptrace might be problematic. Click here for more details.
- monocle_apptrace/__init__.py +1 -0
- monocle_apptrace/__main__.py +19 -0
- monocle_apptrace/exporters/aws/s3_exporter.py +181 -0
- monocle_apptrace/exporters/aws/s3_exporter_opendal.py +137 -0
- monocle_apptrace/exporters/azure/blob_exporter.py +146 -0
- monocle_apptrace/exporters/azure/blob_exporter_opendal.py +162 -0
- monocle_apptrace/exporters/base_exporter.py +48 -0
- monocle_apptrace/exporters/exporter_processor.py +144 -0
- monocle_apptrace/exporters/file_exporter.py +16 -0
- monocle_apptrace/exporters/monocle_exporters.py +55 -0
- monocle_apptrace/exporters/okahu/okahu_exporter.py +117 -0
- monocle_apptrace/instrumentation/__init__.py +1 -0
- monocle_apptrace/instrumentation/common/__init__.py +2 -0
- monocle_apptrace/instrumentation/common/constants.py +70 -0
- monocle_apptrace/instrumentation/common/instrumentor.py +362 -0
- monocle_apptrace/instrumentation/common/span_handler.py +220 -0
- monocle_apptrace/instrumentation/common/utils.py +356 -0
- monocle_apptrace/instrumentation/common/wrapper.py +92 -0
- monocle_apptrace/instrumentation/common/wrapper_method.py +72 -0
- monocle_apptrace/instrumentation/metamodel/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/botocore/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/botocore/_helper.py +95 -0
- monocle_apptrace/instrumentation/metamodel/botocore/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py +65 -0
- monocle_apptrace/instrumentation/metamodel/botocore/handlers/botocore_span_handler.py +26 -0
- monocle_apptrace/instrumentation/metamodel/botocore/methods.py +16 -0
- monocle_apptrace/instrumentation/metamodel/flask/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/flask/_helper.py +29 -0
- monocle_apptrace/instrumentation/metamodel/flask/methods.py +13 -0
- monocle_apptrace/instrumentation/metamodel/haystack/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/haystack/_helper.py +127 -0
- monocle_apptrace/instrumentation/metamodel/haystack/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/haystack/entities/inference.py +76 -0
- monocle_apptrace/instrumentation/metamodel/haystack/entities/retrieval.py +61 -0
- monocle_apptrace/instrumentation/metamodel/haystack/methods.py +43 -0
- monocle_apptrace/instrumentation/metamodel/langchain/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/langchain/_helper.py +127 -0
- monocle_apptrace/instrumentation/metamodel/langchain/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/langchain/entities/inference.py +72 -0
- monocle_apptrace/instrumentation/metamodel/langchain/entities/retrieval.py +58 -0
- monocle_apptrace/{metamodel/maps/lang_chain_methods.json → instrumentation/metamodel/langchain/methods.py} +48 -43
- monocle_apptrace/instrumentation/metamodel/langgraph/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/langgraph/_helper.py +48 -0
- monocle_apptrace/instrumentation/metamodel/langgraph/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/langgraph/entities/inference.py +56 -0
- monocle_apptrace/instrumentation/metamodel/langgraph/methods.py +14 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/_helper.py +172 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/agent.py +47 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/inference.py +73 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/retrieval.py +57 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/methods.py +101 -0
- monocle_apptrace/instrumentation/metamodel/openai/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/openai/_helper.py +112 -0
- monocle_apptrace/instrumentation/metamodel/openai/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/openai/entities/inference.py +71 -0
- monocle_apptrace/instrumentation/metamodel/openai/entities/retrieval.py +43 -0
- monocle_apptrace/instrumentation/metamodel/openai/methods.py +45 -0
- monocle_apptrace/instrumentation/metamodel/requests/__init__.py +4 -0
- monocle_apptrace/instrumentation/metamodel/requests/_helper.py +31 -0
- monocle_apptrace/instrumentation/metamodel/requests/methods.py +12 -0
- {monocle_apptrace-0.1.1.dist-info → monocle_apptrace-0.3.0.dist-info}/METADATA +23 -2
- monocle_apptrace-0.3.0.dist-info/RECORD +68 -0
- {monocle_apptrace-0.1.1.dist-info → monocle_apptrace-0.3.0.dist-info}/WHEEL +1 -1
- monocle_apptrace/constants.py +0 -22
- monocle_apptrace/haystack/__init__.py +0 -9
- monocle_apptrace/haystack/wrap_node.py +0 -27
- monocle_apptrace/haystack/wrap_openai.py +0 -44
- monocle_apptrace/haystack/wrap_pipeline.py +0 -62
- monocle_apptrace/instrumentor.py +0 -124
- monocle_apptrace/langchain/__init__.py +0 -6
- monocle_apptrace/llamaindex/__init__.py +0 -15
- monocle_apptrace/metamodel/README.md +0 -47
- monocle_apptrace/metamodel/entities/README.md +0 -54
- monocle_apptrace/metamodel/entities/entity_types.json +0 -157
- monocle_apptrace/metamodel/entities/entity_types.py +0 -51
- monocle_apptrace/metamodel/maps/haystack_methods.json +0 -25
- monocle_apptrace/metamodel/maps/llama_index_methods.json +0 -70
- monocle_apptrace/metamodel/spans/README.md +0 -121
- monocle_apptrace/metamodel/spans/span_example.json +0 -140
- monocle_apptrace/metamodel/spans/span_format.json +0 -55
- monocle_apptrace/utils.py +0 -93
- monocle_apptrace/wrap_common.py +0 -311
- monocle_apptrace/wrapper.py +0 -24
- monocle_apptrace-0.1.1.dist-info/RECORD +0 -29
- {monocle_apptrace-0.1.1.dist-info → monocle_apptrace-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {monocle_apptrace-0.1.1.dist-info → monocle_apptrace-0.3.0.dist-info}/licenses/NOTICE +0 -0
monocle_apptrace/wrap_common.py
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
#pylint: disable=protected-access
|
|
2
|
-
import logging
|
|
3
|
-
import os
|
|
4
|
-
from urllib.parse import urlparse
|
|
5
|
-
|
|
6
|
-
from opentelemetry.trace import Span, Tracer
|
|
7
|
-
from monocle_apptrace.utils import resolve_from_alias, update_span_with_infra_name, with_tracer_wrapper, get_embedding_model
|
|
8
|
-
|
|
9
|
-
logger = logging.getLogger(__name__)
|
|
10
|
-
WORKFLOW_TYPE_KEY = "workflow_type"
|
|
11
|
-
CONTEXT_INPUT_KEY = "context_input"
|
|
12
|
-
CONTEXT_OUTPUT_KEY = "context_output"
|
|
13
|
-
PROMPT_INPUT_KEY = "input"
|
|
14
|
-
PROMPT_OUTPUT_KEY = "output"
|
|
15
|
-
QUERY = "question"
|
|
16
|
-
RESPONSE = "response"
|
|
17
|
-
TAGS = "tags"
|
|
18
|
-
SESSION_PROPERTIES_KEY = "session"
|
|
19
|
-
INFRA_SERVICE_KEY = "infra_service_name"
|
|
20
|
-
TYPE = "type"
|
|
21
|
-
PROVIDER = "provider_name"
|
|
22
|
-
EMBEDDING_MODEL = "embedding_model"
|
|
23
|
-
VECTOR_STORE = 'vector_store'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
WORKFLOW_TYPE_MAP = {
|
|
27
|
-
"llama_index": "workflow.llamaindex",
|
|
28
|
-
"langchain": "workflow.langchain",
|
|
29
|
-
"haystack": "workflow.haystack"
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
framework_vector_store_mapping = {
|
|
33
|
-
'langchain_core.retrievers': lambda instance: {
|
|
34
|
-
'provider': instance.tags[0],
|
|
35
|
-
'embedding_model': instance.tags[1],
|
|
36
|
-
'type': VECTOR_STORE,
|
|
37
|
-
},
|
|
38
|
-
'llama_index.core.indices.base_retriever': lambda instance: {
|
|
39
|
-
'provider': type(instance._vector_store).__name__,
|
|
40
|
-
'embedding_model': instance._embed_model.model_name,
|
|
41
|
-
'type': VECTOR_STORE,
|
|
42
|
-
},
|
|
43
|
-
'haystack.components.retrievers': lambda instance: {
|
|
44
|
-
'provider': instance.__dict__.get("document_store").__class__.__name__,
|
|
45
|
-
'embedding_model': get_embedding_model(),
|
|
46
|
-
'type': VECTOR_STORE,
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@with_tracer_wrapper
|
|
51
|
-
def task_wrapper(tracer: Tracer, to_wrap, wrapped, instance, args, kwargs):
|
|
52
|
-
"""Instruments and calls every function defined in TO_WRAP."""
|
|
53
|
-
|
|
54
|
-
# Some Langchain objects are wrapped elsewhere, so we ignore them here
|
|
55
|
-
if instance.__class__.__name__ in ("AgentExecutor"):
|
|
56
|
-
return wrapped(*args, **kwargs)
|
|
57
|
-
|
|
58
|
-
if hasattr(instance, "name") and instance.name:
|
|
59
|
-
name = f"{to_wrap.get('span_name')}.{instance.name.lower()}"
|
|
60
|
-
elif to_wrap.get("span_name"):
|
|
61
|
-
name = to_wrap.get("span_name")
|
|
62
|
-
else:
|
|
63
|
-
name = f"langchain.task.{instance.__class__.__name__}"
|
|
64
|
-
|
|
65
|
-
with tracer.start_as_current_span(name) as span:
|
|
66
|
-
pre_task_processing(to_wrap, instance, args, span)
|
|
67
|
-
return_value = wrapped(*args, **kwargs)
|
|
68
|
-
post_task_processing(to_wrap, span, return_value)
|
|
69
|
-
|
|
70
|
-
return return_value
|
|
71
|
-
|
|
72
|
-
def post_task_processing(to_wrap, span, return_value):
|
|
73
|
-
update_span_with_context_output(to_wrap=to_wrap, return_value=return_value, span=span)
|
|
74
|
-
|
|
75
|
-
if is_root_span(span):
|
|
76
|
-
workflow_name = span.resource.attributes.get("service.name")
|
|
77
|
-
span.set_attribute("workflow_name",workflow_name)
|
|
78
|
-
update_span_with_prompt_output(to_wrap=to_wrap, wrapped_args=return_value, span=span)
|
|
79
|
-
update_workflow_type(to_wrap, span)
|
|
80
|
-
|
|
81
|
-
def pre_task_processing(to_wrap, instance, args, span):
|
|
82
|
-
if is_root_span(span):
|
|
83
|
-
update_span_with_prompt_input(to_wrap=to_wrap, wrapped_args=args, span=span)
|
|
84
|
-
|
|
85
|
-
update_span_with_infra_name(span, INFRA_SERVICE_KEY)
|
|
86
|
-
|
|
87
|
-
#capture the tags attribute of the instance if present, else ignore
|
|
88
|
-
try:
|
|
89
|
-
update_tags(instance, span)
|
|
90
|
-
update_vectorstore_attributes(to_wrap, instance, span)
|
|
91
|
-
except AttributeError:
|
|
92
|
-
pass
|
|
93
|
-
update_span_with_context_input(to_wrap=to_wrap, wrapped_args=args, span=span)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
@with_tracer_wrapper
|
|
98
|
-
async def atask_wrapper(tracer, to_wrap, wrapped, instance, args, kwargs):
|
|
99
|
-
"""Instruments and calls every function defined in TO_WRAP."""
|
|
100
|
-
|
|
101
|
-
# Some Langchain objects are wrapped elsewhere, so we ignore them here
|
|
102
|
-
if instance.__class__.__name__ in ("AgentExecutor"):
|
|
103
|
-
return wrapped(*args, **kwargs)
|
|
104
|
-
|
|
105
|
-
if hasattr(instance, "name") and instance.name:
|
|
106
|
-
name = f"{to_wrap.get('span_name')}.{instance.name.lower()}"
|
|
107
|
-
elif to_wrap.get("span_name"):
|
|
108
|
-
name = to_wrap.get("span_name")
|
|
109
|
-
else:
|
|
110
|
-
name = f"langchain.task.{instance.__class__.__name__}"
|
|
111
|
-
with tracer.start_as_current_span(name) as span:
|
|
112
|
-
pre_task_processing(to_wrap, instance, args, span)
|
|
113
|
-
return_value = await wrapped(*args, **kwargs)
|
|
114
|
-
post_task_processing(to_wrap, span, return_value)
|
|
115
|
-
|
|
116
|
-
return return_value
|
|
117
|
-
|
|
118
|
-
@with_tracer_wrapper
|
|
119
|
-
async def allm_wrapper(tracer, to_wrap, wrapped, instance, args, kwargs):
|
|
120
|
-
# Some Langchain objects are wrapped elsewhere, so we ignore them here
|
|
121
|
-
if instance.__class__.__name__ in ("AgentExecutor"):
|
|
122
|
-
return wrapped(*args, **kwargs)
|
|
123
|
-
|
|
124
|
-
if callable(to_wrap.get("span_name_getter")):
|
|
125
|
-
name = to_wrap.get("span_name_getter")(instance)
|
|
126
|
-
|
|
127
|
-
elif hasattr(instance, "name") and instance.name:
|
|
128
|
-
name = f"{to_wrap.get('span_name')}.{instance.name.lower()}"
|
|
129
|
-
elif to_wrap.get("span_name"):
|
|
130
|
-
name = to_wrap.get("span_name")
|
|
131
|
-
else:
|
|
132
|
-
name = f"langchain.task.{instance.__class__.__name__}"
|
|
133
|
-
with tracer.start_as_current_span(name) as span:
|
|
134
|
-
update_llm_endpoint(curr_span= span, instance=instance)
|
|
135
|
-
|
|
136
|
-
return_value = await wrapped(*args, **kwargs)
|
|
137
|
-
update_span_from_llm_response(response = return_value, span = span)
|
|
138
|
-
|
|
139
|
-
return return_value
|
|
140
|
-
|
|
141
|
-
@with_tracer_wrapper
|
|
142
|
-
def llm_wrapper(tracer: Tracer, to_wrap, wrapped, instance, args, kwargs):
|
|
143
|
-
|
|
144
|
-
# Some Langchain objects are wrapped elsewhere, so we ignore them here
|
|
145
|
-
if instance.__class__.__name__ in ("AgentExecutor"):
|
|
146
|
-
return wrapped(*args, **kwargs)
|
|
147
|
-
|
|
148
|
-
if callable(to_wrap.get("span_name_getter")):
|
|
149
|
-
name = to_wrap.get("span_name_getter")(instance)
|
|
150
|
-
|
|
151
|
-
elif hasattr(instance, "name") and instance.name:
|
|
152
|
-
name = f"{to_wrap.get('span_name')}.{instance.name.lower()}"
|
|
153
|
-
elif to_wrap.get("span_name"):
|
|
154
|
-
name = to_wrap.get("span_name")
|
|
155
|
-
else:
|
|
156
|
-
name = f"langchain.task.{instance.__class__.__name__}"
|
|
157
|
-
with tracer.start_as_current_span(name) as span:
|
|
158
|
-
if 'haystack.components.retrievers' in to_wrap['package'] and 'haystack.retriever' in span.name:
|
|
159
|
-
update_vectorstore_attributes(to_wrap, instance, span)
|
|
160
|
-
update_llm_endpoint(curr_span= span, instance=instance)
|
|
161
|
-
|
|
162
|
-
return_value = wrapped(*args, **kwargs)
|
|
163
|
-
update_span_from_llm_response(response = return_value, span = span)
|
|
164
|
-
|
|
165
|
-
return return_value
|
|
166
|
-
|
|
167
|
-
def update_llm_endpoint(curr_span: Span, instance):
|
|
168
|
-
triton_llm_endpoint = os.environ.get("TRITON_LLM_ENDPOINT")
|
|
169
|
-
if triton_llm_endpoint is not None and len(triton_llm_endpoint) > 0:
|
|
170
|
-
curr_span.set_attribute("server_url", triton_llm_endpoint)
|
|
171
|
-
else:
|
|
172
|
-
if 'temperature' in instance.__dict__:
|
|
173
|
-
temp_val = instance.__dict__.get("temperature")
|
|
174
|
-
curr_span.set_attribute("temperature", temp_val)
|
|
175
|
-
# handling for model name
|
|
176
|
-
model_name = resolve_from_alias(instance.__dict__ , ["model","model_name"])
|
|
177
|
-
curr_span.set_attribute("model_name", model_name)
|
|
178
|
-
set_provider_name(curr_span, instance)
|
|
179
|
-
# handling AzureOpenAI deployment
|
|
180
|
-
deployment_name = resolve_from_alias(instance.__dict__ , [ "engine", "azure_deployment",
|
|
181
|
-
"deployment_name", "deployment_id", "deployment"])
|
|
182
|
-
curr_span.set_attribute("az_openai_deployment", deployment_name)
|
|
183
|
-
# handling the inference endpoint
|
|
184
|
-
inference_ep = resolve_from_alias(instance.__dict__,["azure_endpoint","api_base"])
|
|
185
|
-
curr_span.set_attribute("inference_endpoint",inference_ep)
|
|
186
|
-
|
|
187
|
-
def set_provider_name(curr_span, instance):
|
|
188
|
-
provider_url = ""
|
|
189
|
-
|
|
190
|
-
try :
|
|
191
|
-
if isinstance(instance.client._client.base_url.host, str) :
|
|
192
|
-
provider_url = instance. client._client.base_url.host
|
|
193
|
-
except:
|
|
194
|
-
pass
|
|
195
|
-
|
|
196
|
-
try :
|
|
197
|
-
if isinstance(instance.api_base, str):
|
|
198
|
-
provider_url = instance.api_base
|
|
199
|
-
except:
|
|
200
|
-
pass
|
|
201
|
-
|
|
202
|
-
try :
|
|
203
|
-
if len(provider_url) > 0:
|
|
204
|
-
parsed_provider_url = urlparse(provider_url)
|
|
205
|
-
curr_span.set_attribute("provider_name", parsed_provider_url.hostname or provider_url)
|
|
206
|
-
except:
|
|
207
|
-
pass
|
|
208
|
-
|
|
209
|
-
def is_root_span(curr_span: Span) -> bool:
|
|
210
|
-
return curr_span.parent is None
|
|
211
|
-
|
|
212
|
-
def get_input_from_args(chain_args):
|
|
213
|
-
if len(chain_args) > 0 and isinstance(chain_args[0], str):
|
|
214
|
-
return chain_args[0]
|
|
215
|
-
return ""
|
|
216
|
-
|
|
217
|
-
def update_span_from_llm_response(response, span: Span):
|
|
218
|
-
# extract token uasge from langchain openai
|
|
219
|
-
if (response is not None and hasattr(response, "response_metadata")):
|
|
220
|
-
response_metadata = response.response_metadata
|
|
221
|
-
token_usage = response_metadata.get("token_usage")
|
|
222
|
-
if token_usage is not None:
|
|
223
|
-
span.set_attribute("completion_tokens", token_usage.get("completion_tokens"))
|
|
224
|
-
span.set_attribute("prompt_tokens", token_usage.get("prompt_tokens"))
|
|
225
|
-
span.set_attribute("total_tokens", token_usage.get("total_tokens"))
|
|
226
|
-
# extract token usage from llamaindex openai
|
|
227
|
-
if(response is not None and hasattr(response, "raw")):
|
|
228
|
-
try:
|
|
229
|
-
if response.raw is not None:
|
|
230
|
-
token_usage = response.raw.get("usage") if isinstance(response.raw, dict) else getattr(response.raw, "usage", None)
|
|
231
|
-
if token_usage is not None:
|
|
232
|
-
if getattr(token_usage, "completion_tokens", None):
|
|
233
|
-
span.set_attribute("completion_tokens", getattr(token_usage, "completion_tokens"))
|
|
234
|
-
if getattr(token_usage, "prompt_tokens", None):
|
|
235
|
-
span.set_attribute("prompt_tokens", getattr(token_usage, "prompt_tokens"))
|
|
236
|
-
if getattr(token_usage, "total_tokens", None):
|
|
237
|
-
span.set_attribute("total_tokens", getattr(token_usage, "total_tokens"))
|
|
238
|
-
except AttributeError:
|
|
239
|
-
token_usage = None
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def update_workflow_type(to_wrap, span: Span):
|
|
243
|
-
package_name = to_wrap.get('package')
|
|
244
|
-
|
|
245
|
-
for (package, workflow_type) in WORKFLOW_TYPE_MAP.items():
|
|
246
|
-
if(package_name is not None and package in package_name):
|
|
247
|
-
span.set_attribute(WORKFLOW_TYPE_KEY, workflow_type)
|
|
248
|
-
|
|
249
|
-
def update_span_with_context_input(to_wrap, wrapped_args ,span: Span):
|
|
250
|
-
package_name: str = to_wrap.get('package')
|
|
251
|
-
if "langchain_core.retrievers" in package_name:
|
|
252
|
-
input_arg_text = wrapped_args[0]
|
|
253
|
-
span.add_event(CONTEXT_INPUT_KEY, {QUERY:input_arg_text})
|
|
254
|
-
if "llama_index.core.indices.base_retriever" in package_name:
|
|
255
|
-
input_arg_text = wrapped_args[0].query_str
|
|
256
|
-
span.add_event(CONTEXT_INPUT_KEY, {QUERY:input_arg_text})
|
|
257
|
-
|
|
258
|
-
def update_span_with_context_output(to_wrap, return_value ,span: Span):
|
|
259
|
-
package_name: str = to_wrap.get('package')
|
|
260
|
-
if "llama_index.core.indices.base_retriever" in package_name:
|
|
261
|
-
output_arg_text = return_value[0].text
|
|
262
|
-
span.add_event(CONTEXT_OUTPUT_KEY, {RESPONSE:output_arg_text})
|
|
263
|
-
|
|
264
|
-
def update_span_with_prompt_input(to_wrap, wrapped_args ,span: Span):
|
|
265
|
-
input_arg_text = wrapped_args[0]
|
|
266
|
-
|
|
267
|
-
if isinstance(input_arg_text, dict):
|
|
268
|
-
span.add_event(PROMPT_INPUT_KEY,input_arg_text)
|
|
269
|
-
else:
|
|
270
|
-
span.add_event(PROMPT_INPUT_KEY,{QUERY:input_arg_text})
|
|
271
|
-
|
|
272
|
-
def update_span_with_prompt_output(to_wrap, wrapped_args ,span: Span):
|
|
273
|
-
package_name: str = to_wrap.get('package')
|
|
274
|
-
if isinstance(wrapped_args, str):
|
|
275
|
-
span.add_event(PROMPT_OUTPUT_KEY, {RESPONSE:wrapped_args})
|
|
276
|
-
if "llama_index.core.base.base_query_engine" in package_name:
|
|
277
|
-
span.add_event(PROMPT_OUTPUT_KEY, {RESPONSE:wrapped_args.response})
|
|
278
|
-
|
|
279
|
-
def update_tags(instance, span):
|
|
280
|
-
try:
|
|
281
|
-
# copy tags as is from langchain
|
|
282
|
-
span.set_attribute(TAGS, getattr(instance, TAGS))
|
|
283
|
-
except:
|
|
284
|
-
pass
|
|
285
|
-
try:
|
|
286
|
-
# extract embed model and vector store names for llamaindex
|
|
287
|
-
model_name = instance.retriever._embed_model.model_name
|
|
288
|
-
vector_store_name = type(instance.retriever._vector_store).__name__
|
|
289
|
-
span.set_attribute(TAGS, [model_name, vector_store_name])
|
|
290
|
-
except:
|
|
291
|
-
pass
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
def update_vectorstore_attributes(to_wrap, instance, span):
|
|
295
|
-
"""
|
|
296
|
-
Updates the telemetry span attributes for vector store retrieval tasks.
|
|
297
|
-
"""
|
|
298
|
-
try:
|
|
299
|
-
package = to_wrap.get('package')
|
|
300
|
-
if package in framework_vector_store_mapping:
|
|
301
|
-
attributes = framework_vector_store_mapping[package](instance)
|
|
302
|
-
span._attributes.update({
|
|
303
|
-
TYPE: attributes['type'],
|
|
304
|
-
PROVIDER: attributes['provider'],
|
|
305
|
-
EMBEDDING_MODEL: attributes['embedding_model']
|
|
306
|
-
})
|
|
307
|
-
else:
|
|
308
|
-
logger.warning(f"Package '{package}' not recognized for vector store telemetry.")
|
|
309
|
-
|
|
310
|
-
except Exception as e:
|
|
311
|
-
logger.error(f"Error updating span attributes: {e}")
|
monocle_apptrace/wrapper.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from monocle_apptrace.haystack import HAYSTACK_METHODS
|
|
4
|
-
from monocle_apptrace.langchain import LANGCHAIN_METHODS
|
|
5
|
-
from monocle_apptrace.llamaindex import LLAMAINDEX_METHODS
|
|
6
|
-
from monocle_apptrace.wrap_common import task_wrapper
|
|
7
|
-
|
|
8
|
-
# pylint: disable=too-few-public-methods
|
|
9
|
-
class WrapperMethod:
|
|
10
|
-
def __init__(
|
|
11
|
-
self,
|
|
12
|
-
package: str,
|
|
13
|
-
object_name: str,
|
|
14
|
-
method: str,
|
|
15
|
-
span_name: str = None,
|
|
16
|
-
wrapper = task_wrapper
|
|
17
|
-
):
|
|
18
|
-
self.package = package
|
|
19
|
-
self.object = object_name
|
|
20
|
-
self.method = method
|
|
21
|
-
self.span_name = span_name
|
|
22
|
-
self.wrapper = wrapper
|
|
23
|
-
|
|
24
|
-
INBUILT_METHODS_LIST = LANGCHAIN_METHODS + LLAMAINDEX_METHODS + HAYSTACK_METHODS
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
monocle_apptrace/README.md,sha256=T5NFC01bF8VR0oVnAX_n0bhsEtttwqfTxDNAe5Y_ivE,3765
|
|
2
|
-
monocle_apptrace/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
monocle_apptrace/constants.py,sha256=wjObbmMTFL201x-bf3EOXevYygwkFH_1ng5dDrpE3z0,810
|
|
4
|
-
monocle_apptrace/instrumentor.py,sha256=txKj7tZaXY0gznc8QVOyMI-LA5r7tfSPJkleZPI1fWQ,5051
|
|
5
|
-
monocle_apptrace/utils.py,sha256=l3FAVF0rFbsph1LFdTMcs7K5ASiaovRQBmBeFYEHZmU,3174
|
|
6
|
-
monocle_apptrace/wrap_common.py,sha256=rhiY2PE2WoLYofbby3LioTSjFG8YrMlhUnc82yXRkFk,12612
|
|
7
|
-
monocle_apptrace/wrapper.py,sha256=cNUdfciAXNYAhvtOA2O4ONRvuT2bbHb4ax_7pALijEI,734
|
|
8
|
-
monocle_apptrace/exporters/file_exporter.py,sha256=gN9pJ_X5pcstVVsyivgHsjWhr443eRa6Y6Hx1rGLQAM,2280
|
|
9
|
-
monocle_apptrace/haystack/__init__.py,sha256=95LGUcUZbOcX5h-NwNrquKycp-qhuwCmcMfWAwxGylQ,321
|
|
10
|
-
monocle_apptrace/haystack/wrap_node.py,sha256=IK07Wn3Lk1Os9URsyrmB1HXOH2FNdzK9fNLlR8TZdYc,908
|
|
11
|
-
monocle_apptrace/haystack/wrap_openai.py,sha256=Yp916DhOl0WI6virRi3L43snfsQm7PhI28wlDsg19v8,1536
|
|
12
|
-
monocle_apptrace/haystack/wrap_pipeline.py,sha256=1bufscslUpjbSw_kVl24rngTMsiGV33oCKbTxwtWM6Q,2173
|
|
13
|
-
monocle_apptrace/langchain/__init__.py,sha256=3ABxFk92mmRj67Y3z70leZ4j1ig9Z6OU--rtxzfNIIM,271
|
|
14
|
-
monocle_apptrace/llamaindex/__init__.py,sha256=lr-rdprhXJdSt-Fp1LghW-hMxWgDN6lPFTQgyqnb7N0,573
|
|
15
|
-
monocle_apptrace/metamodel/README.md,sha256=KYuuYqgA9PNbOjG0zYj2nAdvNEpyNN_Bk9M2tNdnZ_s,4598
|
|
16
|
-
monocle_apptrace/metamodel/entities/README.md,sha256=ZE8PYne9F8xN4uu0CB1BOS8iM5QdKdpQjHuqCaw7Vkg,1553
|
|
17
|
-
monocle_apptrace/metamodel/entities/entity_types.json,sha256=-J1ZbzrZny1c9HSQKwRZu2Un3c0JjX9FvsfHwlZvaaw,5435
|
|
18
|
-
monocle_apptrace/metamodel/entities/entity_types.py,sha256=4CzobOm692tou1Tsv8YX_yrOhhnwMBF8hBAt1Czn_8Q,1076
|
|
19
|
-
monocle_apptrace/metamodel/maps/haystack_methods.json,sha256=JmngkaKICAzOyrWNTWEOLYFrp99l5wcERYKE_SQRNxE,698
|
|
20
|
-
monocle_apptrace/metamodel/maps/lang_chain_methods.json,sha256=HaOhhxb3PkI7tXPxXhWR4cnWrnEHU--k5pOY9RS0Uew,3119
|
|
21
|
-
monocle_apptrace/metamodel/maps/llama_index_methods.json,sha256=qpODnBHkaDjPBYZNd7clwmp_2subTu-fmI08Ky5OWdg,2192
|
|
22
|
-
monocle_apptrace/metamodel/spans/README.md,sha256=_uMkLLaWitQ_rPh7oQbW5Oe7uGSv2h_QA6YwxHRJi74,5433
|
|
23
|
-
monocle_apptrace/metamodel/spans/span_example.json,sha256=R4YVyz3rkhVc_FxpeBkY9JfO0GwluFa2A2wn4LkOPbo,4402
|
|
24
|
-
monocle_apptrace/metamodel/spans/span_format.json,sha256=GhfioGgMhG7St0DeYA1fgNtMkbr9wiQ1L2hovekRQ24,1512
|
|
25
|
-
monocle_apptrace-0.1.1.dist-info/METADATA,sha256=2Oz22Sjk1qarR4h_RctVoYnQWq0LSklrXu05_GFJjjE,5215
|
|
26
|
-
monocle_apptrace-0.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
27
|
-
monocle_apptrace-0.1.1.dist-info/licenses/LICENSE,sha256=ay9trLiP5I7ZsFXo6AqtkLYdRqe5S9r-DrPOvsNlZrg,9136
|
|
28
|
-
monocle_apptrace-0.1.1.dist-info/licenses/NOTICE,sha256=9jn4xtwM_uUetJMx5WqGnhrR7MIhpoRlpokjSTlyt8c,112
|
|
29
|
-
monocle_apptrace-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|