monocle-apptrace 0.1.0__py3-none-any.whl → 0.1.1__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.

@@ -1,37 +1,59 @@
1
- #Monocle User Guide
2
-
3
1
  ## Monocle Concepts
2
+
4
3
  ### Traces
5
- Traces are the full view of a single end-to-end application KPI eg Chatbot application to provide a response to end user’s question. Traces consists of various metadata about the application run including status, start time, duration, input/outputs etc. It also includes a list of individual steps aka “spans with details about that step.
6
- It’s typically the workflow code components of an application that generate the traces for application runs.
4
+ Traces are the full view of a single end-to-end application execution.
5
+
6
+ Examples of traces include one response to end user’s question by a chatbot app. Traces consists of various metadata about the application run including status, start time, duration, input/outputs etc. It also includes a list of individual steps aka “spans with details about that step.It’s typically the workflow code components of an application that generate the traces for application runs.
7
+
8
+ Traces are collections of spans.
9
+
7
10
  ### Spans
8
- Spans are the individual steps executed by the application to perform a GenAI related task” eg app retrieving vectors from DB, app querying LLM for inference etc. The span includes the type of operation, start time, duration and metadata relevant to that step eg Model name, parameters and model endpoint/server for an inference request.
9
- It’s typically the workflow code components of an application that generate the traces for application runs.
11
+ Spans are the individual steps executed by the application to perform a GenAI related task.
12
+
13
+ Examples of spans include app retrieving vectors from DB, app querying LLM for inference etc. The span includes the type of operation, start time, duration and metadata relevant to that step eg Model name, parameters and model endpoint/server for an inference request.
10
14
 
11
- ## Setup Monocle
12
- - You can download Monocle library releases from Pypi
15
+ ## Contribute to Monocle
16
+
17
+ Monocle includes:
18
+ - Methods for instrumentation of app code
19
+ - Base code for wrapping methods of interest in included in current folder
20
+ - Framework specific code is organized in a folder with the framework name
21
+ - Metamodel for how attributes and events for GenAI components are represented in OpenTelemety format
22
+ - See [metamodel](./metamodel/README.md) for supported GenAI entities, how functions operating on those entities map to spans and format of spans
23
+ - Exporters to send trace data to various locations. See [exporters](./exporters)
24
+
25
+ See [Monocle committer guide](/Monocle_committer_guide.md).
26
+
27
+ ## Get Monocle
28
+
29
+ Option 1 - Download released packages from Pypi
13
30
  ```
14
- > python3 -m pip install pipenv
15
- > pip install monocle-observability
31
+ python3 -m pip install pipenv
32
+ pip install monocle-apptrace
16
33
  ```
17
- - You can locally build and install Monocle library from source
34
+
35
+ Option 2 - Build and install locally from source
18
36
  ```
19
- > pip install .
20
- > pip install -e ".[dev]"
37
+ pip install .
38
+ pip install -e ".[dev]"
21
39
 
22
- > python3 -m pip install pipenv
23
- > pipenv install build
40
+ python3 -m pip install pipenv
41
+ pipenv install build
24
42
  ```
25
43
 
26
- ## Examples
27
- ### Enable Monocle tracing in your application
44
+ ## Examples of app instrumentation with Monocle
45
+
46
+ ### apps written using LLM orchestration frameworks
47
+
28
48
  ```python
29
- from monocle_apptrace.instrumentor import setup_monocle_telemetry
30
- from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
31
49
  from langchain.chains import LLMChain
32
50
  from langchain_openai import OpenAI
33
51
  from langchain.prompts import PromptTemplate
34
52
 
53
+ # Import the monocle_apptrace instrumentation method
54
+ from monocle_apptrace.instrumentor import setup_monocle_telemetry
55
+ from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
56
+
35
57
  # Call the setup Monocle telemetry method
36
58
  setup_monocle_telemetry(workflow_name = "simple_math_app",
37
59
  span_processors=[BatchSpanProcessor(ConsoleSpanExporter())])
@@ -42,19 +64,19 @@ prompt = PromptTemplate.from_template("1 + {number} = ")
42
64
  chain = LLMChain(llm=llm, prompt=prompt)
43
65
  chain.invoke({"number":2})
44
66
 
45
- # Request callbacks: Finally, let's use the request `callbacks` to achieve the same result
46
- chain = LLMChain(llm=llm, prompt=prompt)
47
- chain.invoke({"number":2}, {"callbacks":[handler]})
48
-
67
+ # Trace is generated when invoke() method is called
68
+
49
69
  ```
50
70
 
51
- ### Monitoring custom methods with Monocle
71
+ ### apps with custom methods
52
72
 
53
73
  ```python
74
+
75
+ # Import the monocle_apptrace instrumentation method
54
76
  from monocle_apptrace.wrapper import WrapperMethod,task_wrapper,atask_wrapper
55
77
  from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
56
78
 
57
- # extend the default wrapped methods list as follows
79
+ # Extend the default wrapped methods list as follows
58
80
  app_name = "simple_math_app"
59
81
  setup_monocle_telemetry(
60
82
  workflow_name=app_name,
@@ -74,4 +96,6 @@ setup_monocle_telemetry(
74
96
  wrapper=atask_wrapper)
75
97
  ])
76
98
 
77
- ```
99
+ # Trace is generated when the invoke() method is called in langchain.schema.runnable package
100
+
101
+ ```
@@ -6,4 +6,4 @@ from monocle_apptrace.utils import load_wrapper_from_config
6
6
  logger = logging.getLogger(__name__)
7
7
  parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
8
8
  HAYSTACK_METHODS = load_wrapper_from_config(
9
- os.path.join(parent_dir, 'wrapper_config', 'haystack_methods.json'))
9
+ os.path.join(parent_dir, 'metamodel', 'maps', 'haystack_methods.json'))
@@ -5,6 +5,7 @@ from opentelemetry.instrumentation.utils import (
5
5
  _SUPPRESS_INSTRUMENTATION_KEY,
6
6
  )
7
7
  from monocle_apptrace.wrap_common import PROMPT_INPUT_KEY, PROMPT_OUTPUT_KEY, WORKFLOW_TYPE_MAP, with_tracer_wrapper
8
+ from monocle_apptrace.utils import set_embedding_model
8
9
 
9
10
  logger = logging.getLogger(__name__)
10
11
 
@@ -17,6 +18,9 @@ def wrap(tracer, to_wrap, wrapped, instance, args, kwargs):
17
18
  attach(set_value("workflow_name", name))
18
19
  inputs = set()
19
20
  workflow_input = get_workflow_input(args, inputs)
21
+ embedding_model = get_embedding_model(instance)
22
+ set_embedding_model(embedding_model)
23
+
20
24
 
21
25
  with tracer.start_as_current_span(f"{name}.workflow") as span:
22
26
  span.set_attribute(PROMPT_INPUT_KEY, workflow_input)
@@ -44,3 +48,15 @@ def get_workflow_input(args, inputs):
44
48
  def set_workflow_attributes(span, workflow_name):
45
49
  span.set_attribute("workflow_name",workflow_name)
46
50
  span.set_attribute("workflow_type", WORKFLOW_TYPE_MAP["haystack"])
51
+
52
+ def get_embedding_model(instance):
53
+ try:
54
+ if hasattr(instance, 'get_component'):
55
+ text_embedder = instance.get_component('text_embedder')
56
+ if text_embedder and hasattr(text_embedder, 'model'):
57
+ # Set the embedding model attribute
58
+ return text_embedder.model
59
+ except:
60
+ pass
61
+
62
+ return None
@@ -11,7 +11,7 @@ from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanProcessor
11
11
  from opentelemetry.sdk.resources import SERVICE_NAME, Resource
12
12
  from opentelemetry import trace
13
13
  from opentelemetry.context import get_value, attach, set_value
14
- from monocle_apptrace.wrap_common import CONTEXT_PROPERTIES_KEY
14
+ from monocle_apptrace.wrap_common import SESSION_PROPERTIES_KEY
15
15
  from monocle_apptrace.wrapper import INBUILT_METHODS_LIST, WrapperMethod
16
16
  from monocle_apptrace.exporters.file_exporter import FileSpanExporter
17
17
 
@@ -113,12 +113,12 @@ def setup_monocle_telemetry(
113
113
 
114
114
 
115
115
  def on_processor_start(span: Span, parent_context):
116
- context_properties = get_value(CONTEXT_PROPERTIES_KEY)
116
+ context_properties = get_value(SESSION_PROPERTIES_KEY)
117
117
  if context_properties is not None:
118
118
  for key, value in context_properties.items():
119
119
  span.set_attribute(
120
- f"{CONTEXT_PROPERTIES_KEY}.{key}", value
120
+ f"{SESSION_PROPERTIES_KEY}.{key}", value
121
121
  )
122
122
 
123
123
  def set_context_properties(properties: dict) -> None:
124
- attach(set_value(CONTEXT_PROPERTIES_KEY, properties))
124
+ attach(set_value(SESSION_PROPERTIES_KEY, properties))
@@ -3,4 +3,4 @@ from monocle_apptrace.utils import load_wrapper_from_config
3
3
 
4
4
  parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
5
5
  LANGCHAIN_METHODS = load_wrapper_from_config(
6
- os.path.join(parent_dir, 'wrapper_config', 'lang_chain_methods.json'))
6
+ os.path.join(parent_dir, 'metamodel', 'maps', 'lang_chain_methods.json'))
@@ -12,4 +12,4 @@ def get_llm_span_name_for_openai(instance):
12
12
 
13
13
  parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
14
14
  LLAMAINDEX_METHODS = load_wrapper_from_config(
15
- os.path.join(parent_dir, 'wrapper_config', 'llama_index_methods.json'))
15
+ os.path.join(parent_dir, 'metamodel', 'maps', 'llama_index_methods.json'))
@@ -0,0 +1,47 @@
1
+ # Monocle metamodel
2
+
3
+ ## Overview
4
+ Monocle metamodel is the way to manage standardization across all supported GenAI component stack. It includes the list of components that Monocle can identify and extract metadata. This help understanding and analyzing the traces from applications that include multiple components and can evolve over time. This is one of core value that Monocle provides to it's user community.
5
+
6
+ ## Meta model
7
+ The Monocle metamodel comprises of three things,
8
+ - Entity types, definitions of technology types and supported vendor implementations.
9
+ - A JSON format that overlays on top of Open Telemetry tracing format that includes the common attributes for each entity type.
10
+ - Map of component menthods to trace with instrumentation methods provided by Monocle.
11
+
12
+ ### Entity type
13
+ The entity type defines the type of GenAI component that Monocle understand. The monocle instrumentation can extract the relevenat information for this entity. There are a fixed set of [entity types](./entity_types.py) that are defined by Monocle out of the box, eg workflow, model etc. As the GenAI landscape evolves, the Monocle community will introduce a new entity type if the current entities won't represent a new technology component.
14
+ Each entity types has number of supported technology components that Monocle handles out of the box, eg. LlamaIndex is a supported workflow. Monocle community will continue to expand the breadth of the project by adding more components.
15
+
16
+ ### Span types
17
+ The GenAI application have specific [types of spans](./spans/README.md#span-types-and-events) where diffrent entities integrate. Monocle metamodel defines these types and specifies format for tracing data and metadata generated in such spans.
18
+
19
+ ### Consistent trace format
20
+ Monocle generates [traces](../../../Monocle_User_Guide.md#traces) which comprises of [spans](../../../Monocle_User_Guide.md#spans). Note that Monocle trace is [OpenTelemetry format](https://opentelemetry.io/docs/concepts/signals/traces/) compatible. Each span is essentially a step in the execution that interacts with one of more GenAI technology components. The please refer to the [full spec of the json format](./span_format.json) and a detailed [example](./span_example.json).
21
+ The ```attribute``` section of the span includes a list of such entities that are used in that span.
22
+ The runtime data and metadata collected during the execution of that span are included in the ```events``` section of the trace (as per the Otel spec). Each entry in the event corrosponds to the entity involved in that trace execution if it has produced any runtime outputs.
23
+ Please see the [span format](./spans/README.md) for details.
24
+
25
+ ### Instrumentation method map
26
+ The map dectates what Monocle tracing method is relevant for the a given GenAI tech component method/API. It also specifies the name for that span to set in the trace output.
27
+ ```python
28
+ {
29
+ "package": "llama_index.core.base.base_query_engine",
30
+ "object": "BaseQueryEngine",
31
+ "method": "query",
32
+ "span_name": "llamaindex.query",
33
+ "wrapper_package": "wrap_common",
34
+ "wrapper_method": "task_wrapper"
35
+ }
36
+ ```
37
+
38
+ ## Extending the meta model
39
+ Monocle is highly extensible. This section describe when one would need to extend the meta model. Please refer to Monocle [User guide](../../../Monocle_User_Guide.md) and [Contributor guide](../../../Monocle_contributor_guide.md) for detailed steps.
40
+ ### Trace a new method/API
41
+ If you have overloaded an existing functionality in one of the supported components by creating a new function. Monocle doesn't know that this function should be traced, say because it's calling an LLM. You could define a new mapping so Monocle instrumentation can trace this function the say way it handles other LLM invocation functions.
42
+
43
+ ### Adding a new component provider
44
+ Let's say there's a new database that supports vector search capability which is not supported by the Monocle. In this case, first you'll need to add that database under the ``MonocleEntity.VectorDB`` list. Then you'll need to extend the method map and test if the existing Monocle tracing functions has logic to effectively trace the new component. If not, then you might need to implement new method to cover the gap and update the mapping table according.
45
+
46
+ ### Support new type of entity
47
+ If there's new component that can't be mapped to any of the existing entity types, then it'll require extending the metamodel and implement new instrumetation to support it. We recommend you initiate a discussion with Monocle community to add the support.
@@ -0,0 +1,54 @@
1
+ # Monocle Entities
2
+ The entity type defines the type of GenAI component that Monocle understand. The monocle instrumentation can extract the relevenat information for this entity. There are a fixed set of [entity types](./entity_types.py) that are defined by Monocle out of the box, eg workflow, model etc. As the GenAI landscape evolves, the Monocle community will introduce a new entity type if the current entities won't represent a new technology component.
3
+
4
+ ## Entity Types
5
+ Following attributes are supported for all entities
6
+ | Name | Description | Required |
7
+ | - | - | - |
8
+ | name | Entity name generated by Monocle | Required |
9
+ | type | Monocle Entity type | True |
10
+
11
+ ### MonocleEntity.Workflow
12
+ Workflow ie the core application code. Supported types are -
13
+ - generic
14
+ - langchain
15
+ - llama_index
16
+ - haystack
17
+
18
+ ### MonocleEntity.Model
19
+ GenAI models. Supported types are -
20
+ - generic
21
+ - llm
22
+ - embedding
23
+ Following attributes are supported for all model type entities
24
+ | Name | Description | Required |
25
+ | - | - | - |
26
+ | model_name | Name of model | True |
27
+
28
+
29
+ ### MonocleEntity.AppHosting
30
+ Application host services where the workflow code is run. Supported types are -
31
+ - generic
32
+ - aws_lambda
33
+ - aws_sagemaker
34
+ - azure_func
35
+ - github_codespace
36
+ - azure_mlw
37
+
38
+ ### MonocleEntity.Inference
39
+ The model hosting infrastructure services. Supported types are -
40
+ - generic
41
+ - nvidia_triton
42
+ - openai
43
+ - azure_oai
44
+ - aws_sagemaker
45
+ - aws_bedrock
46
+ - hugging_face
47
+
48
+ ### MonocleEntity.VectorStore
49
+ Vector search data stores. Supported types are -
50
+ - generic
51
+ - chroma
52
+ - aws_es
53
+ - milvus
54
+ - pinecone
@@ -0,0 +1,157 @@
1
+ {
2
+ "description": "Monocle entities represents kinds GenAI technology components and their implementations supported by Monocle",
3
+ "monocle_entities": [
4
+ {
5
+ "attributes" : [
6
+ {
7
+ "attribute_name": "name",
8
+ "attribute_description": "Monocle entity name",
9
+ "required": true
10
+ },
11
+ {
12
+ "attribute_name": "type",
13
+ "attribute_description": "Monocle entity type",
14
+ "required": true
15
+ }
16
+ ],
17
+ "entities": [
18
+ {
19
+ "name": "workflow",
20
+ "attributes" : [],
21
+ "types": [
22
+ {
23
+ "type": "llama_index",
24
+ "attributes" : []
25
+ },
26
+ {
27
+ "type": "langchain",
28
+ "attributes" : []
29
+ },
30
+ {
31
+ "type": "haystack",
32
+ "attributes" : []
33
+ },
34
+ {
35
+ "type": "generic",
36
+ "attributes" : []
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ "name": "model",
42
+ "attributes" : [
43
+ {
44
+ "attribute_name": "model_name",
45
+ "attribute_description": "Model name",
46
+ "required": true
47
+ }
48
+ ],
49
+ "types": [
50
+ {
51
+ "type": "llm",
52
+ "attributes" : []
53
+ },
54
+ {
55
+ "type": "embedding",
56
+ "attributes" : []
57
+ },
58
+ {
59
+ "type": "generic",
60
+ "attributes" : []
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "name": "vector_store",
66
+ "attributes" : [],
67
+ "types": [
68
+ {
69
+ "type": "chroma",
70
+ "attributes" : []
71
+ },
72
+ {
73
+ "type": "aws_es",
74
+ "attributes" : []
75
+ },
76
+ {
77
+ "type": "milvus",
78
+ "attributes" : []
79
+ },
80
+ {
81
+ "type": "pinecone",
82
+ "attributes" : []
83
+ },
84
+ {
85
+ "type": "generic",
86
+ "attributes" : []
87
+ }
88
+ ]
89
+ },
90
+ {
91
+ "name": "app_hosting",
92
+ "attributes" : [],
93
+ "types": [
94
+ {
95
+ "type": "aws_lambda",
96
+ "attributes" : []
97
+ },
98
+ {
99
+ "type": "aws_sagemaker",
100
+ "attributes" : []
101
+ },
102
+ {
103
+ "type": "azure_func",
104
+ "attributes" : []
105
+ },
106
+ {
107
+ "type": "azure_mlw",
108
+ "attributes" : []
109
+ },
110
+ {
111
+ "type": "github_codespace",
112
+ "attributes" : []
113
+ },
114
+ {
115
+ "type": "generic",
116
+ "attributes" : []
117
+ }
118
+ ]
119
+ },
120
+ {
121
+ "name": "inference",
122
+ "attributes" : [],
123
+ "types": [
124
+ {
125
+ "type": "aws_sagemaker",
126
+ "attributes" : []
127
+ },
128
+ {
129
+ "type": "aws_bedrock",
130
+ "attributes" : []
131
+ },
132
+ {
133
+ "type": "azure_oai",
134
+ "attributes" : []
135
+ },
136
+ {
137
+ "type": "openai",
138
+ "attributes" : []
139
+ },
140
+ {
141
+ "type": "nvidia_triton",
142
+ "attributes" : []
143
+ },
144
+ {
145
+ "type": "hugging_face",
146
+ "attributes" : []
147
+ },
148
+ {
149
+ "type": "generic",
150
+ "attributes" : []
151
+ }
152
+ ]
153
+ }
154
+ ]
155
+ }
156
+ ]
157
+ }
@@ -0,0 +1,51 @@
1
+ # Monocle meta model:
2
+ # Monocle Entities --> Entity Type --> Entity
3
+
4
+ import enum
5
+
6
+ class MonocleEntity(enum):
7
+ # Supported Workflow/language frameworks
8
+ class Workflow(enum):
9
+ generic = 0
10
+ langchain = 1
11
+ llama_index = 2
12
+ haystack = 3
13
+
14
+ # Supported model types
15
+ class Model(enum):
16
+ generic = 0
17
+ llm = 1
18
+ embedding = 2
19
+
20
+ # Support Vector databases
21
+ class VectorStore(enum):
22
+ generic = 0
23
+ chroma = 1
24
+ aws_es = 2
25
+ Milvus = 3
26
+ Pinecone = 4
27
+
28
+ # Support application hosting frameworks
29
+ class AppHosting(enum):
30
+ generic = 0
31
+ aws_lambda = 1
32
+ aws_sagemaker = 2
33
+ azure_func = 3
34
+ github_codespace = 4
35
+ azure_mlw = 5
36
+
37
+ # Supported inference infra/services
38
+ class Inference(enum):
39
+ generic = 0
40
+ nvidia_triton = 1
41
+ openai = 2
42
+ azure_oai = 3
43
+ aws_sagemaker = 4
44
+ aws_bedrock = 5
45
+ hugging_face = 6
46
+
47
+ class SpanType(enum):
48
+ internal = 0
49
+ retrieval = 2
50
+ inference = 3
51
+ workflow = 4
@@ -0,0 +1,121 @@
1
+ # Monocle Span format
2
+ Monocle generates [traces](../../../../Monocle_User_Guide.md#traces) which comprises of [spans](../../../../Monocle_User_Guide.md#spans). Note that Monocle trace is [OpenTelemetry format](https://opentelemetry.io/docs/concepts/signals/traces/) compatible. Each span is essentially a step in the execution that interacts with one of more GenAI technology components. This document explains the [span format](./span_format.json) that Monocle generates for GenAI application tracing.
3
+
4
+ Per the OpenTelemetry convention, each span contains an attribute section and event section. In Monocle generated trace, the attribute sections includes details of GenAI entities used in the span. The event section includes the input, output and metadata related to the execution of that span.
5
+
6
+ ## Attributes
7
+ The attribute sections includes details of GenAI entities used in the span. For each entity used in the span in includes the entity name and entity type. For every type of entity, there are required and optional attributes listed below.
8
+ ### Json format
9
+ ```json
10
+ attributes:
11
+ "span.type": "Monocle-span-type",
12
+ "entity.count": "count-of-entities",
13
+
14
+ "entity.<index>.name": "Monocle-Entity-name",
15
+ "entity.<index>.type": "MonocleEntity.<entity-type>"
16
+ ...
17
+ ```
18
+ The ```entity.count``` indicates total number of entities used in the given span. For each entity, the details are captured in ```entity.<index>.X```. For example,
19
+ ```json
20
+ "attributes": {
21
+ "span.type": "Inference",
22
+ "entity.count": 2,
23
+ "entity.1.name": "AzureOpenAI",
24
+ "entity.1.type": "Inference.Azure_oai",
25
+ "entity.2.name": "gpt-35-turbo",
26
+ "entity.2.type": "Model.LLM",
27
+ "entity.2.model_name": "gpt-35-turbo",
28
+ ```
29
+
30
+ ### Entity type specific attributes
31
+ #### MonocleEntity.Workflow
32
+ | Name | Description | Values | Required |
33
+ | - | - | - | - |
34
+ | name | Entity name generated by Monocle | Name String | Required |
35
+ | type | Monocle Entity type | MonocleEntity.Workflow | Required |
36
+ | optional-attribute | Additional attribute specific to entity | | Optional |
37
+
38
+ ### MonocleEntity.Model
39
+ | Name | Description | Values | Required |
40
+ | - | - | - | - |
41
+ | name | Entity name generated by Monocle | Name String | Required |
42
+ | type | Monocle Entity type | MonocleEntity.Model | Required |
43
+ | model_name | Name of model | String | Required |
44
+ | optional-attribute | Additional attribute specific to entity | | Optional |
45
+
46
+ ### MonocleEntity.AppHosting
47
+ | Name | Description | Values | Required |
48
+ | - | - | - | - |
49
+ | name | Entity name generated by Monocle | Name String | Required |
50
+ | type | Monocle Entity type | MonocleEntity.AppHosting | Required |
51
+ | optional-attribute | Additional attribute specific to entity | | Optional |
52
+
53
+ ### MonocleEntity.Inference
54
+ | Name | Description | Values | Required |
55
+ | - | - | - | - |
56
+ | name | Entity name generated by Monocle | Name String | Required |
57
+ | type | Monocle Entity type | MonocleEntity.Inference | Required |
58
+ | optional-attribute | Additional attribute specific to entity | | Optional |
59
+
60
+ ### MonocleEntity.VectorDB
61
+ | Name | Description | Values | Required |
62
+ | - | - | - | - |
63
+ | name | Entity name generated by Monocle | Name String | Required |
64
+ | type | Monocle Entity type | MonocleEntity.VectorDB | Required |
65
+ | optional-attribute | Additional attribute specific to entity | | Optional |
66
+
67
+ ## Events
68
+ The event section includes the input, output and metadata generated by that span execution. For each type of span, there are required and option input, output and metadata items listed below. If there's no data genearated in the space, the events will be an empty array.
69
+
70
+ ### Json format
71
+ ```json
72
+ "events" : [
73
+ {
74
+ "name": "data.input",
75
+ "timestamp": "UTC timestamp",
76
+ "attributes": {
77
+ "input_attribute": "value"
78
+ }
79
+ },
80
+ {
81
+ "name": "data.output",
82
+ "timestamp": "UTC timestamp",
83
+ "attributes": {
84
+ "output_attribute": "value"
85
+ }
86
+ },
87
+ {
88
+ "name": "metadata",
89
+ "timestamp": "UTC timestamp",
90
+ "attributes": {
91
+ "metadata_attribute": "value"
92
+ }
93
+ }
94
+ ]
95
+ ```
96
+
97
+ ## Span types and events
98
+ The ```span.type``` captured in ```attributes``` section of the span dectates the format of the ```events```
99
+ ### SpanType.Retrieval
100
+ | Name | Description | Values | Required |
101
+ | - | - | - | - |
102
+ | name | event name | data.input or data.output or metadata | Required |
103
+ | timestamp | timestap when the event occurred | UTC timestamp | Required |
104
+ | attributes | input/output/metadata attributes generated in span | Dictionary | Required |
105
+
106
+ ### SpanType.Inference
107
+ | Name | Description | Values | Required |
108
+ | - | - | - | - |
109
+ | name | event name | data.input or data.output or metadata | Required |
110
+ | timestamp | timestap when the event occurred | UTC timestamp | Required |
111
+ | attributes | input/output/metadata attributes generated in span | Dictionary | Required |
112
+
113
+ ### SpanType.Workflow
114
+ | Name | Description | Values | Required |
115
+ | - | - | - | - |
116
+ | name | event name | data.input or data.output or metadata | Required |
117
+ | timestamp | timestap when the event occurred | UTC timestamp | Required |
118
+ | attributes | input/output/metadata attributes generated in span | Dictionary | Required |
119
+
120
+ ### SpanType.Internal
121
+ Events will be empty
@@ -0,0 +1,140 @@
1
+ {
2
+ "name": "llamaindex.retrieve",
3
+ "context": {
4
+ "trace_id": "0x93cd0bf865b3ffcc3cf9c075dc3e3797",
5
+ "span_id": "0x5d3f839e900bda24",
6
+ "trace_state": "[]"
7
+ },
8
+ "kind": "SpanKind.CLIENT",
9
+ "parent_id": "0x7a63d63e42ccac60",
10
+ "start_time": "2024-09-09T14:38:45.237182Z",
11
+ "end_time": "2024-09-09T14:38:45.620112Z",
12
+ "status": {
13
+ "status_code": "OK"
14
+ },
15
+ "attributes": {
16
+ "span.type": "Retrieval",
17
+ "entity.count": 2,
18
+ "entity.1.name": "ChromaVectorStore",
19
+ "entity.1.type": "vectorstore.chroma",
20
+ "entity.1.embedding-model-name": "BAAI/bge-small-en-v1.5",
21
+ "entity.2.name": "BAAI/bge-small-en-v1.5",
22
+ "entity.2.type": "model.embedding",
23
+ "entity.2.model_name": "BAAI/bge-small-en-v1.5"
24
+ },
25
+ "events": [
26
+ {
27
+ "name": "data.input",
28
+ "timestamp": "timestamp",
29
+ "attributes": {
30
+ "context_input": "question: What is an americano?"
31
+ }
32
+ },
33
+ {
34
+ "name": "data.output",
35
+ "timestamp": "timestamp",
36
+ "attributes": {
37
+ "context_output": "Coffee is a hot drink made from the roasted and ground seeds (coffee beans) of a tropical shrub\nA latte consists of one or more shots of espresso, served in a glass (or sometimes a cup), into which hot steamed milk is added\nAmericano is a type of coffee drink prepared by diluting an espresso shot with hot water at a 1:3 to 1:4 ratio, resulting in a drink that retains the complex flavors of espresso, but in a lighter way"
38
+ }
39
+ }
40
+
41
+ ],
42
+ "links": [],
43
+ "resource": {
44
+ "attributes": {
45
+ "service.name": "coffee-bot"
46
+ },
47
+ "schema_url": ""
48
+ }
49
+ },
50
+ {
51
+ "name": "llamaindex.openai",
52
+ "context": {
53
+ "trace_id": "0x93cd0bf865b3ffcc3cf9c075dc3e3797",
54
+ "span_id": "0x8b6363e1937a4d7b",
55
+ "trace_state": "[]"
56
+ },
57
+ "kind": "SpanKind.CLIENT",
58
+ "parent_id": "0x7a63d63e42ccac60",
59
+ "start_time": "2024-09-09T14:38:45.622174Z",
60
+ "end_time": "2024-09-09T14:38:46.514120Z",
61
+ "status": {
62
+ "status_code": "OK"
63
+ },
64
+ "attributes": {
65
+ "span.type": "inference",
66
+ "entity.count": 2,
67
+ "entity.1.name": "AzureOpenAI",
68
+ "entity.1.type": "inference.azure_oai",
69
+ "entity.1.provider_name": "openai.azure.com",
70
+ "entity.1.deployment": "kshitiz-gpt",
71
+ "entity.1.inference_endpoint": "https://okahu-openai-dev.openai.azure.com/",
72
+
73
+ "entity.2.name": "gpt-35-turbo",
74
+ "entity.2.type": "model.llm",
75
+ "entity.2.model_name": "gpt-35-turbo"
76
+ },
77
+ "events": [
78
+ {
79
+ "name": "data.input",
80
+ "timestamp": "timestamp",
81
+ "attributes": {
82
+ "question": "What is an americano?",
83
+ }
84
+ },
85
+ {
86
+ "name": "data.output",
87
+ "timestamp": "timestamp",
88
+ "attributes": {
89
+ "response": "An americano is a type of coffee drink that is made by diluting an espresso shot with hot water at a 1:3 to 1:4 ratio, resulting in a drink that retains the complex flavors of espresso, but in a lighter way.",
90
+ }
91
+ },
92
+ {
93
+ "name": "metadata",
94
+ "timestamp": "timestamp",
95
+ "attributes": {
96
+ "temperature": 0.1,
97
+ "completion_tokens": 52,
98
+ "prompt_tokens": 233,
99
+ "total_tokens": 285
100
+ }
101
+ }
102
+ ],
103
+ "links": [],
104
+ "resource": {
105
+ "attributes": {
106
+ "service.name": "coffee-bot"
107
+ },
108
+ "schema_url": ""
109
+ }
110
+ }
111
+ {
112
+ "name": "llamaindex.query",
113
+ "context": {
114
+ "trace_id": "0x93cd0bf865b3ffcc3cf9c075dc3e3797",
115
+ "span_id": "0x7a63d63e42ccac60",
116
+ "trace_state": "[]"
117
+ },
118
+ "kind": "SpanKind.CLIENT",
119
+ "parent_id": null,
120
+ "start_time": "2024-09-09T14:38:45.236627Z",
121
+ "end_time": "2024-09-09T14:38:46.514442Z",
122
+ "status": {
123
+ "status_code": "OK"
124
+ },
125
+ "attributes": {
126
+ "span.type": "workflow",
127
+ "entity.count": 1,
128
+ "entity.1.name": "coffee-bot",
129
+ "entity.1.type": "workflow.llama_index"
130
+ },
131
+ "events": [
132
+ ],
133
+ "links": [],
134
+ "resource": {
135
+ "attributes": {
136
+ "service.name": "coffee-bot"
137
+ },
138
+ "schema_url": ""
139
+ }
140
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "span-name",
3
+ "context": {
4
+ "trace_id": "trace-id",
5
+ "span_id": "span-id",
6
+ "trace_state": "[]"
7
+ },
8
+ "kind": "SpanKind.CLIENT",
9
+ "parent_id": "parent-id or None (for root span)",
10
+ "start_time": "UTC timestamp",
11
+ "end_time": "UTC timestamp",
12
+ "status": {
13
+ "status_code": "OK or Error"
14
+ },
15
+ "attributes": {
16
+ "description": "List of AI component entities used in this span, eg Model, Inference hosting service. Needs to be one of the supported entity types.",
17
+
18
+ "span.type": "Monocle-span-type",
19
+ "entity.count": "count-of-entities",
20
+
21
+ "entity.<index>.name": "Monocle-Entity-name",
22
+ "entity.<index>.type": "Monocle-Entity-Type",
23
+ "entity.<index>.<attribute>": "Value"
24
+ },
25
+ "events" : [
26
+ {
27
+ "name": "data.input",
28
+ "timestamp": "UTC timestamp",
29
+ "attributes": {
30
+ "input_attribute": "value"
31
+ }
32
+ },
33
+ {
34
+ "name": "data.output",
35
+ "timestamp": "UTC timestamp",
36
+ "attributes": {
37
+ "output_attribute": "value"
38
+ }
39
+ },
40
+ {
41
+ "name": "metadata",
42
+ "timestamp": "UTC timestamp",
43
+ "attributes": {
44
+ "metadata_attribute": "value"
45
+ }
46
+ }
47
+ ],
48
+ "links": [],
49
+ "resource": {
50
+ "attributes": {
51
+ "service.name": "top-workflow-name"
52
+ },
53
+ "schema_url": ""
54
+ }
55
+ }
monocle_apptrace/utils.py CHANGED
@@ -5,6 +5,8 @@ import os
5
5
  from opentelemetry.trace import Span
6
6
  from monocle_apptrace.constants import azure_service_map, aws_service_map
7
7
 
8
+ embedding_model_context = {}
9
+
8
10
  def set_span_attribute(span, name, value):
9
11
  if value is not None:
10
12
  if value != "":
@@ -71,3 +73,21 @@ def update_span_with_infra_name(span: Span, span_key: str):
71
73
  for key,val in aws_service_map.items():
72
74
  if key in os.environ:
73
75
  span.set_attribute(span_key, val)
76
+
77
+
78
+ def set_embedding_model(model_name: str):
79
+ """
80
+ Sets the embedding model in the global context.
81
+
82
+ @param model_name: The name of the embedding model to set
83
+ """
84
+ embedding_model_context['embedding_model'] = model_name
85
+
86
+
87
+ def get_embedding_model() -> str:
88
+ """
89
+ Retrieves the embedding model from the global context.
90
+
91
+ @return: The name of the embedding model, or 'unknown' if not set
92
+ """
93
+ return embedding_model_context.get('embedding_model', 'unknown')
@@ -4,7 +4,7 @@ import os
4
4
  from urllib.parse import urlparse
5
5
 
6
6
  from opentelemetry.trace import Span, Tracer
7
- from monocle_apptrace.utils import resolve_from_alias, update_span_with_infra_name, with_tracer_wrapper
7
+ from monocle_apptrace.utils import resolve_from_alias, update_span_with_infra_name, with_tracer_wrapper, get_embedding_model
8
8
 
9
9
  logger = logging.getLogger(__name__)
10
10
  WORKFLOW_TYPE_KEY = "workflow_type"
@@ -15,9 +15,12 @@ PROMPT_OUTPUT_KEY = "output"
15
15
  QUERY = "question"
16
16
  RESPONSE = "response"
17
17
  TAGS = "tags"
18
- CONTEXT_PROPERTIES_KEY = "workflow_context_properties"
18
+ SESSION_PROPERTIES_KEY = "session"
19
19
  INFRA_SERVICE_KEY = "infra_service_name"
20
-
20
+ TYPE = "type"
21
+ PROVIDER = "provider_name"
22
+ EMBEDDING_MODEL = "embedding_model"
23
+ VECTOR_STORE = 'vector_store'
21
24
 
22
25
 
23
26
  WORKFLOW_TYPE_MAP = {
@@ -26,6 +29,24 @@ WORKFLOW_TYPE_MAP = {
26
29
  "haystack": "workflow.haystack"
27
30
  }
28
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
+
29
50
  @with_tracer_wrapper
30
51
  def task_wrapper(tracer: Tracer, to_wrap, wrapped, instance, args, kwargs):
31
52
  """Instruments and calls every function defined in TO_WRAP."""
@@ -66,6 +87,7 @@ def pre_task_processing(to_wrap, instance, args, span):
66
87
  #capture the tags attribute of the instance if present, else ignore
67
88
  try:
68
89
  update_tags(instance, span)
90
+ update_vectorstore_attributes(to_wrap, instance, span)
69
91
  except AttributeError:
70
92
  pass
71
93
  update_span_with_context_input(to_wrap=to_wrap, wrapped_args=args, span=span)
@@ -133,6 +155,8 @@ def llm_wrapper(tracer: Tracer, to_wrap, wrapped, instance, args, kwargs):
133
155
  else:
134
156
  name = f"langchain.task.{instance.__class__.__name__}"
135
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)
136
160
  update_llm_endpoint(curr_span= span, instance=instance)
137
161
 
138
162
  return_value = wrapped(*args, **kwargs)
@@ -148,12 +172,12 @@ def update_llm_endpoint(curr_span: Span, instance):
148
172
  if 'temperature' in instance.__dict__:
149
173
  temp_val = instance.__dict__.get("temperature")
150
174
  curr_span.set_attribute("temperature", temp_val)
151
- # handling for model name
152
- model_name = resolve_from_alias(instance.__dict__ , ["model","model_name"])
175
+ # handling for model name
176
+ model_name = resolve_from_alias(instance.__dict__ , ["model","model_name"])
153
177
  curr_span.set_attribute("model_name", model_name)
154
178
  set_provider_name(curr_span, instance)
155
179
  # handling AzureOpenAI deployment
156
- deployment_name = resolve_from_alias(instance.__dict__ , [ "engine", "azure_deployment",
180
+ deployment_name = resolve_from_alias(instance.__dict__ , [ "engine", "azure_deployment",
157
181
  "deployment_name", "deployment_id", "deployment"])
158
182
  curr_span.set_attribute("az_openai_deployment", deployment_name)
159
183
  # handling the inference endpoint
@@ -191,7 +215,6 @@ def get_input_from_args(chain_args):
191
215
  return ""
192
216
 
193
217
  def update_span_from_llm_response(response, span: Span):
194
-
195
218
  # extract token uasge from langchain openai
196
219
  if (response is not None and hasattr(response, "response_metadata")):
197
220
  response_metadata = response.response_metadata
@@ -266,3 +289,23 @@ def update_tags(instance, span):
266
289
  span.set_attribute(TAGS, [model_name, vector_store_name])
267
290
  except:
268
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}")
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.3
2
+ Name: monocle_apptrace
3
+ Version: 0.1.1
4
+ Summary: package with monocle genAI tracing
5
+ Project-URL: Homepage, https://github.com/monocle2ai/monocle
6
+ Project-URL: Issues, https://github.com/monocle2ai/monocle/issues
7
+ License-File: LICENSE
8
+ License-File: NOTICE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.8
13
+ Requires-Dist: opentelemetry-api>=1.21.0
14
+ Requires-Dist: opentelemetry-instrumentation
15
+ Requires-Dist: opentelemetry-sdk>=1.21.0
16
+ Requires-Dist: requests
17
+ Requires-Dist: wrapt>=1.14.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: datasets==2.20.0; extra == 'dev'
20
+ Requires-Dist: faiss-cpu==1.8.0; extra == 'dev'
21
+ Requires-Dist: instructorembedding==1.0.1; extra == 'dev'
22
+ Requires-Dist: langchain-chroma==0.1.1; extra == 'dev'
23
+ Requires-Dist: langchain-community==0.2.5; extra == 'dev'
24
+ Requires-Dist: langchain-openai==0.1.8; extra == 'dev'
25
+ Requires-Dist: langchain==0.2.5; extra == 'dev'
26
+ Requires-Dist: llama-index-embeddings-huggingface==0.2.0; extra == 'dev'
27
+ Requires-Dist: llama-index-vector-stores-chroma==0.1.9; extra == 'dev'
28
+ Requires-Dist: llama-index==0.10.30; extra == 'dev'
29
+ Requires-Dist: numpy==1.26.4; extra == 'dev'
30
+ Requires-Dist: parameterized==0.9.0; extra == 'dev'
31
+ Requires-Dist: pytest==8.0.0; extra == 'dev'
32
+ Requires-Dist: sentence-transformers==2.6.1; extra == 'dev'
33
+ Requires-Dist: types-requests==2.31.0.20240106; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # Monocle for tracing GenAI app code
37
+
38
+ **Monocle** helps developers and platform engineers building or managing GenAI apps monitor these in prod by making it easy to instrument their code to capture traces that are compliant with open-source cloud-native observability ecosystem.
39
+
40
+ **Monocle** is a community-driven OSS framework for tracing GenAI app code governed as a [Linux Foundation AI & Data project](https://lfaidata.foundation/projects/monocle/).
41
+
42
+ ## Why Monocle
43
+
44
+ Monocle is built for:
45
+ - **app developers** to trace their app code in any environment without lots of custom code decoration
46
+ - **platform engineers** to instrument apps in prod through wrapping instead of asking app devs to recode
47
+ - **GenAI component providers** to add observability features to their products
48
+ - **enterprises** to consume traces from GenAI apps in their existing open-source observability stack
49
+
50
+ Benefits:
51
+ - Monocle provides an implementation + package, not just a spec
52
+ - No expertise in OpenTelemetry spec required
53
+ - No bespoke implementation of that spec required
54
+ - No last-mile GenAI domain specific code required to instrument your app
55
+ - Monocle provides consistency
56
+ - Connect traces across app code executions, model inference or data retrievals
57
+ - No cleansing of telemetry data across GenAI component providers required
58
+ - Works the same in personal lab dev or org cloud prod environments
59
+ - Send traces to location that fits your scale, budget and observability stack
60
+ - Monocle is fully open source and community driven
61
+ - No vendor lock-in
62
+ - Implementation is transparent
63
+ - You can freely use or customize it to fit your needs
64
+
65
+ ## What Monocle provides
66
+
67
+ - Easy to [use](#use-monocle) code instrumentation
68
+ - OpenTelemetry compatible format for [spans](src/monocle_apptrace/metamodel/spans/span_format.json).
69
+ - Community-curated and extensible [metamodel](src/monocle_apptrace/metamodel/README.md) for consisent tracing of GenAI components.
70
+ - Export to local and cloud storage
71
+
72
+ ## Use Monocle
73
+
74
+ - Get the Monocle package
75
+
76
+ ```
77
+ pip install monocle_apptrace
78
+ ```
79
+ - Instrument your app code
80
+ - Import the Monocle package
81
+ ```
82
+ from monocle_apptrace.instrumentor import setup_monocle_telemetry
83
+ ```
84
+ - Setup instrumentation in your ```main()``` function
85
+ ```
86
+ setup_monocle_telemetry(workflow_name="your-app-name")
87
+ ```
88
+ - (Optionally) Modify config to alter where traces are sent
89
+
90
+ See [Monocle user guide](Monocle_User_Guide.md) for more details.
91
+
92
+
93
+ ## Roadmap
94
+
95
+ Goal of Monocle is to support tracing for apps written in *any language* with *any LLM orchestration or agentic framework* and built using models, vectors, agents or other components served up by *any cloud or model inference provider*.
96
+
97
+ Current version supports:
98
+ - Language: (🟢) Python , (🔜) [Typescript](https://github.com/monocle2ai/monocle-typescript)
99
+ - LLM-frameworks: (🟢) Langchain, (🟢) Llamaindex, (🟢) Haystack, (🔜) Flask
100
+ - LLM inference providers: (🟢) OpenAI, (🟢) Azure OpenAI, (🟢) Nvidia Triton, (🔜) AWS Bedrock, (🔜) Google Vertex, (🔜) Azure ML, (🔜) Hugging Face
101
+ - Vector stores: (🟢) FAISS, (🔜) OpenSearch, (🔜) Milvus
102
+ - Exporter: (🟢) stdout, (🟢) file, (🔜) Azure Blob Storage, (🔜) AWS S3, (🔜) Google Cloud Storage
103
+
104
+
105
+ ## Get involved
106
+ ### Provide feedback
107
+ - Submit issues and enhancements requests via Github issues
108
+
109
+ ### Contribute
110
+ - Monocle is community based open source project. We welcome your contributions. Please refer to the CONTRIBUTING and CODE_OF_CONDUCT for guidelines. The [contributor's guide](CONTRIBUTING.md) provides technical details of the project.
111
+
@@ -0,0 +1,29 @@
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,,
@@ -1,77 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: monocle_apptrace
3
- Version: 0.1.0
4
- Summary: package with monocle genAI tracing
5
- Project-URL: Homepage, https://github.com/monocle2ai/monocle
6
- Project-URL: Issues, https://github.com/monocle2ai/monocle/issues
7
- License-File: LICENSE
8
- License-File: NOTICE
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.8
13
- Requires-Dist: opentelemetry-api>=1.21.0
14
- Requires-Dist: opentelemetry-instrumentation
15
- Requires-Dist: opentelemetry-sdk>=1.21.0
16
- Requires-Dist: requests
17
- Requires-Dist: wrapt>=1.14.0
18
- Provides-Extra: dev
19
- Requires-Dist: datasets==2.20.0; extra == 'dev'
20
- Requires-Dist: faiss-cpu==1.8.0; extra == 'dev'
21
- Requires-Dist: instructorembedding==1.0.1; extra == 'dev'
22
- Requires-Dist: langchain-chroma==0.1.1; extra == 'dev'
23
- Requires-Dist: langchain-community==0.2.5; extra == 'dev'
24
- Requires-Dist: langchain-openai==0.1.8; extra == 'dev'
25
- Requires-Dist: langchain==0.2.5; extra == 'dev'
26
- Requires-Dist: llama-index-embeddings-huggingface==0.2.0; extra == 'dev'
27
- Requires-Dist: llama-index-vector-stores-chroma==0.1.9; extra == 'dev'
28
- Requires-Dist: llama-index==0.10.30; extra == 'dev'
29
- Requires-Dist: numpy==1.26.4; extra == 'dev'
30
- Requires-Dist: parameterized==0.9.0; extra == 'dev'
31
- Requires-Dist: pytest==8.0.0; extra == 'dev'
32
- Requires-Dist: sentence-transformers==2.6.1; extra == 'dev'
33
- Requires-Dist: types-requests==2.31.0.20240106; extra == 'dev'
34
- Description-Content-Type: text/markdown
35
-
36
- # monocle genAI observability
37
- ### Background
38
- Generative AI (GenAI) is the type of AI used to create content such as conversations, images, or video based on prior learning from existing content. GenAI relies on foundational models, which are exceptionally large ML models trained on vast amounts of generalized and unlabeled data to perform variety of general tasks such as understanding language and generating new text, audio or images from user provided prompts in a human language. Foundational models (FM) work by using learned patterns and relationships from the training data to predict the next item in a sequence given a prompt. It is cheaper and faster for data scientists to use foundational models as starting points rather than building models from scratch to build ML apps.
39
- Large Language Models (LLMs) are a class of foundational models trained on text data used to perform a variety of tasks such as understanding language, reasoning over text, and generating new text based on user prompts in a human language. Examples of LLMs include ChatGPT, Llama, and Claude.
40
- LLM-based AI apps leverage understanding language, reasoning & text generation to augment or automate complex tasks that typically require human intervention such as summarizing legal documents, triaging customer support tickets, or more.
41
- Typically, AI developers build LLM-based AI apps that automate complex workflows by combining multiple LLMs and components such as prompts, vectors, or agents that each solve a discrete task that are connected by chains or pipelines in different ways using LLM (Large Language Model) orchestration frameworks.
42
- When deployed to production, different parts of multi-component distributed LLM-based AI apps run on a combination of different kinds of AI infrastructure such as LLM-as-a-Service, GPU (graphics processing units) clouds, managed services from cloud, or custom-engineered AI stack. Typically, these systems are managed in production by IT DevOps engineers.
43
- AI developers code, monitor, debug and optimize the resources in an LLM-based AI application. IT DevOps engineers monitor, troubleshoot, and optimize the services in the AI infra that the LLM-based AI application runs on.
44
-
45
- ## Introducing “Monocle – An eye for A.I.”
46
- The goal of project Monocle is to help GenAI developer to trace their applications. A typical GenAI application comprises of several technology components like application code/workflow, models, inferences services, vector databases etc. Understanding the dependencies and tracking application quickly becomes a difficult task. Monocle can be integrated into application code with very little to no code changes. Monocle supports tracing all GenAI technology components, application frameworks, LLM hosting services. We do all the hard work of finding what needs to be instrumented and how to instrument it. This enables the enlightened applications to generate detailed traces without any additional efforts from the developers.
47
- The traces are compatible with OpenTelemetry format. They are further enriched to contain lot more attribute relevant to GenAI applications like prompts. The project will have out of box support to store the traces locally and a extensibility for a third party store which can be implemented by end user or a supplied by third party vendors.
48
-
49
- ## Monocle integration
50
- ### genAI Appliation frameworks
51
- - Langchain
52
- - LlamaIndex
53
- - Haystack
54
- ### LLMs
55
- - OpenAI
56
- - Azure OpenAI
57
- - NVIDIA Triton
58
-
59
- ## Getting started
60
- ### Try Monocle with your python genAI application
61
- - Get latest Monocle python brary
62
- ```
63
- pip install monocle_apptrace
64
- ```
65
- - Enable Monocle tracing in your app by adding following
66
- ```
67
- setup_monocle_telemetry(workflow_name="your-app-name")
68
- ```
69
- Please refer to [Monocle user guide](Monocle_User_Guide.md) for more details
70
-
71
- ## Get involved
72
- ### Provide feedback
73
- - Submit issues and enhancements requests via Github issues
74
-
75
- ### Contribute
76
- - Monocle is community based open source project. We welcome your contributions. Please refer to the CONTRIBUTING and CODE_OF_CONDUCT for guidelines. The [contributor's guide](CONTRIBUTING.md) provides technical details of the project.
77
-
@@ -1,22 +0,0 @@
1
- monocle_apptrace/README.md,sha256=OVJgf1_HAm5L2-FSDZ-3AYfBjSxiT4fhE_CgKVaDVuQ,3104
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=IDCuqzvTLzYKBzHGX3q1gbiboq07LMkdOA8DhOUTEEU,5051
5
- monocle_apptrace/utils.py,sha256=VMiWscPCNjp29IQE3ahprXjkfiMw160DbCo8WrjQCXk,2658
6
- monocle_apptrace/wrap_common.py,sha256=zbYlhL7V655exfdE0h_aT6-THmmHL1ltzsm4cBZ4jq8,10875
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=zcluKUIu1M9g_B3s_ZfzRS_vr7yMz5gj-6rqQ7bJ5B0,318
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=xRYMRzxvFPdcJ64E0bbMdMuWO_p3V1T7eIvb3-Um5DE,1661
13
- monocle_apptrace/langchain/__init__.py,sha256=HhvRJ_rl9cX4M8ckiOkJC7QHbklrttaY9RvDC51m1l4,268
14
- monocle_apptrace/llamaindex/__init__.py,sha256=3zmSNoVDjB-hh_M4eUr-hUP0bup7HKmWFVv_3xPAwsA,570
15
- monocle_apptrace/wrapper_config/haystack_methods.json,sha256=JmngkaKICAzOyrWNTWEOLYFrp99l5wcERYKE_SQRNxE,698
16
- monocle_apptrace/wrapper_config/lang_chain_methods.json,sha256=HaOhhxb3PkI7tXPxXhWR4cnWrnEHU--k5pOY9RS0Uew,3119
17
- monocle_apptrace/wrapper_config/llama_index_methods.json,sha256=qpODnBHkaDjPBYZNd7clwmp_2subTu-fmI08Ky5OWdg,2192
18
- monocle_apptrace-0.1.0.dist-info/METADATA,sha256=sQfm_x1NFthDhfMKX_ZDE0E5bDLSxUOtV1v6yXt0Wpc,5699
19
- monocle_apptrace-0.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
20
- monocle_apptrace-0.1.0.dist-info/licenses/LICENSE,sha256=ay9trLiP5I7ZsFXo6AqtkLYdRqe5S9r-DrPOvsNlZrg,9136
21
- monocle_apptrace-0.1.0.dist-info/licenses/NOTICE,sha256=9jn4xtwM_uUetJMx5WqGnhrR7MIhpoRlpokjSTlyt8c,112
22
- monocle_apptrace-0.1.0.dist-info/RECORD,,