monocle-apptrace 0.3.0b2__py3-none-any.whl → 0.3.0b3__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.

Files changed (74) hide show
  1. monocle_apptrace/exporters/aws/s3_exporter.py +1 -1
  2. monocle_apptrace/exporters/aws/s3_exporter_opendal.py +126 -0
  3. monocle_apptrace/exporters/azure/blob_exporter_opendal.py +147 -0
  4. monocle_apptrace/exporters/monocle_exporters.py +38 -20
  5. monocle_apptrace/instrumentation/__init__.py +0 -0
  6. monocle_apptrace/instrumentation/common/__init__.py +0 -0
  7. monocle_apptrace/{constants.py → instrumentation/common/constants.py} +13 -0
  8. monocle_apptrace/instrumentation/common/instrumentor.py +208 -0
  9. monocle_apptrace/instrumentation/common/span_handler.py +154 -0
  10. monocle_apptrace/instrumentation/common/utils.py +171 -0
  11. monocle_apptrace/instrumentation/common/wrapper.py +69 -0
  12. monocle_apptrace/instrumentation/common/wrapper_method.py +45 -0
  13. monocle_apptrace/instrumentation/metamodel/__init__.py +0 -0
  14. monocle_apptrace/instrumentation/metamodel/botocore/__init__.py +0 -0
  15. monocle_apptrace/instrumentation/metamodel/botocore/_helper.py +126 -0
  16. monocle_apptrace/instrumentation/metamodel/botocore/entities/__init__.py +0 -0
  17. monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py +65 -0
  18. monocle_apptrace/instrumentation/metamodel/botocore/methods.py +16 -0
  19. monocle_apptrace/instrumentation/metamodel/haystack/__init__.py +0 -0
  20. monocle_apptrace/instrumentation/metamodel/haystack/_helper.py +127 -0
  21. monocle_apptrace/instrumentation/metamodel/haystack/entities/__init__.py +0 -0
  22. monocle_apptrace/instrumentation/metamodel/haystack/entities/inference.py +76 -0
  23. monocle_apptrace/instrumentation/metamodel/haystack/entities/retrieval.py +61 -0
  24. monocle_apptrace/instrumentation/metamodel/haystack/methods.py +42 -0
  25. monocle_apptrace/instrumentation/metamodel/langchain/__init__.py +0 -0
  26. monocle_apptrace/instrumentation/metamodel/langchain/_helper.py +121 -0
  27. monocle_apptrace/instrumentation/metamodel/langchain/entities/__init__.py +0 -0
  28. monocle_apptrace/instrumentation/metamodel/langchain/entities/inference.py +71 -0
  29. monocle_apptrace/instrumentation/metamodel/langchain/entities/retrieval.py +58 -0
  30. monocle_apptrace/instrumentation/metamodel/langchain/methods.py +105 -0
  31. monocle_apptrace/instrumentation/metamodel/llamaindex/__init__.py +0 -0
  32. monocle_apptrace/instrumentation/metamodel/llamaindex/_helper.py +154 -0
  33. monocle_apptrace/instrumentation/metamodel/llamaindex/entities/__init__.py +0 -0
  34. monocle_apptrace/instrumentation/metamodel/llamaindex/entities/inference.py +71 -0
  35. monocle_apptrace/instrumentation/metamodel/llamaindex/entities/retrieval.py +57 -0
  36. monocle_apptrace/{metamodel/maps/llamaindex_methods.json → instrumentation/metamodel/llamaindex/methods.py} +28 -31
  37. {monocle_apptrace-0.3.0b2.dist-info → monocle_apptrace-0.3.0b3.dist-info}/METADATA +14 -1
  38. monocle_apptrace-0.3.0b3.dist-info/RECORD +48 -0
  39. monocle_apptrace/botocore/__init__.py +0 -9
  40. monocle_apptrace/haystack/__init__.py +0 -9
  41. monocle_apptrace/haystack/wrap_pipeline.py +0 -63
  42. monocle_apptrace/instrumentor.py +0 -121
  43. monocle_apptrace/langchain/__init__.py +0 -9
  44. monocle_apptrace/llamaindex/__init__.py +0 -16
  45. monocle_apptrace/message_processing.py +0 -80
  46. monocle_apptrace/metamodel/README.md +0 -47
  47. monocle_apptrace/metamodel/entities/README.md +0 -77
  48. monocle_apptrace/metamodel/entities/app_hosting_types.json +0 -29
  49. monocle_apptrace/metamodel/entities/entities.json +0 -49
  50. monocle_apptrace/metamodel/entities/inference_types.json +0 -33
  51. monocle_apptrace/metamodel/entities/model_types.json +0 -41
  52. monocle_apptrace/metamodel/entities/vector_store_types.json +0 -25
  53. monocle_apptrace/metamodel/entities/workflow_types.json +0 -22
  54. monocle_apptrace/metamodel/maps/attributes/inference/botocore_entities.json +0 -27
  55. monocle_apptrace/metamodel/maps/attributes/inference/haystack_entities.json +0 -57
  56. monocle_apptrace/metamodel/maps/attributes/inference/langchain_entities.json +0 -57
  57. monocle_apptrace/metamodel/maps/attributes/inference/llamaindex_entities.json +0 -57
  58. monocle_apptrace/metamodel/maps/attributes/retrieval/haystack_entities.json +0 -31
  59. monocle_apptrace/metamodel/maps/attributes/retrieval/langchain_entities.json +0 -31
  60. monocle_apptrace/metamodel/maps/attributes/retrieval/llamaindex_entities.json +0 -31
  61. monocle_apptrace/metamodel/maps/botocore_methods.json +0 -13
  62. monocle_apptrace/metamodel/maps/haystack_methods.json +0 -45
  63. monocle_apptrace/metamodel/maps/langchain_methods.json +0 -129
  64. monocle_apptrace/metamodel/spans/README.md +0 -121
  65. monocle_apptrace/metamodel/spans/span_example.json +0 -140
  66. monocle_apptrace/metamodel/spans/span_format.json +0 -55
  67. monocle_apptrace/metamodel/spans/span_types.json +0 -16
  68. monocle_apptrace/utils.py +0 -252
  69. monocle_apptrace/wrap_common.py +0 -511
  70. monocle_apptrace/wrapper.py +0 -27
  71. monocle_apptrace-0.3.0b2.dist-info/RECORD +0 -48
  72. {monocle_apptrace-0.3.0b2.dist-info → monocle_apptrace-0.3.0b3.dist-info}/WHEEL +0 -0
  73. {monocle_apptrace-0.3.0b2.dist-info → monocle_apptrace-0.3.0b3.dist-info}/licenses/LICENSE +0 -0
  74. {monocle_apptrace-0.3.0b2.dist-info → monocle_apptrace-0.3.0b3.dist-info}/licenses/NOTICE +0 -0
@@ -0,0 +1,154 @@
1
+ """
2
+ This module provides utility functions for extracting system, user,
3
+ and assistant messages from various input formats.
4
+ """
5
+
6
+ import logging
7
+ from urllib.parse import urlparse
8
+ from opentelemetry.sdk.trace import Span
9
+ from monocle_apptrace.instrumentation.common.utils import (
10
+ Option,
11
+ get_keys_as_tuple,
12
+ get_nested_value,
13
+ try_option,
14
+ )
15
+
16
+ logger = logging.getLogger(__name__)
17
+
18
+
19
+ def extract_messages(args):
20
+ """Extract system and user messages"""
21
+ try:
22
+ messages = []
23
+ if args and isinstance(args, (list, tuple)) and args[0]:
24
+ for msg in args[0]:
25
+ if hasattr(msg, 'content') and hasattr(msg, 'role'):
26
+ role = getattr(msg.role, 'value', msg.role)
27
+ if role == "system":
28
+ messages.append({role: msg.content})
29
+ elif role in ["user", "human"]:
30
+ user_message = extract_query_from_content(msg.content)
31
+ messages.append({role: user_message})
32
+ if args and isinstance(args, dict):
33
+ for msg in args.get("messages", []):
34
+ if hasattr(msg, 'content') and hasattr(msg, 'role'):
35
+ role = getattr(msg.role, 'value', msg.role)
36
+ if role == "system":
37
+ messages.append({role: msg.content})
38
+ elif role in ["user", "human"]:
39
+ user_message = msg.content
40
+ messages.append({role: user_message})
41
+ return [str(message) for message in messages]
42
+ except Exception as e:
43
+ logger.warning("Warning: Error occurred in extract_messages: %s", str(e))
44
+ return []
45
+
46
+
47
+ def extract_assistant_message(response):
48
+ try:
49
+ if isinstance(response, str):
50
+ return [response]
51
+ if hasattr(response, "content"):
52
+ return [response.content]
53
+ if hasattr(response, "message") and hasattr(response.message, "content"):
54
+ return [response.message.content]
55
+ except Exception as e:
56
+ logger.warning("Warning: Error occurred in extract_assistant_message: %s", str(e))
57
+ return []
58
+
59
+
60
+ def extract_query_from_content(content):
61
+ try:
62
+ query_prefix = "Query:"
63
+ answer_prefix = "Answer:"
64
+ query_start = content.find(query_prefix)
65
+ if query_start == -1:
66
+ return None
67
+
68
+ query_start += len(query_prefix)
69
+ answer_start = content.find(answer_prefix, query_start)
70
+ if answer_start == -1:
71
+ query = content[query_start:].strip()
72
+ else:
73
+ query = content[query_start:answer_start].strip()
74
+ return query
75
+ except Exception as e:
76
+ logger.warning("Warning: Error occurred in extract_query_from_content: %s", str(e))
77
+ return ""
78
+
79
+
80
+ def extract_provider_name(instance):
81
+ provider_url = try_option(getattr, instance, 'api_base').and_then(lambda url: urlparse(url).hostname)
82
+ return provider_url
83
+
84
+
85
+ def extract_inference_endpoint(instance):
86
+ inference_endpoint = try_option(getattr, instance._client.sdk_configuration, 'server_url').map(str)
87
+ return inference_endpoint.unwrap_or(extract_provider_name(instance))
88
+
89
+
90
+ def extract_vectorstore_deployment(my_map):
91
+ if isinstance(my_map, dict):
92
+ if '_client_settings' in my_map:
93
+ client = my_map['_client_settings'].__dict__
94
+ host, port = get_keys_as_tuple(client, 'host', 'port')
95
+ if host:
96
+ return f"{host}:{port}" if port else host
97
+ keys_to_check = ['client', '_client']
98
+ host = __get_host_from_map(my_map, keys_to_check)
99
+ if host:
100
+ return host
101
+ else:
102
+ if hasattr(my_map, 'client') and '_endpoint' in my_map.client.__dict__:
103
+ return my_map.client.__dict__['_endpoint']
104
+ host, port = get_keys_as_tuple(my_map.__dict__, 'host', 'port')
105
+ if host:
106
+ return f"{host}:{port}" if port else host
107
+ return None
108
+
109
+
110
+ def __get_host_from_map(my_map, keys_to_check):
111
+ for key in keys_to_check:
112
+ seed_connections = get_nested_value(my_map, [key, 'transport', 'seed_connections'])
113
+ if seed_connections and 'host' in seed_connections[0].__dict__:
114
+ return seed_connections[0].__dict__['host']
115
+ return None
116
+
117
+
118
+ def resolve_from_alias(my_map, alias):
119
+ """Find a alias that is not none from list of aliases"""
120
+
121
+ for i in alias:
122
+ if i in my_map.keys():
123
+ return my_map[i]
124
+ return None
125
+
126
+
127
+ def update_input_span_events(args):
128
+ if isinstance(args, tuple):
129
+ return args[0].query_str if len(args) > 0 else ""
130
+
131
+
132
+ def update_output_span_events(results):
133
+ if isinstance(results, list) and len(results) >0:
134
+ output_arg_text = results[0].text
135
+ if len(output_arg_text) > 100:
136
+ output_arg_text = output_arg_text[:100] + "..."
137
+ return output_arg_text
138
+
139
+
140
+ def update_span_from_llm_response(response, instance):
141
+ meta_dict = {}
142
+ if response is not None and hasattr(response, "raw"):
143
+ if response.raw is not None:
144
+ token_usage = response.raw.get("usage") if isinstance(response.raw, dict) else getattr(response.raw, "usage", None)
145
+ if token_usage is not None:
146
+ temperature = instance.__dict__.get("temperature", None)
147
+ meta_dict.update({"temperature": temperature})
148
+ if getattr(token_usage, "completion_tokens", None):
149
+ meta_dict.update({"completion_tokens": getattr(token_usage, "completion_tokens")})
150
+ if getattr(token_usage, "prompt_tokens", None):
151
+ meta_dict.update({"prompt_tokens": getattr(token_usage, "prompt_tokens")})
152
+ if getattr(token_usage, "total_tokens", None):
153
+ meta_dict.update({"total_tokens": getattr(token_usage, "total_tokens")})
154
+ return meta_dict
@@ -0,0 +1,71 @@
1
+ from monocle_apptrace.instrumentation.metamodel.llamaindex import (
2
+ _helper,
3
+ )
4
+ from monocle_apptrace.instrumentation.common.utils import resolve_from_alias
5
+
6
+ INFERENCE = {
7
+ "type": "inference",
8
+ "attributes": [
9
+ [
10
+ {
11
+ "_comment": "provider type ,name , deployment , inference_endpoint",
12
+ "attribute": "type",
13
+ "accessor": lambda arguments: 'inference.azure_oai'
14
+ },
15
+ {
16
+ "attribute": "provider_name",
17
+ "accessor": lambda arguments: _helper.extract_provider_name(arguments['instance'])
18
+ },
19
+ {
20
+ "attribute": "deployment",
21
+ "accessor": lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])
22
+ },
23
+ {
24
+ "attribute": "inference_endpoint",
25
+ "accessor": lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['azure_endpoint', 'api_base']) or _helper.extract_inference_endpoint(arguments['instance'])
26
+ }
27
+ ],
28
+ [
29
+ {
30
+ "_comment": "LLM Model",
31
+ "attribute": "name",
32
+ "accessor": lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['model', 'model_name'])
33
+ },
34
+ {
35
+ "attribute": "type",
36
+ "accessor": lambda arguments: 'model.llm.' + resolve_from_alias(arguments['instance'].__dict__, ['model', 'model_name'])
37
+ }
38
+ ]
39
+ ],
40
+ "events": [
41
+ {"name": "data.input",
42
+ "attributes": [
43
+
44
+ {
45
+ "_comment": "this is instruction and user query to LLM",
46
+ "attribute": "input",
47
+ "accessor": lambda arguments: _helper.extract_messages(arguments['args'])
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ "name": "data.output",
53
+ "attributes": [
54
+ {
55
+ "_comment": "this is response from LLM",
56
+ "attribute": "response",
57
+ "accessor": lambda arguments: _helper.extract_assistant_message(arguments['result'])
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "name": "metadata",
63
+ "attributes": [
64
+ {
65
+ "_comment": "this is metadata usage from LLM",
66
+ "accessor": lambda arguments: _helper.update_span_from_llm_response(arguments['result'],arguments['instance'])
67
+ }
68
+ ]
69
+ }
70
+ ]
71
+ }
@@ -0,0 +1,57 @@
1
+ from monocle_apptrace.instrumentation.metamodel.llamaindex import (
2
+ _helper,
3
+ )
4
+
5
+ RETRIEVAL = {
6
+ "type": "retrieval",
7
+ "attributes": [
8
+ [
9
+ {
10
+ "_comment": "vector store name and type",
11
+ "attribute": "name",
12
+ "accessor": lambda arguments: type(arguments['instance']._vector_store).__name__
13
+ },
14
+ {
15
+ "attribute": "type",
16
+ "accessor": lambda arguments: 'vectorstore.' + type(arguments['instance']._vector_store).__name__
17
+ },
18
+ {
19
+ "attribute": "deployment",
20
+ "accessor": lambda arguments: _helper.extract_vectorstore_deployment(arguments['instance']._vector_store)
21
+ }
22
+ ],
23
+ [
24
+ {
25
+ "_comment": "embedding model name and type",
26
+ "attribute": "name",
27
+ "accessor": lambda arguments: arguments['instance']._embed_model.model_name
28
+ },
29
+ {
30
+ "attribute": "type",
31
+ "accessor": lambda arguments: 'model.embedding.' + arguments['instance']._embed_model.model_name
32
+ }
33
+ ]
34
+ ],
35
+ "events": [
36
+ {"name": "data.input",
37
+ "attributes": [
38
+
39
+ {
40
+ "_comment": "this is instruction and user query to LLM",
41
+ "attribute": "input",
42
+ "accessor": lambda arguments: _helper.update_input_span_events(arguments['args'])
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "name": "data.output",
48
+ "attributes": [
49
+ {
50
+ "_comment": "this is result from LLM",
51
+ "attribute": "response",
52
+ "accessor": lambda arguments: _helper.update_output_span_events(arguments['result'])
53
+ }
54
+ ]
55
+ }
56
+ ]
57
+ }
@@ -1,92 +1,89 @@
1
- {
2
- "wrapper_methods" : [
1
+ from monocle_apptrace.instrumentation.common.wrapper import atask_wrapper, task_wrapper
2
+ from monocle_apptrace.instrumentation.metamodel.llamaindex.entities.inference import (
3
+ INFERENCE,
4
+ )
5
+ from monocle_apptrace.instrumentation.metamodel.llamaindex.entities.retrieval import (
6
+ RETRIEVAL,
7
+ )
8
+
9
+
10
+ LLAMAINDEX_METHODS = [
3
11
  {
4
12
  "package": "llama_index.core.indices.base_retriever",
5
13
  "object": "BaseRetriever",
6
14
  "method": "retrieve",
7
15
  "span_name": "llamaindex.retrieve",
8
- "wrapper_package": "wrap_common",
9
- "wrapper_method": "task_wrapper",
10
- "output_processor": ["metamodel/maps/attributes/retrieval/llamaindex_entities.json"]
16
+ "wrapper_method": task_wrapper,
17
+ "output_processor": RETRIEVAL
11
18
  },
12
19
  {
13
20
  "package": "llama_index.core.indices.base_retriever",
14
21
  "object": "BaseRetriever",
15
22
  "method": "aretrieve",
16
23
  "span_name": "llamaindex.retrieve",
17
- "wrapper_package": "wrap_common",
18
- "wrapper_method": "atask_wrapper",
19
- "output_processor": ["metamodel/maps/attributes/retrieval/llamaindex_entities.json"]
24
+ "wrapper_method": atask_wrapper,
25
+ "output_processor": RETRIEVAL
20
26
  },
21
27
  {
22
28
  "package": "llama_index.core.base.base_query_engine",
23
29
  "object": "BaseQueryEngine",
24
30
  "method": "query",
25
31
  "span_name": "llamaindex.query",
26
- "wrapper_package": "wrap_common",
27
- "wrapper_method": "task_wrapper"
32
+ "wrapper_method": task_wrapper
28
33
  },
29
34
  {
30
35
  "package": "llama_index.core.base.base_query_engine",
31
36
  "object": "BaseQueryEngine",
32
37
  "method": "aquery",
33
38
  "span_name": "llamaindex.query",
34
- "wrapper_package": "wrap_common",
35
- "wrapper_method": "atask_wrapper"
39
+ "wrapper_method": atask_wrapper
36
40
  },
37
41
  {
38
42
  "package": "llama_index.core.llms.custom",
39
43
  "object": "CustomLLM",
40
44
  "method": "chat",
41
45
  "span_name": "llamaindex.llmchat",
42
- "wrapper_package": "wrap_common",
43
- "wrapper_method": "task_wrapper",
44
- "output_processor": ["metamodel/maps/attributes/inference/llamaindex_entities.json"]
46
+ "wrapper_method": task_wrapper,
47
+ "output_processor": INFERENCE
45
48
  },
46
49
  {
47
50
  "package": "llama_index.core.llms.custom",
48
51
  "object": "CustomLLM",
49
52
  "method": "achat",
50
53
  "span_name": "llamaindex.llmchat",
51
- "wrapper_package": "wrap_common",
52
- "wrapper_method": "atask_wrapper",
53
- "output_processor": ["metamodel/maps/attributes/inference/llamaindex_entities.json"]
54
+ "wrapper_method": atask_wrapper,
55
+ "output_processor": INFERENCE
54
56
  },
55
57
  {
56
58
  "package": "llama_index.llms.openai.base",
57
59
  "object": "OpenAI",
58
60
  "method": "chat",
59
61
  "span_name": "llamaindex.openai",
60
- "wrapper_package": "wrap_common",
61
- "wrapper_method": "llm_wrapper",
62
- "output_processor": ["metamodel/maps/attributes/inference/llamaindex_entities.json"]
62
+ "wrapper_method": task_wrapper,
63
+ "output_processor": INFERENCE
63
64
  },
64
65
  {
65
66
  "package": "llama_index.llms.openai.base",
66
67
  "object": "OpenAI",
67
68
  "method": "achat",
68
69
  "span_name": "llamaindex.openai",
69
- "wrapper_package": "wrap_common",
70
- "wrapper_method": "allm_wrapper",
71
- "output_processor": ["metamodel/maps/attributes/inference/llamaindex_entities.json"]
70
+ "wrapper_method": atask_wrapper,
71
+ "output_processor": INFERENCE
72
72
  },
73
73
  {
74
74
  "package": "llama_index.llms.mistralai.base",
75
75
  "object": "MistralAI",
76
76
  "method": "chat",
77
77
  "span_name": "llamaindex.mistralai",
78
- "wrapper_package": "wrap_common",
79
- "wrapper_method": "llm_wrapper",
80
- "output_processor": ["metamodel/maps/attributes/inference/llamaindex_entities.json"]
78
+ "wrapper_method": task_wrapper,
79
+ "output_processor": INFERENCE
81
80
  },
82
81
  {
83
82
  "package": "llama_index.llms.mistralai.base",
84
83
  "object": "MistralAI",
85
84
  "method": "achat",
86
85
  "span_name": "llamaindex.mistralai",
87
- "wrapper_package": "wrap_common",
88
- "wrapper_method": "allm_wrapper",
89
- "output_processor": ["metamodel/maps/attributes/inference/llamaindex_entities.json"]
86
+ "wrapper_method": atask_wrapper,
87
+ "output_processor": INFERENCE
90
88
  }
91
89
  ]
92
- }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: monocle_apptrace
3
- Version: 0.3.0b2
3
+ Version: 0.3.0b3
4
4
  Summary: package with monocle genAI tracing
5
5
  Project-URL: Homepage, https://github.com/monocle2ai/monocle
6
6
  Project-URL: Issues, https://github.com/monocle2ai/monocle/issues
@@ -20,22 +20,35 @@ Requires-Dist: boto3==1.35.19; extra == 'aws'
20
20
  Provides-Extra: azure
21
21
  Requires-Dist: azure-storage-blob==12.22.0; extra == 'azure'
22
22
  Provides-Extra: dev
23
+ Requires-Dist: azure-storage-blob==12.22.0; extra == 'dev'
24
+ Requires-Dist: boto3==1.34.131; extra == 'dev'
25
+ Requires-Dist: chromadb==0.4.22; extra == 'dev'
23
26
  Requires-Dist: datasets==2.20.0; extra == 'dev'
24
27
  Requires-Dist: faiss-cpu==1.8.0; extra == 'dev'
28
+ Requires-Dist: flask; extra == 'dev'
29
+ Requires-Dist: haystack-ai==2.3.0; extra == 'dev'
25
30
  Requires-Dist: instructorembedding==1.0.1; extra == 'dev'
31
+ Requires-Dist: langchain-aws==0.1.10; extra == 'dev'
26
32
  Requires-Dist: langchain-chroma==0.1.1; extra == 'dev'
27
33
  Requires-Dist: langchain-community==0.2.5; extra == 'dev'
28
34
  Requires-Dist: langchain-mistralai==0.1.13; extra == 'dev'
29
35
  Requires-Dist: langchain-openai==0.1.8; extra == 'dev'
30
36
  Requires-Dist: langchain==0.2.5; extra == 'dev'
37
+ Requires-Dist: langchainhub==0.1.21; extra == 'dev'
31
38
  Requires-Dist: llama-index-embeddings-huggingface==0.2.0; extra == 'dev'
39
+ Requires-Dist: llama-index-llms-azure-openai==0.1.9; extra == 'dev'
32
40
  Requires-Dist: llama-index-llms-mistralai==0.1.20; extra == 'dev'
33
41
  Requires-Dist: llama-index-vector-stores-chroma==0.1.9; extra == 'dev'
42
+ Requires-Dist: llama-index-vector-stores-opensearch==0.1.10; extra == 'dev'
34
43
  Requires-Dist: llama-index==0.10.30; extra == 'dev'
35
44
  Requires-Dist: mistral-haystack==0.0.2; extra == 'dev'
36
45
  Requires-Dist: numpy==1.26.4; extra == 'dev'
46
+ Requires-Dist: opendal==0.45.14; extra == 'dev'
47
+ Requires-Dist: opensearch-haystack==1.2.0; extra == 'dev'
48
+ Requires-Dist: opentelemetry-instrumentation-flask; extra == 'dev'
37
49
  Requires-Dist: parameterized==0.9.0; extra == 'dev'
38
50
  Requires-Dist: pytest==8.0.0; extra == 'dev'
51
+ Requires-Dist: requests-aws4auth==1.2.3; extra == 'dev'
39
52
  Requires-Dist: sentence-transformers==2.6.1; extra == 'dev'
40
53
  Requires-Dist: types-requests==2.31.0.20240106; extra == 'dev'
41
54
  Description-Content-Type: text/markdown
@@ -0,0 +1,48 @@
1
+ monocle_apptrace/README.md,sha256=T5NFC01bF8VR0oVnAX_n0bhsEtttwqfTxDNAe5Y_ivE,3765
2
+ monocle_apptrace/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ monocle_apptrace/exporters/base_exporter.py,sha256=Gov_QKp5fonVZ-YdNM2ynoPot7GCaSNmKbCHIP3bDlE,1680
4
+ monocle_apptrace/exporters/exporter_processor.py,sha256=BTcBgMuFLHCdCgVvc9TKIo9y8g1BvShI0L4vX6Q-cmk,393
5
+ monocle_apptrace/exporters/file_exporter.py,sha256=gN9pJ_X5pcstVVsyivgHsjWhr443eRa6Y6Hx1rGLQAM,2280
6
+ monocle_apptrace/exporters/monocle_exporters.py,sha256=WRcRnnN0gSL7khN-BZ9wonMKiWaHNFqnBZ-QyM6hMsg,2177
7
+ monocle_apptrace/exporters/aws/s3_exporter.py,sha256=eq5SfZmaeyhtXeXYnJGAfT1vlaNGSyh1leGX9Rr7vQ4,6619
8
+ monocle_apptrace/exporters/aws/s3_exporter_opendal.py,sha256=FvyW0KkAz0W_1g16C_ERmamg4fSreT-UXgLaN9URTVQ,5057
9
+ monocle_apptrace/exporters/azure/blob_exporter.py,sha256=m7Hsw3OXlP2GOCQcdxf8LM6Fe12fZmih45x82Z12dbI,5597
10
+ monocle_apptrace/exporters/azure/blob_exporter_opendal.py,sha256=h5xv7JU6YEXL4AKT2B1op3YsHoA0rNnLCGq8seoVRWs,6114
11
+ monocle_apptrace/exporters/okahu/okahu_exporter.py,sha256=p2rjStwo0OMEdHWQt_QvREpUWXbDm5jGx3qXeYai4_M,4407
12
+ monocle_apptrace/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ monocle_apptrace/instrumentation/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ monocle_apptrace/instrumentation/common/constants.py,sha256=ySfwN5ZUtNFwm3ba5QWxBpLmZVuBRqVltuaBvpk-e3Y,1937
15
+ monocle_apptrace/instrumentation/common/instrumentor.py,sha256=v79pmHDRf64G1Y0A6RMZlxbKizYRuNwlkJpRabESDiU,8386
16
+ monocle_apptrace/instrumentation/common/span_handler.py,sha256=d5ycN3_OYkNm6_XKuAybMa-s1o6VrH92bEiR-Q_Hj24,7141
17
+ monocle_apptrace/instrumentation/common/utils.py,sha256=nX3TErgaaYSlebYqQHuj4nqFyU51-nMrdIbQmO2vOTI,5357
18
+ monocle_apptrace/instrumentation/common/wrapper.py,sha256=Q-7gyJpTtNpY1-khduT3vykvOewQ8qKzKQfYaZjho7s,2864
19
+ monocle_apptrace/instrumentation/common/wrapper_method.py,sha256=rWiSdzhZrnWnNVVAZMetPboCH2HHSOZ7KgI7dPwGxV8,1629
20
+ monocle_apptrace/instrumentation/metamodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ monocle_apptrace/instrumentation/metamodel/botocore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ monocle_apptrace/instrumentation/metamodel/botocore/_helper.py,sha256=wK6yZ96csTOUaq5itQx0dS-vjDfyMu-AIPu3i3cXebs,4979
23
+ monocle_apptrace/instrumentation/metamodel/botocore/methods.py,sha256=EYNYE8FolCoFgJU8q6Jkf_0CWDJ8kXIktX1eB5eTAIQ,404
24
+ monocle_apptrace/instrumentation/metamodel/botocore/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
+ monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py,sha256=JfTRmrxgU6e-b3dBbunWt5ObY_Ry_ZBYJBwKJB5UlJ8,2255
26
+ monocle_apptrace/instrumentation/metamodel/haystack/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ monocle_apptrace/instrumentation/metamodel/haystack/_helper.py,sha256=VgTrKn7rZMcv4OVdVEBI76G-5B0Rux4guiI6Nsso14s,4833
28
+ monocle_apptrace/instrumentation/metamodel/haystack/methods.py,sha256=4WwhZoPQBkV42TpBvn-rXu37xtaBRrw7_VZB3MGrfxE,1434
29
+ monocle_apptrace/instrumentation/metamodel/haystack/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ monocle_apptrace/instrumentation/metamodel/haystack/entities/inference.py,sha256=PkCaaar5hbZH7YGtWisq8dUJqBINsFGmtaUgt11UDa4,3019
31
+ monocle_apptrace/instrumentation/metamodel/haystack/entities/retrieval.py,sha256=nq3lsk2qFxXqwrAHsBt8zrh4ZVGAJABkPtylrjUCCqc,2357
32
+ monocle_apptrace/instrumentation/metamodel/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ monocle_apptrace/instrumentation/metamodel/langchain/_helper.py,sha256=7GixVwwzYR_Vcit1YN-xscA00HWFxOx7lcpqI94zi-w,4535
34
+ monocle_apptrace/instrumentation/metamodel/langchain/methods.py,sha256=xEWO4uSiOnR221cvXESnVgAfC6JeExsP46ZkbK8_Yqs,3027
35
+ monocle_apptrace/instrumentation/metamodel/langchain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ monocle_apptrace/instrumentation/metamodel/langchain/entities/inference.py,sha256=wjW9hb1Qwr_aqY0lPehdPftyHtuvHinGxVmy0TVj5xo,2705
37
+ monocle_apptrace/instrumentation/metamodel/langchain/entities/retrieval.py,sha256=r4UqTCT5vOfkbz9lwoTRoiMkUUJtPMwqOYbqo53A6K8,2039
38
+ monocle_apptrace/instrumentation/metamodel/llamaindex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ monocle_apptrace/instrumentation/metamodel/llamaindex/_helper.py,sha256=PnxHbVP_XdXTelGYpWqlPvhR4Tr5QcaVd7hdJ0LuA3I,5854
40
+ monocle_apptrace/instrumentation/metamodel/llamaindex/methods.py,sha256=THr-nmeGRNwmHaHeYxNLAG7EQOHZTwTYX-0EdFjfFBk,2748
41
+ monocle_apptrace/instrumentation/metamodel/llamaindex/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ monocle_apptrace/instrumentation/metamodel/llamaindex/entities/inference.py,sha256=585hJXbdN2kFOnABv12vlzFkCbDExZln5ISvQI71EHw,2623
43
+ monocle_apptrace/instrumentation/metamodel/llamaindex/entities/retrieval.py,sha256=QBF1nrqog5KHh925jiY2V-kejL6iVLKUowZmqUDoiJ4,1870
44
+ monocle_apptrace-0.3.0b3.dist-info/METADATA,sha256=VVAF6k-HKzOqIX05cguZz9fmkySu6CKpNWr8ynwRo8I,6265
45
+ monocle_apptrace-0.3.0b3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
46
+ monocle_apptrace-0.3.0b3.dist-info/licenses/LICENSE,sha256=ay9trLiP5I7ZsFXo6AqtkLYdRqe5S9r-DrPOvsNlZrg,9136
47
+ monocle_apptrace-0.3.0b3.dist-info/licenses/NOTICE,sha256=9jn4xtwM_uUetJMx5WqGnhrR7MIhpoRlpokjSTlyt8c,112
48
+ monocle_apptrace-0.3.0b3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- import os
2
- from monocle_apptrace.utils import get_wrapper_methods_config
3
-
4
- parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
5
- BOTOCORE_METHODS = get_wrapper_methods_config(
6
- wrapper_methods_config_path=os.path.join(parent_dir, 'metamodel', 'maps', 'botocore_methods.json'),
7
- attributes_config_base_path=os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
8
-
9
-
@@ -1,9 +0,0 @@
1
- import os
2
- import logging
3
- from monocle_apptrace.utils import get_wrapper_methods_config
4
-
5
- logger = logging.getLogger(__name__)
6
- parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
7
- HAYSTACK_METHODS = get_wrapper_methods_config(
8
- wrapper_methods_config_path=os.path.join(parent_dir, 'metamodel', 'maps', 'haystack_methods.json'),
9
- attributes_config_base_path=os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
@@ -1,63 +0,0 @@
1
- import logging
2
- from opentelemetry import context as context_api
3
- from opentelemetry.context import attach, set_value
4
- from opentelemetry.instrumentation.utils import (
5
- _SUPPRESS_INSTRUMENTATION_KEY,
6
- )
7
- from monocle_apptrace.wrap_common import PROMPT_INPUT_KEY, PROMPT_OUTPUT_KEY, WORKFLOW_TYPE_MAP, with_tracer_wrapper, DATA_INPUT_KEY
8
- from monocle_apptrace.utils import set_embedding_model, set_attribute
9
-
10
- logger = logging.getLogger(__name__)
11
-
12
-
13
- @with_tracer_wrapper
14
- def wrap(tracer, to_wrap, wrapped, instance, args, kwargs):
15
- if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
16
- return wrapped(*args, **kwargs)
17
- name = "haystack_pipeline"
18
- attach(set_value("workflow_name", name))
19
- inputs = set()
20
- workflow_input = get_workflow_input(args, inputs)
21
- embedding_model = get_embedding_model(instance)
22
- set_embedding_model(embedding_model)
23
- set_attribute(DATA_INPUT_KEY, workflow_input)
24
-
25
-
26
- with tracer.start_as_current_span(f"{name}.workflow") as span:
27
- span.set_attribute(PROMPT_INPUT_KEY, workflow_input)
28
- workflow_name = span.resource.attributes.get("service.name")
29
- set_workflow_attributes(span, workflow_name)
30
- response = wrapped(*args, **kwargs)
31
- set_workflow_output(span, response)
32
- return response
33
-
34
- def set_workflow_output(span, response):
35
- workflow_output: str = response["llm"]["replies"][0]
36
- span.set_attribute(PROMPT_OUTPUT_KEY, workflow_output)
37
-
38
- def get_workflow_input(args, inputs):
39
- for value in args[0].values():
40
- for text in value.values():
41
- inputs.add(text)
42
-
43
- workflow_input: str = ""
44
-
45
- for input_str in inputs:
46
- workflow_input = workflow_input + input_str
47
- return workflow_input
48
-
49
- def set_workflow_attributes(span, workflow_name):
50
- span.set_attribute("workflow_name",workflow_name)
51
- span.set_attribute("workflow_type", WORKFLOW_TYPE_MAP["haystack"])
52
-
53
- def get_embedding_model(instance):
54
- try:
55
- if hasattr(instance, 'get_component'):
56
- text_embedder = instance.get_component('text_embedder')
57
- if text_embedder and hasattr(text_embedder, 'model'):
58
- # Set the embedding model attribute
59
- return text_embedder.model
60
- except:
61
- pass
62
-
63
- return None