monocle-apptrace 0.4.2__tar.gz → 0.5.0__tar.gz
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-0.4.2 → monocle_apptrace-0.5.0}/CHANGELOG.md +38 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/PKG-INFO +27 -11
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/pyproject.toml +28 -12
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/__main__.py +1 -1
- monocle_apptrace-0.5.0/src/monocle_apptrace/exporters/file_exporter.py +182 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/common/__init__.py +17 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/constants.py +14 -1
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/instrumentor.py +19 -152
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/common/method_wrappers.py +376 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/span_handler.py +58 -32
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/utils.py +52 -15
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/wrapper.py +124 -18
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/wrapper_method.py +47 -1
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/a2a/_helper.py +37 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/a2a/entities/inference.py +112 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/a2a/methods.py +22 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/adk/_helper.py +182 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/adk/entities/agent.py +50 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/adk/entities/tool.py +57 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/adk/methods.py +24 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/agents/_helper.py +220 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/agents/agents_processor.py +152 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/agents/entities/inference.py +191 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/agents/methods.py +56 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/aiohttp/_helper.py +6 -11
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/anthropic/_helper.py +183 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/anthropic/entities/inference.py +18 -10
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azfunc/_helper.py +13 -11
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/azfunc/entities/http.py +56 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azureaiinference/_helper.py +88 -8
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azureaiinference/entities/inference.py +22 -8
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/botocore/_helper.py +92 -16
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py +13 -8
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/botocore/handlers/botocore_span_handler.py +1 -1
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/fastapi/_helper.py +82 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/fastapi/entities/http.py +44 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/fastapi/methods.py +23 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/finish_types.py +463 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/flask/_helper.py +6 -11
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/gemini/_helper.py +51 -7
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/gemini/entities/inference.py +22 -11
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/gemini/entities/retrieval.py +43 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/gemini/methods.py +31 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/haystack/_helper.py +79 -8
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/haystack/entities/inference.py +15 -10
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/haystack/methods.py +7 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/lambdafunc/_helper.py +78 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/azfunc → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/lambdafunc}/entities/http.py +6 -6
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/lambdafunc/methods.py +23 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/lambdafunc/wrapper.py +23 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langchain/_helper.py +267 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/langchain/entities/inference.py +19 -10
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langgraph/_helper.py +105 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langgraph/entities/inference.py +163 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langgraph/langgraph_processor.py +46 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langgraph/methods.py +40 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/litellm/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/litellm/_helper.py +89 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/litellm/entities/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/litellm/entities/inference.py +108 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/litellm/methods.py +19 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/llamaindex/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/llamaindex/_helper.py +395 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/llamaindex/entities/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/llamaindex/entities/agent.py +164 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/llamaindex/entities/inference.py +13 -8
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/llamaindex/llamaindex_processor.py +62 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/llamaindex/methods.py +68 -1
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/mcp/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/mcp/_helper.py +118 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/mcp/entities/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/mcp/entities/inference.py +48 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/mcp/mcp_processor.py +8 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/mcp/methods.py +21 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/openai/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/openai/_helper.py +318 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/openai/entities/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/openai/entities/inference.py +286 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/openai/entities/retrieval.py +1 -1
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/teamsai/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/teamsai/_helper.py +53 -23
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/teamsai/entities/__init__.py +0 -0
- monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/actionplanner_output_processor.py +1 -1
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/teamsai_output_processor.py +15 -9
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/teamsai/sample.json +0 -4
- monocle_apptrace-0.4.2/src/monocle_apptrace/exporters/file_exporter.py +0 -94
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/common/__init__.py +0 -2
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/anthropic/_helper.py +0 -89
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/gemini/methods.py +0 -14
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langchain/_helper.py +0 -141
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langgraph/_helper.py +0 -48
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langgraph/entities/inference.py +0 -56
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langgraph/methods.py +0 -14
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/llamaindex/_helper.py +0 -184
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/llamaindex/entities/agent.py +0 -47
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/openai/_helper.py +0 -146
- monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/openai/entities/inference.py +0 -230
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/.gitignore +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/CODEOWNERS.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/CODE_OF_CONDUCT.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/CONTRIBUTING.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/COPYRIGHT.template +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/LICENSE +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/MAINTAINER.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/Monocle_User_Guide.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/Monocle_committer_guide.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/Monocle_contributor_guide.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/NOTICE +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/README.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/SECURITY.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/README.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/aws/s3_exporter.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/aws/s3_exporter_opendal.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/azure/blob_exporter.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/azure/blob_exporter_opendal.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/base_exporter.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/exporter_processor.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/monocle_exporters.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/exporters/okahu/okahu_exporter.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/common/tracing.md +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/aiohttp → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/a2a}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/anthropic → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/a2a/entities}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/anthropic/entities → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/adk}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/botocore → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/agents}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/botocore → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/agents}/entities/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/flask → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/aiohttp}/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/aiohttp/entities/http.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/aiohttp/methods.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/gemini → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/anthropic}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/gemini → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/anthropic}/entities/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/anthropic/methods.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azfunc/methods.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azfunc/wrapper.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azureaiinference/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/azureaiinference/methods.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/haystack → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/botocore}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/haystack → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/botocore}/entities/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/botocore/methods.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langchain → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/fastapi}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langchain → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/fastapi}/entities/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langgraph → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/flask}/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/flask/entities/http.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/flask/methods.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/langgraph/entities → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/gemini}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/llamaindex → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/gemini/entities}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/llamaindex/entities → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/haystack}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/openai → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/haystack/entities}/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/haystack/entities/retrieval.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/openai/entities → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langchain}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/teamsai → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langchain/entities}/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/langchain/entities/retrieval.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/langchain/methods.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/teamsai/entities → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langgraph}/__init__.py +0 -0
- {monocle_apptrace-0.4.2/src/monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference → monocle_apptrace-0.5.0/src/monocle_apptrace/instrumentation/metamodel/langgraph/entities}/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/llamaindex/entities/retrieval.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/openai/methods.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/requests/__init__.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/requests/_helper.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/requests/entities/http.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/requests/methods.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/src/monocle_apptrace/instrumentation/metamodel/teamsai/methods.py +0 -0
- {monocle_apptrace-0.4.2 → monocle_apptrace-0.5.0}/tox.ini +0 -0
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
|
|
2
|
+
## Version 0.5.0 (2025-08-05)
|
|
3
|
+
|
|
4
|
+
- Fix missing inference span in google ADK ([#249](https://github.com/monocle2ai/monocle/pull/249))
|
|
5
|
+
- Added openai agents instrumentation ([#248](https://github.com/monocle2ai/monocle/pull/248))
|
|
6
|
+
- Google Agent development kit meta mode ([#247](https://github.com/monocle2ai/monocle/pull/247))
|
|
7
|
+
- Add Support for LiteLLM OpenAI and AzureOpenAI ([#246](https://github.com/monocle2ai/monocle/pull/246))
|
|
8
|
+
- Added inference subtype for langgrap, openai and anthropic ([#245](https://github.com/monocle2ai/monocle/pull/245))
|
|
9
|
+
- Add support for teams finish type, move finish types to metadata section ([#240](https://github.com/monocle2ai/monocle/pull/240))
|
|
10
|
+
- Fix integration tests ([#239](https://github.com/monocle2ai/monocle/pull/239))
|
|
11
|
+
- Add function_name attribute for Azure function ([#238](https://github.com/monocle2ai/monocle/pull/238))
|
|
12
|
+
- Added MCP and A2A ([#237](https://github.com/monocle2ai/monocle/pull/237))
|
|
13
|
+
- Add Metamodel for Lambda Func ([#236](https://github.com/monocle2ai/monocle/pull/236))
|
|
14
|
+
- Allow llm SDKs as workflow types ([#234](https://github.com/monocle2ai/monocle/pull/234))
|
|
15
|
+
- Add Sample Span for VertexAI ([#233](https://github.com/monocle2ai/monocle/pull/233))
|
|
16
|
+
- Add Haystack Gemini sample ([#232](https://github.com/monocle2ai/monocle/pull/232))
|
|
17
|
+
- Add Llama Index Gemini sample ([#231](https://github.com/monocle2ai/monocle/pull/231))
|
|
18
|
+
- Add workflow span name to all spans ([#230](https://github.com/monocle2ai/monocle/pull/230))
|
|
19
|
+
- Add Langchain Gemini sample ([#229](https://github.com/monocle2ai/monocle/pull/229))
|
|
20
|
+
- Add Embeddings Span in Gemini Metamodel ([#228](https://github.com/monocle2ai/monocle/pull/228))
|
|
21
|
+
- Agent metamodel updates for LangGraph ([#227](https://github.com/monocle2ai/monocle/pull/227))
|
|
22
|
+
- Add fastapi metamodel with fastapi tracid propogation testcase ([#226](https://github.com/monocle2ai/monocle/pull/226))
|
|
23
|
+
|
|
2
24
|
## Version 0.4.2 (2025-06-26)
|
|
3
25
|
|
|
4
26
|
- Add gemini instrumentation ([#220](https://github.com/monocle2ai/monocle/pull/220))
|
|
@@ -122,3 +144,19 @@
|
|
|
122
144
|
## 0.0.1 (Jul 17, 2024)
|
|
123
145
|
|
|
124
146
|
- First monocle release
|
|
147
|
+
|
|
148
|
+
- Add support for teams finish type, move finish types to metadata section ([#240](https://github.com/monocle2ai/monocle/pull/240))
|
|
149
|
+
- Fix integration tests ([#239](https://github.com/monocle2ai/monocle/pull/239))
|
|
150
|
+
- Add function_name attribute for Azure function ([#238](https://github.com/monocle2ai/monocle/pull/238))
|
|
151
|
+
- Added MCP and A2A ([#237](https://github.com/monocle2ai/monocle/pull/237))
|
|
152
|
+
- Add Metamodel for Lambda Func ([#236](https://github.com/monocle2ai/monocle/pull/236))
|
|
153
|
+
- Allow llm SDKs as workflow types ([#234](https://github.com/monocle2ai/monocle/pull/234))
|
|
154
|
+
- Add Sample Span for VertexAI ([#233](https://github.com/monocle2ai/monocle/pull/233))
|
|
155
|
+
- Add Haystack Gemini sample ([#232](https://github.com/monocle2ai/monocle/pull/232))
|
|
156
|
+
- Add Llama Index Gemini sample ([#231](https://github.com/monocle2ai/monocle/pull/231))
|
|
157
|
+
- Add workflow span name to all spans ([#230](https://github.com/monocle2ai/monocle/pull/230))
|
|
158
|
+
- Add Langchain Gemini sample ([#229](https://github.com/monocle2ai/monocle/pull/229))
|
|
159
|
+
- Add Embeddings Span in Gemini Metamodel ([#228](https://github.com/monocle2ai/monocle/pull/228))
|
|
160
|
+
- Agent metamodel updates for LangGraph ([#227](https://github.com/monocle2ai/monocle/pull/227))
|
|
161
|
+
- Add fastapi metamodel with fastapi tracid propogation testcase ([#226](https://github.com/monocle2ai/monocle/pull/226))
|
|
162
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: monocle_apptrace
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
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,43 +20,59 @@ Requires-Dist: boto3==1.37.24; 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: a2a-sdk==0.2.8; extra == 'dev'
|
|
23
24
|
Requires-Dist: anthropic-haystack; extra == 'dev'
|
|
24
|
-
Requires-Dist: anthropic==0.
|
|
25
|
+
Requires-Dist: anthropic==0.57.1; extra == 'dev'
|
|
25
26
|
Requires-Dist: azure-storage-blob==12.22.0; extra == 'dev'
|
|
26
27
|
Requires-Dist: boto3==1.37.24; extra == 'dev'
|
|
27
|
-
Requires-Dist: chromadb==1.0.
|
|
28
|
+
Requires-Dist: chromadb==1.0.15; extra == 'dev'
|
|
29
|
+
Requires-Dist: click==8.2.1; extra == 'dev'
|
|
28
30
|
Requires-Dist: datasets==2.20.0; extra == 'dev'
|
|
29
31
|
Requires-Dist: faiss-cpu==1.8.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: fastapi>=0.115.0; extra == 'dev'
|
|
30
33
|
Requires-Dist: flask; extra == 'dev'
|
|
34
|
+
Requires-Dist: google-adk==1.10.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: google-generativeai==0.8.5; extra == 'dev'
|
|
31
36
|
Requires-Dist: haystack-ai==2.3.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: httpx==0.28.1; extra == 'dev'
|
|
32
38
|
Requires-Dist: instructorembedding==1.0.1; extra == 'dev'
|
|
33
39
|
Requires-Dist: langchain-anthropic==0.3.13; extra == 'dev'
|
|
34
40
|
Requires-Dist: langchain-aws==0.2.23; extra == 'dev'
|
|
35
41
|
Requires-Dist: langchain-chroma==0.2.4; extra == 'dev'
|
|
36
42
|
Requires-Dist: langchain-community==0.3.24; extra == 'dev'
|
|
43
|
+
Requires-Dist: langchain-google-genai==2.1.8; extra == 'dev'
|
|
44
|
+
Requires-Dist: langchain-mcp-adapters==0.1.8; extra == 'dev'
|
|
37
45
|
Requires-Dist: langchain-mistralai==0.2.10; extra == 'dev'
|
|
38
46
|
Requires-Dist: langchain-openai==0.3.18; extra == 'dev'
|
|
39
47
|
Requires-Dist: langchain==0.3.25; extra == 'dev'
|
|
40
48
|
Requires-Dist: langchainhub==0.1.21; extra == 'dev'
|
|
41
|
-
Requires-Dist: langgraph==0.
|
|
42
|
-
Requires-Dist:
|
|
43
|
-
Requires-Dist: llama-index-
|
|
44
|
-
Requires-Dist: llama-index-llms-
|
|
45
|
-
Requires-Dist: llama-index-llms-
|
|
46
|
-
Requires-Dist: llama-index-
|
|
47
|
-
Requires-Dist: llama-index-
|
|
48
|
-
Requires-Dist: llama-index==0.
|
|
49
|
+
Requires-Dist: langgraph-supervisor==0.0.28; extra == 'dev'
|
|
50
|
+
Requires-Dist: langgraph==0.5.4; extra == 'dev'
|
|
51
|
+
Requires-Dist: llama-index-embeddings-huggingface==0.6.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: llama-index-llms-anthropic==0.8.1; extra == 'dev'
|
|
53
|
+
Requires-Dist: llama-index-llms-azure-openai==0.4.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: llama-index-llms-mistralai==0.7.0; extra == 'dev'
|
|
55
|
+
Requires-Dist: llama-index-llms-openai==0.5.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: llama-index-tools-mcp==0.3.0; extra == 'dev'
|
|
57
|
+
Requires-Dist: llama-index-vector-stores-chroma==0.5.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: llama-index-vector-stores-opensearch==0.6.0; extra == 'dev'
|
|
59
|
+
Requires-Dist: llama-index==0.13.0; extra == 'dev'
|
|
60
|
+
Requires-Dist: mcp==1.12.1; extra == 'dev'
|
|
49
61
|
Requires-Dist: mistral-haystack==0.0.2; extra == 'dev'
|
|
50
62
|
Requires-Dist: numpy==1.26.4; extra == 'dev'
|
|
63
|
+
Requires-Dist: openai-agents==0.2.6; extra == 'dev'
|
|
51
64
|
Requires-Dist: opendal==0.45.14; extra == 'dev'
|
|
52
65
|
Requires-Dist: opensearch-haystack==1.2.0; extra == 'dev'
|
|
53
66
|
Requires-Dist: opentelemetry-instrumentation-flask; extra == 'dev'
|
|
54
67
|
Requires-Dist: parameterized==0.9.0; extra == 'dev'
|
|
68
|
+
Requires-Dist: pydantic==2.11.7; extra == 'dev'
|
|
55
69
|
Requires-Dist: pytest-asyncio==0.26.0; extra == 'dev'
|
|
56
70
|
Requires-Dist: pytest==8.3.5; extra == 'dev'
|
|
71
|
+
Requires-Dist: python-dotenv>=1.1.0; extra == 'dev'
|
|
57
72
|
Requires-Dist: requests-aws4auth==1.2.3; extra == 'dev'
|
|
58
73
|
Requires-Dist: sentence-transformers==2.6.1; extra == 'dev'
|
|
59
74
|
Requires-Dist: types-requests==2.31.0.20240106; extra == 'dev'
|
|
75
|
+
Requires-Dist: uvicorn==0.35.0; extra == 'dev'
|
|
60
76
|
Description-Content-Type: text/markdown
|
|
61
77
|
|
|
62
78
|
# Monocle for tracing GenAI app code
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "monocle_apptrace"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
authors = []
|
|
9
9
|
description = "package with monocle genAI tracing"
|
|
10
10
|
readme = "README.md"
|
|
@@ -52,32 +52,48 @@ dev = [
|
|
|
52
52
|
'sentence-transformers==2.6.1',
|
|
53
53
|
'faiss-cpu==1.8.0',
|
|
54
54
|
'pytest==8.3.5',
|
|
55
|
-
'llama-index==0.
|
|
56
|
-
'llama-index-
|
|
57
|
-
'llama-index-
|
|
55
|
+
'llama-index==0.13.0',
|
|
56
|
+
'llama-index-llms-openai==0.5.0',
|
|
57
|
+
'llama-index-tools-mcp==0.3.0',
|
|
58
|
+
'llama-index-embeddings-huggingface==0.6.0',
|
|
59
|
+
'llama-index-vector-stores-chroma==0.5.0',
|
|
58
60
|
'parameterized==0.9.0',
|
|
59
|
-
'llama-index-llms-mistralai==0.
|
|
61
|
+
'llama-index-llms-mistralai==0.7.0',
|
|
60
62
|
'langchain-mistralai==0.2.10',
|
|
61
63
|
'mistral-haystack==0.0.2',
|
|
62
64
|
'langchain-aws==0.2.23',
|
|
63
65
|
'azure-storage-blob==12.22.0', # this is for blob exporter
|
|
64
66
|
'boto3==1.37.24', # this is for aws exporter
|
|
65
|
-
'llama-index-vector-stores-opensearch==0.
|
|
67
|
+
'llama-index-vector-stores-opensearch==0.6.0',
|
|
66
68
|
'haystack-ai==2.3.0',
|
|
67
|
-
'llama-index-llms-azure-openai==0.
|
|
69
|
+
'llama-index-llms-azure-openai==0.4.0',
|
|
68
70
|
'requests-aws4auth==1.2.3',
|
|
69
71
|
'opensearch-haystack==1.2.0',
|
|
70
72
|
'langchainhub==0.1.21',
|
|
71
|
-
'chromadb==1.0.
|
|
73
|
+
'chromadb==1.0.15',
|
|
72
74
|
'flask',
|
|
73
75
|
'opentelemetry-instrumentation-flask',
|
|
74
|
-
'langgraph==0.
|
|
76
|
+
'langgraph==0.5.4',
|
|
77
|
+
'langgraph-supervisor==0.0.28',
|
|
75
78
|
'opendal==0.45.14',
|
|
76
|
-
'anthropic==0.
|
|
79
|
+
'anthropic==0.57.1',
|
|
77
80
|
'anthropic-haystack',
|
|
78
81
|
'pytest-asyncio==0.26.0',
|
|
79
|
-
'llama-index-llms-anthropic==0.
|
|
80
|
-
'langchain-anthropic==0.3.13'
|
|
82
|
+
'llama-index-llms-anthropic==0.8.1',
|
|
83
|
+
'langchain-anthropic==0.3.13',
|
|
84
|
+
'langchain-mcp-adapters==0.1.8',
|
|
85
|
+
'mcp==1.12.1',
|
|
86
|
+
'a2a-sdk==0.2.8',
|
|
87
|
+
'httpx==0.28.1',
|
|
88
|
+
'fastapi>=0.115.0',
|
|
89
|
+
'pydantic==2.11.7',
|
|
90
|
+
'uvicorn==0.35.0',
|
|
91
|
+
'click==8.2.1',
|
|
92
|
+
'python-dotenv>=1.1.0',
|
|
93
|
+
'langchain-google-genai==2.1.8',
|
|
94
|
+
'google-adk==1.10.0',
|
|
95
|
+
'google-generativeai==0.8.5',
|
|
96
|
+
'openai-agents==0.2.6'
|
|
81
97
|
]
|
|
82
98
|
|
|
83
99
|
azure = [
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#pylint: disable=consider-using-with
|
|
2
|
+
|
|
3
|
+
from os import linesep, path
|
|
4
|
+
from io import TextIOWrapper
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
import os
|
|
7
|
+
from typing import Optional, Callable, Sequence, Dict, Tuple
|
|
8
|
+
from opentelemetry.sdk.trace import ReadableSpan
|
|
9
|
+
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
|
|
10
|
+
from opentelemetry.sdk.resources import SERVICE_NAME
|
|
11
|
+
from monocle_apptrace.exporters.base_exporter import SpanExporterBase
|
|
12
|
+
from monocle_apptrace.exporters.exporter_processor import ExportTaskProcessor
|
|
13
|
+
|
|
14
|
+
DEFAULT_FILE_PREFIX:str = "monocle_trace_"
|
|
15
|
+
DEFAULT_TIME_FORMAT:str = "%Y-%m-%d_%H.%M.%S"
|
|
16
|
+
HANDLE_TIMEOUT_SECONDS: int = 60 # 1 minute timeout
|
|
17
|
+
|
|
18
|
+
class FileSpanExporter(SpanExporterBase):
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
service_name: Optional[str] = None,
|
|
22
|
+
out_path:str = ".",
|
|
23
|
+
file_prefix = DEFAULT_FILE_PREFIX,
|
|
24
|
+
time_format = DEFAULT_TIME_FORMAT,
|
|
25
|
+
formatter: Callable[
|
|
26
|
+
[ReadableSpan], str
|
|
27
|
+
] = lambda span: span.to_json()
|
|
28
|
+
+ linesep,
|
|
29
|
+
task_processor: Optional[ExportTaskProcessor] = None
|
|
30
|
+
):
|
|
31
|
+
super().__init__()
|
|
32
|
+
# Dictionary to store file handles: {trace_id: (file_handle, file_path, creation_time, first_span)}
|
|
33
|
+
self.file_handles: Dict[int, Tuple[TextIOWrapper, str, datetime, bool]] = {}
|
|
34
|
+
self.formatter = formatter
|
|
35
|
+
self.service_name = service_name
|
|
36
|
+
self.output_path = os.getenv("MONOCLE_TRACE_OUTPUT_PATH", out_path)
|
|
37
|
+
self.file_prefix = file_prefix
|
|
38
|
+
self.time_format = time_format
|
|
39
|
+
self.task_processor = task_processor
|
|
40
|
+
self.is_first_span_in_file = True # Track if this is the first span in the current file
|
|
41
|
+
if self.task_processor is not None:
|
|
42
|
+
self.task_processor.start()
|
|
43
|
+
|
|
44
|
+
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
|
|
45
|
+
is_root_span = any(not span.parent for span in spans)
|
|
46
|
+
if self.task_processor is not None and callable(getattr(self.task_processor, 'queue_task', None)):
|
|
47
|
+
# Check if any span is a root span (no parent)
|
|
48
|
+
self.task_processor.queue_task(self._process_spans, spans, is_root_span)
|
|
49
|
+
return SpanExportResult.SUCCESS
|
|
50
|
+
else:
|
|
51
|
+
return self._process_spans(spans, is_root_span=is_root_span)
|
|
52
|
+
|
|
53
|
+
def _cleanup_expired_handles(self) -> None:
|
|
54
|
+
"""Close and remove file handles that have exceeded the timeout."""
|
|
55
|
+
current_time = datetime.now()
|
|
56
|
+
expired_trace_ids = []
|
|
57
|
+
|
|
58
|
+
for trace_id, (handle, file_path, creation_time, _) in self.file_handles.items():
|
|
59
|
+
if (current_time - creation_time).total_seconds() > HANDLE_TIMEOUT_SECONDS:
|
|
60
|
+
expired_trace_ids.append(trace_id)
|
|
61
|
+
|
|
62
|
+
for trace_id in expired_trace_ids:
|
|
63
|
+
self._close_trace_handle(trace_id)
|
|
64
|
+
|
|
65
|
+
def _get_or_create_handle(self, trace_id: int, service_name: str) -> Tuple[TextIOWrapper, str, bool]:
|
|
66
|
+
"""Get existing handle or create new one for the trace_id."""
|
|
67
|
+
self._cleanup_expired_handles()
|
|
68
|
+
|
|
69
|
+
if trace_id in self.file_handles:
|
|
70
|
+
handle, file_path, creation_time, first_span = self.file_handles[trace_id]
|
|
71
|
+
return handle, file_path, first_span
|
|
72
|
+
|
|
73
|
+
# Create new handle
|
|
74
|
+
file_path = path.join(self.output_path,
|
|
75
|
+
self.file_prefix + service_name + "_" + hex(trace_id) + "_"
|
|
76
|
+
+ datetime.now().strftime(self.time_format) + ".json")
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
handle = open(file_path, "w", encoding='UTF-8')
|
|
80
|
+
handle.write("[")
|
|
81
|
+
self.file_handles[trace_id] = (handle, file_path, datetime.now(), True)
|
|
82
|
+
return handle, file_path, True
|
|
83
|
+
except Exception as e:
|
|
84
|
+
print(f"Error creating file {file_path}: {e}")
|
|
85
|
+
return None, file_path, True
|
|
86
|
+
|
|
87
|
+
def _close_trace_handle(self, trace_id: int) -> None:
|
|
88
|
+
"""Close and remove a specific trace handle."""
|
|
89
|
+
if trace_id in self.file_handles:
|
|
90
|
+
handle, file_path, creation_time, _ = self.file_handles[trace_id]
|
|
91
|
+
try:
|
|
92
|
+
if handle is not None:
|
|
93
|
+
handle.write("]")
|
|
94
|
+
handle.close()
|
|
95
|
+
except Exception as e:
|
|
96
|
+
print(f"Error closing file {file_path}: {e}")
|
|
97
|
+
finally:
|
|
98
|
+
del self.file_handles[trace_id]
|
|
99
|
+
|
|
100
|
+
def _mark_span_written(self, trace_id: int) -> None:
|
|
101
|
+
"""Mark that a span has been written for this trace (no longer first span)."""
|
|
102
|
+
if trace_id in self.file_handles:
|
|
103
|
+
handle, file_path, creation_time, _ = self.file_handles[trace_id]
|
|
104
|
+
self.file_handles[trace_id] = (handle, file_path, creation_time, False)
|
|
105
|
+
|
|
106
|
+
def _process_spans(self, spans: Sequence[ReadableSpan], is_root_span: bool = False) -> SpanExportResult:
|
|
107
|
+
# Group spans by trace_id for efficient processing
|
|
108
|
+
spans_by_trace = {}
|
|
109
|
+
root_span_traces = set()
|
|
110
|
+
|
|
111
|
+
for span in spans:
|
|
112
|
+
if self.skip_export(span):
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
trace_id = span.context.trace_id
|
|
116
|
+
if trace_id not in spans_by_trace:
|
|
117
|
+
spans_by_trace[trace_id] = []
|
|
118
|
+
spans_by_trace[trace_id].append(span)
|
|
119
|
+
|
|
120
|
+
# Check if this span is a root span
|
|
121
|
+
if not span.parent:
|
|
122
|
+
root_span_traces.add(trace_id)
|
|
123
|
+
|
|
124
|
+
# Process spans for each trace
|
|
125
|
+
for trace_id, trace_spans in spans_by_trace.items():
|
|
126
|
+
service_name = trace_spans[0].resource.attributes.get(SERVICE_NAME, "unknown")
|
|
127
|
+
handle, file_path, is_first_span = self._get_or_create_handle(trace_id, service_name)
|
|
128
|
+
|
|
129
|
+
if handle is None:
|
|
130
|
+
continue
|
|
131
|
+
|
|
132
|
+
for span in trace_spans:
|
|
133
|
+
if not is_first_span:
|
|
134
|
+
try:
|
|
135
|
+
handle.write(",")
|
|
136
|
+
except Exception as e:
|
|
137
|
+
print(f"Error writing comma to file {file_path} for span {span.context.span_id}: {e}")
|
|
138
|
+
continue
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
handle.write(self.formatter(span))
|
|
142
|
+
if is_first_span:
|
|
143
|
+
self._mark_span_written(trace_id)
|
|
144
|
+
is_first_span = False
|
|
145
|
+
except Exception as e:
|
|
146
|
+
print(f"Error formatting span {span.context.span_id}: {e}")
|
|
147
|
+
continue
|
|
148
|
+
|
|
149
|
+
# Close handles for traces with root spans
|
|
150
|
+
for trace_id in root_span_traces:
|
|
151
|
+
self._close_trace_handle(trace_id)
|
|
152
|
+
|
|
153
|
+
# Flush remaining handles
|
|
154
|
+
for trace_id, (handle, file_path, _, _) in self.file_handles.items():
|
|
155
|
+
if trace_id not in root_span_traces:
|
|
156
|
+
try:
|
|
157
|
+
if handle is not None:
|
|
158
|
+
handle.flush()
|
|
159
|
+
except Exception as e:
|
|
160
|
+
print(f"Error flushing file {file_path}: {e}")
|
|
161
|
+
|
|
162
|
+
return SpanExportResult.SUCCESS
|
|
163
|
+
|
|
164
|
+
def force_flush(self, timeout_millis: int = 30000) -> bool:
|
|
165
|
+
"""Flush all open file handles."""
|
|
166
|
+
for trace_id, (handle, file_path, _, _) in self.file_handles.items():
|
|
167
|
+
try:
|
|
168
|
+
if handle is not None:
|
|
169
|
+
handle.flush()
|
|
170
|
+
except Exception as e:
|
|
171
|
+
print(f"Error flushing file {file_path}: {e}")
|
|
172
|
+
return True
|
|
173
|
+
|
|
174
|
+
def shutdown(self) -> None:
|
|
175
|
+
"""Close all file handles and stop task processor."""
|
|
176
|
+
if hasattr(self, 'task_processor') and self.task_processor is not None:
|
|
177
|
+
self.task_processor.stop()
|
|
178
|
+
|
|
179
|
+
# Close all remaining file handles
|
|
180
|
+
trace_ids_to_close = list(self.file_handles.keys())
|
|
181
|
+
for trace_id in trace_ids_to_close:
|
|
182
|
+
self._close_trace_handle(trace_id)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .instrumentor import (
|
|
2
|
+
setup_monocle_telemetry,
|
|
3
|
+
start_trace,
|
|
4
|
+
stop_trace,
|
|
5
|
+
start_scope,
|
|
6
|
+
stop_scope,
|
|
7
|
+
http_route_handler,
|
|
8
|
+
monocle_trace_scope,
|
|
9
|
+
amonocle_trace_scope,
|
|
10
|
+
monocle_trace_scope_method,
|
|
11
|
+
monocle_trace,
|
|
12
|
+
amonocle_trace,
|
|
13
|
+
monocle_trace_method,
|
|
14
|
+
monocle_trace_http_route,
|
|
15
|
+
is_valid_trace_id_uuid
|
|
16
|
+
)
|
|
17
|
+
from .utils import MonocleSpanException
|
|
@@ -57,6 +57,12 @@ llm_type_map = {
|
|
|
57
57
|
"chatcompletionsclient": "azure_ai_inference",
|
|
58
58
|
"embeddingsclient": "azure_ai_inference",
|
|
59
59
|
"imageembeddingsclient": "azure_ai_inference",
|
|
60
|
+
"chatbedrockconverse": "aws_bedrock",
|
|
61
|
+
"googleaigeminichatgenerator": "gemini",
|
|
62
|
+
"gemini": "gemini",
|
|
63
|
+
"chatgooglegenerativeai": "gemini",
|
|
64
|
+
"azurechatcompletion": "azure_openai",
|
|
65
|
+
"openaichatcompletion": "openai",
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
MONOCLE_INSTRUMENTOR = "monocle_apptrace"
|
|
@@ -81,4 +87,11 @@ WORKFLOW_TYPE_GENERIC = "workflow.generic"
|
|
|
81
87
|
MONOCLE_SDK_VERSION = "monocle_apptrace.version"
|
|
82
88
|
MONOCLE_SDK_LANGUAGE = "monocle_apptrace.language"
|
|
83
89
|
MONOCLE_DETECTED_SPAN_ERROR = "monocle_apptrace.detected_span_error"
|
|
84
|
-
HTTP_SUCCESS_CODES = ('200', '201', '202', '204', '205', '206')
|
|
90
|
+
HTTP_SUCCESS_CODES = ('200', '201', '202', '204', '205', '206')
|
|
91
|
+
CHILD_ERROR_CODE = "child.error.code"
|
|
92
|
+
|
|
93
|
+
AGENT_PREFIX_KEY = "monocle.agent.prefix"
|
|
94
|
+
|
|
95
|
+
INFERENCE_AGENT_DELEGATION = "delegation"
|
|
96
|
+
INFERENCE_TOOL_CALL = "tool_call"
|
|
97
|
+
INFERENCE_COMMUNICATION = "turn"
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import inspect
|
|
3
3
|
from typing import Collection, Dict, List, Union
|
|
4
|
-
import random
|
|
5
4
|
import uuid
|
|
6
5
|
import inspect
|
|
7
6
|
from opentelemetry import trace
|
|
8
|
-
from
|
|
9
|
-
from opentelemetry.context import attach, get_value, set_value, get_current, detach
|
|
7
|
+
from opentelemetry.context import attach, get_value, set_value
|
|
10
8
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
11
9
|
from opentelemetry.instrumentation.utils import unwrap
|
|
12
|
-
from opentelemetry.trace import
|
|
13
|
-
from opentelemetry.sdk.trace import TracerProvider, Span, id_generator
|
|
10
|
+
from opentelemetry.sdk.trace import TracerProvider, Span
|
|
14
11
|
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
|
|
15
12
|
from opentelemetry.sdk.trace import Span, TracerProvider
|
|
16
13
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanProcessor
|
|
17
14
|
from opentelemetry.sdk.trace.export import SpanExporter
|
|
18
15
|
from opentelemetry.trace import get_tracer
|
|
19
16
|
from wrapt import wrap_function_wrapper
|
|
20
|
-
from opentelemetry.trace.propagation import set_span_in_context, _SPAN_KEY
|
|
21
17
|
from monocle_apptrace.exporters.monocle_exporters import get_monocle_exporter
|
|
22
18
|
from monocle_apptrace.instrumentation.common.span_handler import SpanHandler, NonFrameworkSpanHandler
|
|
23
19
|
from monocle_apptrace.instrumentation.common.wrapper_method import (
|
|
@@ -27,10 +23,11 @@ from monocle_apptrace.instrumentation.common.wrapper_method import (
|
|
|
27
23
|
)
|
|
28
24
|
from monocle_apptrace.instrumentation.common.wrapper import scope_wrapper, ascope_wrapper, monocle_wrapper, amonocle_wrapper
|
|
29
25
|
from monocle_apptrace.instrumentation.common.utils import (
|
|
30
|
-
|
|
26
|
+
load_scopes
|
|
31
27
|
)
|
|
32
|
-
from monocle_apptrace.instrumentation.common.constants import MONOCLE_INSTRUMENTOR
|
|
28
|
+
from monocle_apptrace.instrumentation.common.constants import MONOCLE_INSTRUMENTOR
|
|
33
29
|
from functools import wraps
|
|
30
|
+
|
|
34
31
|
logger = logging.getLogger(__name__)
|
|
35
32
|
|
|
36
33
|
SESSION_PROPERTIES_KEY = "session"
|
|
@@ -229,49 +226,6 @@ def on_processor_start(span: Span, parent_context):
|
|
|
229
226
|
def set_context_properties(properties: dict) -> None:
|
|
230
227
|
attach(set_value(SESSION_PROPERTIES_KEY, properties))
|
|
231
228
|
|
|
232
|
-
def start_trace():
|
|
233
|
-
"""
|
|
234
|
-
Starts a new trace. All the spans created after this call will be part of the same trace.
|
|
235
|
-
Returns:
|
|
236
|
-
Token: A token representing the attached context for the workflow span.
|
|
237
|
-
This token is to be used later to stop the current trace.
|
|
238
|
-
Returns None if tracing fails.
|
|
239
|
-
|
|
240
|
-
Raises:
|
|
241
|
-
Exception: The function catches all exceptions internally and logs a warning.
|
|
242
|
-
"""
|
|
243
|
-
try:
|
|
244
|
-
tracer = get_tracer(instrumenting_module_name= MONOCLE_INSTRUMENTOR, tracer_provider= get_tracer_provider())
|
|
245
|
-
span = tracer.start_span(name = "workflow")
|
|
246
|
-
updated_span_context = set_span_in_context(span=span)
|
|
247
|
-
SpanHandler.set_default_monocle_attributes(span)
|
|
248
|
-
SpanHandler.set_workflow_properties(span)
|
|
249
|
-
token = attach(updated_span_context)
|
|
250
|
-
return token
|
|
251
|
-
except Exception as e:
|
|
252
|
-
logger.warning("Failed to start trace {e}")
|
|
253
|
-
return None
|
|
254
|
-
|
|
255
|
-
def stop_trace(token) -> None:
|
|
256
|
-
"""
|
|
257
|
-
Stop the active trace and detach workflow type if token is provided. All the spans created after this will not be part of the trace.
|
|
258
|
-
Args:
|
|
259
|
-
token: The token that was returned when the trace was started. Used to detach
|
|
260
|
-
workflow type. Can be None in which case only the span is ended.
|
|
261
|
-
Returns:
|
|
262
|
-
None
|
|
263
|
-
"""
|
|
264
|
-
try:
|
|
265
|
-
_parent_span_context = get_current()
|
|
266
|
-
if _parent_span_context is not None:
|
|
267
|
-
parent_span: Span = _parent_span_context.get(_SPAN_KEY, None)
|
|
268
|
-
if parent_span is not None:
|
|
269
|
-
parent_span.end()
|
|
270
|
-
if token is not None:
|
|
271
|
-
detach(token)
|
|
272
|
-
except:
|
|
273
|
-
logger.warning("Failed to stop trace")
|
|
274
|
-
|
|
275
229
|
def is_valid_trace_id_uuid(traceId: str) -> bool:
|
|
276
230
|
try:
|
|
277
231
|
uuid.UUID(traceId)
|
|
@@ -280,105 +234,18 @@ def is_valid_trace_id_uuid(traceId: str) -> bool:
|
|
|
280
234
|
pass
|
|
281
235
|
return False
|
|
282
236
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
Stop the active scope. All the spans created after this will not have the scope attached.
|
|
298
|
-
Args:
|
|
299
|
-
token: The token that was returned when the scope was started.
|
|
300
|
-
Returns:
|
|
301
|
-
None
|
|
302
|
-
"""
|
|
303
|
-
remove_scope(token)
|
|
304
|
-
return
|
|
305
|
-
|
|
306
|
-
@contextmanager
|
|
307
|
-
def monocle_trace():
|
|
308
|
-
"""
|
|
309
|
-
Context manager to start and stop a scope. All the spans, across traces created within the encapsulated code will have same trace ID
|
|
310
|
-
"""
|
|
311
|
-
token = start_trace()
|
|
312
|
-
try:
|
|
313
|
-
yield
|
|
314
|
-
finally:
|
|
315
|
-
stop_trace(token)
|
|
316
|
-
|
|
317
|
-
@contextmanager
|
|
318
|
-
def monocle_trace_scope(scope_name: str, scope_value:str = None):
|
|
319
|
-
"""
|
|
320
|
-
Context manager to start and stop a scope. All the spans, across traces created within the encapsulated code will have the scope attached.
|
|
321
|
-
Args:
|
|
322
|
-
scope_name: The name of the scope.
|
|
323
|
-
scope_value: Optional value of the scope. If None, a random UUID will be generated."""
|
|
324
|
-
token = start_scope(scope_name, scope_value)
|
|
325
|
-
try:
|
|
326
|
-
yield
|
|
327
|
-
finally:
|
|
328
|
-
stop_scope(token)
|
|
329
|
-
|
|
330
|
-
def monocle_trace_scope_method(scope_name: str, scope_value:str=None):
|
|
331
|
-
"""
|
|
332
|
-
Decorator to start and stop a scope for a method. All the spans, across traces created in the method will have the scope attached.
|
|
333
|
-
"""
|
|
334
|
-
def decorator(func):
|
|
335
|
-
if inspect.iscoroutinefunction(func):
|
|
336
|
-
@wraps(func)
|
|
337
|
-
async def wrapper(*args, **kwargs):
|
|
338
|
-
token = start_scope(scope_name, scope_value)
|
|
339
|
-
try:
|
|
340
|
-
result = await func(*args, **kwargs)
|
|
341
|
-
return result
|
|
342
|
-
finally:
|
|
343
|
-
stop_scope(token)
|
|
344
|
-
return wrapper
|
|
345
|
-
else:
|
|
346
|
-
@wraps(func)
|
|
347
|
-
def wrapper(*args, **kwargs):
|
|
348
|
-
token = start_scope(scope_name, scope_value)
|
|
349
|
-
try:
|
|
350
|
-
result = func(*args, **kwargs)
|
|
351
|
-
return result
|
|
352
|
-
finally:
|
|
353
|
-
stop_scope(token)
|
|
354
|
-
return wrapper
|
|
355
|
-
return decorator
|
|
356
|
-
|
|
357
|
-
def monocle_trace_http_route(func):
|
|
358
|
-
"""
|
|
359
|
-
Decorator to start and stop a continue traces and scope for a http route. It will also initiate new scopes from the http headers if configured in ``monocle_scopes.json``
|
|
360
|
-
All the spans, across traces created in the route will have the scope attached.
|
|
361
|
-
"""
|
|
362
|
-
if inspect.iscoroutinefunction(func):
|
|
363
|
-
@wraps(func)
|
|
364
|
-
async def wrapper(*args, **kwargs):
|
|
365
|
-
return await http_async_route_handler(func, *args, **kwargs)
|
|
366
|
-
return wrapper
|
|
367
|
-
else:
|
|
368
|
-
@wraps(func)
|
|
369
|
-
def wrapper(*args, **kwargs):
|
|
370
|
-
return http_route_handler(func, *args, **kwargs)
|
|
371
|
-
return wrapper
|
|
372
|
-
|
|
373
|
-
class FixedIdGenerator(id_generator.IdGenerator):
|
|
374
|
-
def __init__(
|
|
375
|
-
self,
|
|
376
|
-
trace_id: int) -> None:
|
|
377
|
-
self.trace_id = trace_id
|
|
378
|
-
|
|
379
|
-
def generate_span_id(self) -> int:
|
|
380
|
-
return random.getrandbits(64)
|
|
381
|
-
|
|
382
|
-
def generate_trace_id(self) -> int:
|
|
383
|
-
return self.trace_id
|
|
237
|
+
from monocle_apptrace.instrumentation.common.method_wrappers import (
|
|
238
|
+
monocle_trace_scope_method,
|
|
239
|
+
amonocle_trace_scope,
|
|
240
|
+
monocle_trace,
|
|
241
|
+
amonocle_trace,
|
|
242
|
+
monocle_trace_method,
|
|
243
|
+
monocle_trace_http_route,
|
|
244
|
+
start_scope,
|
|
245
|
+
stop_scope,
|
|
246
|
+
start_trace,
|
|
247
|
+
stop_trace,
|
|
248
|
+
http_route_handler,
|
|
249
|
+
monocle_trace_scope,
|
|
250
|
+
)
|
|
384
251
|
|