openlit 1.32.0__tar.gz → 1.32.2__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.
Files changed (102) hide show
  1. {openlit-1.32.0 → openlit-1.32.2}/PKG-INFO +4 -3
  2. {openlit-1.32.0 → openlit-1.32.2}/README.md +3 -2
  3. {openlit-1.32.0 → openlit-1.32.2}/pyproject.toml +1 -1
  4. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/__init__.py +3 -0
  5. openlit-1.32.2/src/openlit/instrumentation/julep/__init__.py +80 -0
  6. openlit-1.32.2/src/openlit/instrumentation/julep/async_julep.py +111 -0
  7. openlit-1.32.2/src/openlit/instrumentation/julep/julep.py +112 -0
  8. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/semcov/__init__.py +1 -0
  9. {openlit-1.32.0 → openlit-1.32.2}/LICENSE +0 -0
  10. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/__helpers.py +0 -0
  11. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/evals/__init__.py +0 -0
  12. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/evals/all.py +0 -0
  13. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/evals/bias_detection.py +0 -0
  14. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/evals/hallucination.py +0 -0
  15. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/evals/toxicity.py +0 -0
  16. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/evals/utils.py +0 -0
  17. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/guard/__init__.py +0 -0
  18. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/guard/all.py +0 -0
  19. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/guard/prompt_injection.py +0 -0
  20. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/guard/restrict_topic.py +0 -0
  21. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/guard/sensitive_topic.py +0 -0
  22. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/guard/utils.py +0 -0
  23. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/ag2/__init__.py +0 -0
  24. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/ag2/ag2.py +0 -0
  25. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
  26. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
  27. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
  28. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
  29. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
  30. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
  31. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
  32. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
  33. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/chroma/__init__.py +0 -0
  34. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/chroma/chroma.py +0 -0
  35. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/cohere/__init__.py +0 -0
  36. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/cohere/cohere.py +0 -0
  37. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/crewai/__init__.py +0 -0
  38. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/crewai/crewai.py +0 -0
  39. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
  40. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
  41. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
  42. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
  43. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
  44. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
  45. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
  46. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
  47. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
  48. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
  49. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
  50. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
  51. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/gpu/__init__.py +0 -0
  52. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/groq/__init__.py +0 -0
  53. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/groq/async_groq.py +0 -0
  54. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/groq/groq.py +0 -0
  55. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/haystack/__init__.py +0 -0
  56. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/haystack/haystack.py +0 -0
  57. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/langchain/__init__.py +0 -0
  58. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/langchain/langchain.py +0 -0
  59. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/litellm/__init__.py +0 -0
  60. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
  61. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/litellm/litellm.py +0 -0
  62. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
  63. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
  64. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/mem0/__init__.py +0 -0
  65. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/mem0/mem0.py +0 -0
  66. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/milvus/__init__.py +0 -0
  67. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/milvus/milvus.py +0 -0
  68. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/mistral/__init__.py +0 -0
  69. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
  70. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/mistral/mistral.py +0 -0
  71. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/multion/__init__.py +0 -0
  72. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/multion/async_multion.py +0 -0
  73. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/multion/multion.py +0 -0
  74. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/ollama/__init__.py +0 -0
  75. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
  76. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/ollama/ollama.py +0 -0
  77. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/openai/__init__.py +0 -0
  78. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/openai/async_azure_openai.py +0 -0
  79. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/openai/async_openai.py +0 -0
  80. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/openai/azure_openai.py +0 -0
  81. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/openai/openai.py +0 -0
  82. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/phidata/__init__.py +0 -0
  83. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/phidata/phidata.py +0 -0
  84. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
  85. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
  86. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/premai/__init__.py +0 -0
  87. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/premai/premai.py +0 -0
  88. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
  89. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
  90. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
  91. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/reka/__init__.py +0 -0
  92. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/reka/async_reka.py +0 -0
  93. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/reka/reka.py +0 -0
  94. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/transformers/__init__.py +0 -0
  95. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/transformers/transformers.py +0 -0
  96. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
  97. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
  98. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
  99. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/vllm/__init__.py +0 -0
  100. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/instrumentation/vllm/vllm.py +0 -0
  101. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/otel/metrics.py +0 -0
  102. {openlit-1.32.0 → openlit-1.32.2}/src/openlit/otel/tracing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openlit
3
- Version: 1.32.0
3
+ Version: 1.32.2
4
4
  Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
5
5
  Home-page: https://github.com/openlit/openlit/tree/main/openlit/python
6
6
  Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
@@ -45,7 +45,7 @@ Description-Content-Type: text/markdown
45
45
  [![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack&logoColor=white)](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
46
46
  [![X](https://img.shields.io/badge/follow-%40openlit__io-1DA1F2?logo=x&style=social)](https://twitter.com/openlit_io)
47
47
 
48
- ![OpenLIT Connections Banner](https://github.com/openlit/.github/blob/main/profile/assets/github-readme-connections-banner.png?raw=true)
48
+ ![OpenLIT Connections Banner](https://github.com/openlit/.github/blob/main/profile/assets/openlit-integrations-banner.png?raw=true)
49
49
 
50
50
 
51
51
  </div>
@@ -78,7 +78,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
78
78
  | [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | | [✅ Phidata](https://docs.openlit.io/latest/integrations/phidata) | |
79
79
  | | | [✅ mem0](https://docs.openlit.io/latest/integrations/mem0) | |
80
80
  | [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | | [✅ MultiOn](https://docs.openlit.io/latest/integrations/multion) | |
81
- | [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | | | |
81
+ | [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | | [✅ Julep AI](https://docs.openlit.io/latest/integrations/julep-ai) | |
82
82
  | [✅ ElevenLabs](https://docs.openlit.io/latest/integrations/elevenlabs) | | | |
83
83
  | [✅ vLLM](https://docs.openlit.io/latest/integrations/vllm) | | | |
84
84
  | [✅ OLA Krutrim](https://docs.openlit.io/latest/integrations/krutrim) | | | |
@@ -89,6 +89,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
89
89
  | [✅ xAI](https://docs.openlit.io/latest/integrations/xai) | | | |
90
90
  | [✅ Prem AI](https://docs.openlit.io/latest/integrations/premai) | | | |
91
91
 
92
+
92
93
  ## Supported Destinations
93
94
  - [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
94
95
  - [✅ Prometheus + Tempo](https://docs.openlit.io/latest/connections/prometheus-tempo)
@@ -14,7 +14,7 @@
14
14
  [![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack&logoColor=white)](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
15
15
  [![X](https://img.shields.io/badge/follow-%40openlit__io-1DA1F2?logo=x&style=social)](https://twitter.com/openlit_io)
16
16
 
17
- ![OpenLIT Connections Banner](https://github.com/openlit/.github/blob/main/profile/assets/github-readme-connections-banner.png?raw=true)
17
+ ![OpenLIT Connections Banner](https://github.com/openlit/.github/blob/main/profile/assets/openlit-integrations-banner.png?raw=true)
18
18
 
19
19
 
20
20
  </div>
@@ -47,7 +47,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
47
47
  | [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | | [✅ Phidata](https://docs.openlit.io/latest/integrations/phidata) | |
48
48
  | | | [✅ mem0](https://docs.openlit.io/latest/integrations/mem0) | |
49
49
  | [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | | [✅ MultiOn](https://docs.openlit.io/latest/integrations/multion) | |
50
- | [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | | | |
50
+ | [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | | [✅ Julep AI](https://docs.openlit.io/latest/integrations/julep-ai) | |
51
51
  | [✅ ElevenLabs](https://docs.openlit.io/latest/integrations/elevenlabs) | | | |
52
52
  | [✅ vLLM](https://docs.openlit.io/latest/integrations/vllm) | | | |
53
53
  | [✅ OLA Krutrim](https://docs.openlit.io/latest/integrations/krutrim) | | | |
@@ -58,6 +58,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
58
58
  | [✅ xAI](https://docs.openlit.io/latest/integrations/xai) | | | |
59
59
  | [✅ Prem AI](https://docs.openlit.io/latest/integrations/premai) | | | |
60
60
 
61
+
61
62
  ## Supported Destinations
62
63
  - [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
63
64
  - [✅ Prometheus + Tempo](https://docs.openlit.io/latest/connections/prometheus-tempo)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "openlit"
3
- version = "1.32.0"
3
+ version = "1.32.2"
4
4
  description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
5
5
  authors = ["OpenLIT"]
6
6
  repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
@@ -55,6 +55,7 @@ from openlit.instrumentation.ag2 import AG2Instrumentor
55
55
  from openlit.instrumentation.multion import MultiOnInstrumentor
56
56
  from openlit.instrumentation.dynamiq import DynamiqInstrumentor
57
57
  from openlit.instrumentation.phidata import PhidataInstrumentor
58
+ from openlit.instrumentation.julep import JulepInstrumentor
58
59
  from openlit.instrumentation.gpu import GPUInstrumentor
59
60
  import openlit.guard
60
61
  import openlit.evals
@@ -248,6 +249,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
248
249
  "phidata": "phi",
249
250
  "reka-api": "reka",
250
251
  "premai": "premai",
252
+ "julep": "julep",
251
253
  }
252
254
 
253
255
  invalid_instrumentors = [
@@ -336,6 +338,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
336
338
  "phidata": PhidataInstrumentor(),
337
339
  "reka-api": RekaInstrumentor(),
338
340
  "premai": PremAIInstrumentor(),
341
+ "julep": JulepInstrumentor(),
339
342
  }
340
343
 
341
344
  # Initialize and instrument only the enabled instrumentors
@@ -0,0 +1,80 @@
1
+ # pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
2
+ """Initializer of Auto Instrumentation of Juelp Functions"""
3
+
4
+ from typing import Collection
5
+ import importlib.metadata
6
+ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
7
+ from wrapt import wrap_function_wrapper
8
+
9
+ from openlit.instrumentation.julep.julep import (
10
+ wrap_julep
11
+ )
12
+
13
+ from openlit.instrumentation.julep.async_julep import (
14
+ async_wrap_julep
15
+ )
16
+
17
+ _instruments = ("julep >= 1.42.0",)
18
+
19
+ class JulepInstrumentor(BaseInstrumentor):
20
+ """
21
+ An instrumentor for Julep's client library.
22
+ """
23
+
24
+ def instrumentation_dependencies(self) -> Collection[str]:
25
+ return _instruments
26
+
27
+ def _instrument(self, **kwargs):
28
+ application_name = kwargs.get("application_name", "default_application")
29
+ environment = kwargs.get("environment", "default_environment")
30
+ tracer = kwargs.get("tracer")
31
+ metrics = kwargs.get("metrics_dict")
32
+ pricing_info = kwargs.get("pricing_info", {})
33
+ trace_content = kwargs.get("trace_content", False)
34
+ disable_metrics = kwargs.get("disable_metrics")
35
+ version = importlib.metadata.version("julep")
36
+
37
+ # sync
38
+ wrap_function_wrapper(
39
+ "julep.resources.agents.agents",
40
+ "AgentsResource.create",
41
+ wrap_julep("julep.agents_create", version, environment, application_name,
42
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
43
+ )
44
+ wrap_function_wrapper(
45
+ "julep.resources.tasks",
46
+ "TasksResource.create",
47
+ wrap_julep("julep.task_create", version, environment, application_name,
48
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
49
+ )
50
+ wrap_function_wrapper(
51
+ "julep.resources.executions.executions",
52
+ "ExecutionsResource.create",
53
+ wrap_julep("julep.execution_create", version, environment, application_name,
54
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
55
+ )
56
+
57
+ # async
58
+ wrap_function_wrapper(
59
+ "julep.resources.agents.agents",
60
+ "AsyncAgentsResource.create",
61
+ async_wrap_julep("julep.agents_create", version, environment, application_name,
62
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
63
+ )
64
+ wrap_function_wrapper(
65
+ "julep.resources.tasks",
66
+ "AsyncTasksResource.create",
67
+ async_wrap_julep("julep.task_create", version, environment, application_name,
68
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
69
+ )
70
+ wrap_function_wrapper(
71
+ "julep.resources.executions.executions",
72
+ "AsyncExecutionsResource.create",
73
+ async_wrap_julep("julep.execution_create", version, environment, application_name,
74
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
75
+ )
76
+
77
+
78
+ def _uninstrument(self, **kwargs):
79
+ # Proper uninstrumentation logic to revert patched methods
80
+ pass
@@ -0,0 +1,111 @@
1
+ # pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument
2
+ """
3
+ Module for monitoring Julep.
4
+ """
5
+
6
+ import logging
7
+ from opentelemetry.trace import SpanKind, Status, StatusCode
8
+ from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
9
+ from openlit.__helpers import handle_exception
10
+ from openlit.semcov import SemanticConvetion
11
+
12
+ # Initialize logger for logging potential issues and operations
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def async_wrap_julep(gen_ai_endpoint, version, environment, application_name,
16
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
17
+ """
18
+ Creates a wrapper around a function call to trace and log its execution metrics.
19
+
20
+ This function wraps any given function to measure its execution time,
21
+ log its operation, and trace its execution using OpenTelemetry.
22
+
23
+ Parameters:
24
+ - gen_ai_endpoint (str): A descriptor or name for the endpoint being traced.
25
+ - version (str): The version of the application.
26
+ - environment (str): The deployment environment (e.g., 'production', 'development').
27
+ - application_name (str): Name of the application.
28
+ - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
29
+ - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
30
+ - trace_content (bool): Flag indicating whether to trace the content of the response.
31
+
32
+ Returns:
33
+ - function: A higher-order function that takes a function 'wrapped' and returns
34
+ a new function that wraps 'wrapped' with additional tracing and logging.
35
+ """
36
+
37
+ async def wrapper(wrapped, instance, args, kwargs):
38
+ """
39
+ An inner wrapper function that executes the wrapped function, measures execution
40
+ time, and records trace data using OpenTelemetry.
41
+
42
+ Parameters:
43
+ - wrapped (Callable): The original function that this wrapper will execute.
44
+ - instance (object): The instance to which the wrapped function belongs. This
45
+ is used for instance methods. For static and classmethods,
46
+ this may be None.
47
+ - args (tuple): Positional arguments passed to the wrapped function.
48
+ - kwargs (dict): Keyword arguments passed to the wrapped function.
49
+
50
+ Returns:
51
+ - The result of the wrapped function call.
52
+
53
+ The wrapper initiates a span with the provided tracer, sets various attributes
54
+ on the span based on the function's execution and response, and ensures
55
+ errors are handled and logged appropriately.
56
+ """
57
+
58
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
59
+ response = await wrapped(*args, **kwargs)
60
+
61
+ try:
62
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
63
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
64
+ gen_ai_endpoint)
65
+ span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
66
+ SemanticConvetion.GEN_AI_SYSTEM_JULEP)
67
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
68
+ environment)
69
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
70
+ application_name)
71
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
72
+ SemanticConvetion.GEN_AI_TYPE_AGENT)
73
+
74
+ if gen_ai_endpoint == "julep.agents_create":
75
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
76
+ response.id)
77
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
78
+ kwargs.get("name", ""))
79
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
80
+ kwargs.get("model", "gpt-4-turbo"))
81
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
82
+ kwargs.get("about", ""))
83
+
84
+ elif gen_ai_endpoint == "julep.task_create":
85
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
86
+ str(kwargs.get("tools", "")))
87
+
88
+ elif gen_ai_endpoint == "julep.execution_create":
89
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
90
+ kwargs.get("task_id", ""))
91
+ if trace_content:
92
+ span.add_event(
93
+ name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
94
+ attributes={
95
+ SemanticConvetion.GEN_AI_CONTENT_PROMPT:str(kwargs.get("input", "")),
96
+ },
97
+ )
98
+
99
+ span.set_status(Status(StatusCode.OK))
100
+
101
+ # Return original response
102
+ return response
103
+
104
+ except Exception as e:
105
+ handle_exception(span, e)
106
+ logger.error("Error in trace creation: %s", e)
107
+
108
+ # Return original response
109
+ return response
110
+
111
+ return wrapper
@@ -0,0 +1,112 @@
1
+ # pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument
2
+ """
3
+ Module for monitoring Julep.
4
+ """
5
+
6
+ import logging
7
+ from opentelemetry.trace import SpanKind, Status, StatusCode
8
+ from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
9
+ from openlit.__helpers import handle_exception
10
+ from openlit.semcov import SemanticConvetion
11
+
12
+ # Initialize logger for logging potential issues and operations
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def wrap_julep(gen_ai_endpoint, version, environment, application_name,
16
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
17
+ """
18
+ Creates a wrapper around a function call to trace and log its execution metrics.
19
+
20
+ This function wraps any given function to measure its execution time,
21
+ log its operation, and trace its execution using OpenTelemetry.
22
+
23
+ Parameters:
24
+ - gen_ai_endpoint (str): A descriptor or name for the endpoint being traced.
25
+ - version (str): The version of the Langchain application.
26
+ - environment (str): The deployment environment (e.g., 'production', 'development').
27
+ - application_name (str): Name of the Langchain application.
28
+ - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
29
+ - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
30
+ - trace_content (bool): Flag indicating whether to trace the content of the response.
31
+
32
+ Returns:
33
+ - function: A higher-order function that takes a function 'wrapped' and returns
34
+ a new function that wraps 'wrapped' with additional tracing and logging.
35
+ """
36
+
37
+ def wrapper(wrapped, instance, args, kwargs):
38
+ """
39
+ An inner wrapper function that executes the wrapped function, measures execution
40
+ time, and records trace data using OpenTelemetry.
41
+
42
+ Parameters:
43
+ - wrapped (Callable): The original function that this wrapper will execute.
44
+ - instance (object): The instance to which the wrapped function belongs. This
45
+ is used for instance methods. For static and classmethods,
46
+ this may be None.
47
+ - args (tuple): Positional arguments passed to the wrapped function.
48
+ - kwargs (dict): Keyword arguments passed to the wrapped function.
49
+
50
+ Returns:
51
+ - The result of the wrapped function call.
52
+
53
+ The wrapper initiates a span with the provided tracer, sets various attributes
54
+ on the span based on the function's execution and response, and ensures
55
+ errors are handled and logged appropriately.
56
+ """
57
+
58
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
59
+ response = wrapped(*args, **kwargs)
60
+
61
+ try:
62
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
63
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
64
+ gen_ai_endpoint)
65
+ span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
66
+ SemanticConvetion.GEN_AI_SYSTEM_JULEP)
67
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
68
+ environment)
69
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
70
+ application_name)
71
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
72
+ SemanticConvetion.GEN_AI_TYPE_AGENT)
73
+
74
+ if gen_ai_endpoint == "julep.agents_create":
75
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
76
+ response.id)
77
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
78
+ kwargs.get("name", ""))
79
+ span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
80
+ kwargs.get("model", "gpt-4-turbo"))
81
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
82
+ kwargs.get("about", ""))
83
+
84
+ elif gen_ai_endpoint == "julep.task_create":
85
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
86
+ str(kwargs.get("tools", "")))
87
+
88
+ elif gen_ai_endpoint == "julep.execution_create":
89
+ span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
90
+ kwargs.get("task_id", ""))
91
+ if trace_content:
92
+ span.add_event(
93
+ name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
94
+ attributes={
95
+ SemanticConvetion.GEN_AI_CONTENT_PROMPT:str(kwargs.get("input", "")),
96
+ },
97
+ )
98
+
99
+
100
+ span.set_status(Status(StatusCode.OK))
101
+
102
+ # Return original response
103
+ return response
104
+
105
+ except Exception as e:
106
+ handle_exception(span, e)
107
+ logger.error("Error in trace creation: %s", e)
108
+
109
+ # Return original response
110
+ return response
111
+
112
+ return wrapper
@@ -118,6 +118,7 @@ class SemanticConvetion:
118
118
  GEN_AI_SYSTEM_MULTION = "multion"
119
119
  GEN_AI_SYSTEM_DYNAMIQ = "dynamiq"
120
120
  GEN_AI_SYSTEM_PHIDATA = "phidata"
121
+ GEN_AI_SYSTEM_JULEP = "julep"
121
122
 
122
123
  # Vector DB
123
124
  DB_REQUESTS = "db.total.requests"
File without changes