openlit 1.33.10__py3-none-any.whl → 1.33.11__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.
Files changed (112) hide show
  1. openlit/__helpers.py +73 -0
  2. openlit/__init__.py +38 -11
  3. openlit/instrumentation/ag2/__init__.py +9 -10
  4. openlit/instrumentation/ag2/ag2.py +133 -68
  5. openlit/instrumentation/ai21/__init__.py +6 -5
  6. openlit/instrumentation/ai21/ai21.py +71 -534
  7. openlit/instrumentation/ai21/async_ai21.py +71 -534
  8. openlit/instrumentation/ai21/utils.py +407 -0
  9. openlit/instrumentation/anthropic/__init__.py +3 -3
  10. openlit/instrumentation/anthropic/anthropic.py +4 -4
  11. openlit/instrumentation/anthropic/async_anthropic.py +4 -4
  12. openlit/instrumentation/assemblyai/__init__.py +2 -2
  13. openlit/instrumentation/assemblyai/assemblyai.py +3 -3
  14. openlit/instrumentation/astra/__init__.py +25 -25
  15. openlit/instrumentation/astra/astra.py +2 -2
  16. openlit/instrumentation/astra/async_astra.py +2 -2
  17. openlit/instrumentation/azure_ai_inference/__init__.py +5 -5
  18. openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +8 -8
  19. openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +8 -8
  20. openlit/instrumentation/bedrock/__init__.py +2 -2
  21. openlit/instrumentation/bedrock/bedrock.py +3 -3
  22. openlit/instrumentation/chroma/__init__.py +9 -9
  23. openlit/instrumentation/chroma/chroma.py +2 -2
  24. openlit/instrumentation/cohere/__init__.py +7 -7
  25. openlit/instrumentation/cohere/async_cohere.py +9 -9
  26. openlit/instrumentation/cohere/cohere.py +9 -9
  27. openlit/instrumentation/controlflow/__init__.py +4 -4
  28. openlit/instrumentation/controlflow/controlflow.py +2 -2
  29. openlit/instrumentation/crawl4ai/__init__.py +3 -3
  30. openlit/instrumentation/crawl4ai/async_crawl4ai.py +2 -2
  31. openlit/instrumentation/crawl4ai/crawl4ai.py +2 -2
  32. openlit/instrumentation/crewai/__init__.py +3 -3
  33. openlit/instrumentation/crewai/crewai.py +2 -2
  34. openlit/instrumentation/dynamiq/__init__.py +5 -5
  35. openlit/instrumentation/dynamiq/dynamiq.py +2 -2
  36. openlit/instrumentation/elevenlabs/__init__.py +5 -5
  37. openlit/instrumentation/elevenlabs/async_elevenlabs.py +3 -3
  38. openlit/instrumentation/elevenlabs/elevenlabs.py +3 -3
  39. openlit/instrumentation/embedchain/__init__.py +2 -2
  40. openlit/instrumentation/embedchain/embedchain.py +4 -4
  41. openlit/instrumentation/firecrawl/__init__.py +3 -3
  42. openlit/instrumentation/firecrawl/firecrawl.py +2 -2
  43. openlit/instrumentation/google_ai_studio/__init__.py +3 -3
  44. openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +3 -3
  45. openlit/instrumentation/google_ai_studio/google_ai_studio.py +3 -3
  46. openlit/instrumentation/gpt4all/__init__.py +3 -3
  47. openlit/instrumentation/gpt4all/gpt4all.py +7 -7
  48. openlit/instrumentation/groq/__init__.py +3 -3
  49. openlit/instrumentation/groq/async_groq.py +5 -5
  50. openlit/instrumentation/groq/groq.py +5 -5
  51. openlit/instrumentation/haystack/__init__.py +2 -2
  52. openlit/instrumentation/haystack/haystack.py +2 -2
  53. openlit/instrumentation/julep/__init__.py +7 -7
  54. openlit/instrumentation/julep/async_julep.py +3 -3
  55. openlit/instrumentation/julep/julep.py +3 -3
  56. openlit/instrumentation/langchain/__init__.py +2 -2
  57. openlit/instrumentation/langchain/async_langchain.py +13 -9
  58. openlit/instrumentation/langchain/langchain.py +13 -8
  59. openlit/instrumentation/letta/__init__.py +7 -7
  60. openlit/instrumentation/letta/letta.py +5 -5
  61. openlit/instrumentation/litellm/__init__.py +5 -5
  62. openlit/instrumentation/litellm/async_litellm.py +8 -8
  63. openlit/instrumentation/litellm/litellm.py +8 -8
  64. openlit/instrumentation/llamaindex/__init__.py +2 -2
  65. openlit/instrumentation/llamaindex/llamaindex.py +2 -2
  66. openlit/instrumentation/mem0/__init__.py +2 -2
  67. openlit/instrumentation/mem0/mem0.py +2 -2
  68. openlit/instrumentation/milvus/__init__.py +2 -2
  69. openlit/instrumentation/milvus/milvus.py +2 -2
  70. openlit/instrumentation/mistral/__init__.py +7 -7
  71. openlit/instrumentation/mistral/async_mistral.py +10 -10
  72. openlit/instrumentation/mistral/mistral.py +10 -10
  73. openlit/instrumentation/multion/__init__.py +7 -7
  74. openlit/instrumentation/multion/async_multion.py +5 -5
  75. openlit/instrumentation/multion/multion.py +5 -5
  76. openlit/instrumentation/ollama/__init__.py +11 -9
  77. openlit/instrumentation/ollama/async_ollama.py +71 -465
  78. openlit/instrumentation/ollama/ollama.py +71 -465
  79. openlit/instrumentation/ollama/utils.py +333 -0
  80. openlit/instrumentation/openai/__init__.py +11 -11
  81. openlit/instrumentation/openai/async_openai.py +18 -18
  82. openlit/instrumentation/openai/openai.py +18 -18
  83. openlit/instrumentation/phidata/__init__.py +2 -2
  84. openlit/instrumentation/phidata/phidata.py +2 -2
  85. openlit/instrumentation/pinecone/__init__.py +6 -6
  86. openlit/instrumentation/pinecone/pinecone.py +2 -2
  87. openlit/instrumentation/premai/__init__.py +3 -3
  88. openlit/instrumentation/premai/premai.py +7 -7
  89. openlit/instrumentation/qdrant/__init__.py +2 -2
  90. openlit/instrumentation/qdrant/async_qdrant.py +2 -2
  91. openlit/instrumentation/qdrant/qdrant.py +2 -2
  92. openlit/instrumentation/reka/__init__.py +3 -3
  93. openlit/instrumentation/reka/async_reka.py +3 -3
  94. openlit/instrumentation/reka/reka.py +3 -3
  95. openlit/instrumentation/together/__init__.py +5 -5
  96. openlit/instrumentation/together/async_together.py +8 -8
  97. openlit/instrumentation/together/together.py +8 -8
  98. openlit/instrumentation/transformers/__init__.py +2 -2
  99. openlit/instrumentation/transformers/transformers.py +4 -4
  100. openlit/instrumentation/vertexai/__init__.py +9 -9
  101. openlit/instrumentation/vertexai/async_vertexai.py +4 -4
  102. openlit/instrumentation/vertexai/vertexai.py +4 -4
  103. openlit/instrumentation/vllm/__init__.py +2 -2
  104. openlit/instrumentation/vllm/vllm.py +3 -3
  105. openlit/otel/events.py +85 -0
  106. openlit/otel/tracing.py +3 -13
  107. openlit/semcov/__init__.py +13 -1
  108. {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/METADATA +2 -2
  109. openlit-1.33.11.dist-info/RECORD +125 -0
  110. openlit-1.33.10.dist-info/RECORD +0 -122
  111. {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/LICENSE +0 -0
  112. {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/WHEEL +0 -0
@@ -19,7 +19,7 @@ from openlit.semcov import SemanticConvetion
19
19
  logger = logging.getLogger(__name__)
20
20
 
21
21
  def generate(version, environment, application_name,
22
- tracer, pricing_info, trace_content, metrics, disable_metrics):
22
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
23
23
  """
24
24
  Generates a telemetry wrapper for chat to collect metrics.
25
25
 
@@ -30,7 +30,7 @@ def generate(version, environment, application_name,
30
30
  application_name: Name of the application using the Google AI Studio API.
31
31
  tracer: OpenTelemetry tracer for creating spans.
32
32
  pricing_info: Information used for calculating the cost of Google AI Studio usage.
33
- trace_content: Flag indicating whether to trace the actual content.
33
+ capture_message_content: Flag indicating whether to trace the actual content.
34
34
 
35
35
  Returns:
36
36
  A function that wraps the chat method to add telemetry.
@@ -165,7 +165,7 @@ def generate(version, environment, application_name,
165
165
  end_time - start_time)
166
166
  span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
167
167
  version)
168
- if trace_content:
168
+ if capture_message_content:
169
169
  span.add_event(
170
170
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
171
171
  attributes={
@@ -26,7 +26,7 @@ class GPT4AllInstrumentor(BaseInstrumentor):
26
26
  tracer = kwargs.get("tracer")
27
27
  metrics = kwargs.get("metrics_dict")
28
28
  pricing_info = kwargs.get("pricing_info", {})
29
- trace_content = kwargs.get("trace_content", False)
29
+ capture_message_content = kwargs.get("capture_message_content", False)
30
30
  disable_metrics = kwargs.get("disable_metrics")
31
31
  version = importlib.metadata.version("gpt4all")
32
32
 
@@ -35,7 +35,7 @@ class GPT4AllInstrumentor(BaseInstrumentor):
35
35
  "gpt4all",
36
36
  "GPT4All.generate",
37
37
  generate(version, environment, application_name,
38
- tracer, pricing_info, trace_content, metrics, disable_metrics),
38
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
39
39
  )
40
40
 
41
41
  # embed
@@ -43,7 +43,7 @@ class GPT4AllInstrumentor(BaseInstrumentor):
43
43
  "gpt4all",
44
44
  "Embed4All.embed",
45
45
  embed(version, environment, application_name,
46
- tracer, pricing_info, trace_content, metrics, disable_metrics),
46
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
47
47
  )
48
48
 
49
49
 
@@ -20,7 +20,7 @@ from openlit.semcov import SemanticConvetion
20
20
  logger = logging.getLogger(__name__)
21
21
 
22
22
  def generate(version, environment, application_name,
23
- tracer, pricing_info, trace_content, metrics, disable_metrics):
23
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
24
24
  """
25
25
  Generates a telemetry wrapper for chat completions to collect metrics.
26
26
 
@@ -30,7 +30,7 @@ def generate(version, environment, application_name,
30
30
  application_name: Name of the application using the GPT4All API.
31
31
  tracer: OpenTelemetry tracer for creating spans.
32
32
  pricing_info: Information used for calculating GPT4All usage.
33
- trace_content: Flag indicating whether to trace the actual content.
33
+ capture_message_content: Flag indicating whether to trace the actual content.
34
34
 
35
35
  Returns:
36
36
  A function that wraps the chat completions method to add telemetry.
@@ -168,7 +168,7 @@ def generate(version, environment, application_name,
168
168
  version)
169
169
  self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
170
170
  0)
171
- if trace_content:
171
+ if capture_message_content:
172
172
  self._span.add_event(
173
173
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
174
174
  attributes={
@@ -319,7 +319,7 @@ def generate(version, environment, application_name,
319
319
  version)
320
320
  span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
321
321
  0)
322
- if trace_content:
322
+ if capture_message_content:
323
323
  span.add_event(
324
324
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
325
325
  attributes={
@@ -374,7 +374,7 @@ def generate(version, environment, application_name,
374
374
  return wrapper
375
375
 
376
376
  def embed(version, environment, application_name,
377
- tracer, pricing_info, trace_content, metrics, disable_metrics):
377
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
378
378
  """
379
379
  Generates a telemetry wrapper for embeddings to collect metrics.
380
380
 
@@ -384,7 +384,7 @@ def embed(version, environment, application_name,
384
384
  application_name: Name of the application using the GPT4All API.
385
385
  tracer: OpenTelemetry tracer for creating spans.
386
386
  pricing_info: Information used for calculating GPT4All usage.
387
- trace_content: Flag indicating whether to trace the actual content.
387
+ capture_message_content: Flag indicating whether to trace the actual content.
388
388
 
389
389
  Returns:
390
390
  A function that wraps the embeddings method to add telemetry.
@@ -452,7 +452,7 @@ def embed(version, environment, application_name,
452
452
  span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
453
453
  0)
454
454
 
455
- if trace_content:
455
+ if capture_message_content:
456
456
  span.add_event(
457
457
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
458
458
  attributes={
@@ -25,7 +25,7 @@ class GroqInstrumentor(BaseInstrumentor):
25
25
  tracer = kwargs.get("tracer")
26
26
  metrics = kwargs.get("metrics_dict")
27
27
  pricing_info = kwargs.get("pricing_info", {})
28
- trace_content = kwargs.get("trace_content", False)
28
+ capture_message_content = kwargs.get("capture_message_content", False)
29
29
  disable_metrics = kwargs.get("disable_metrics")
30
30
  version = importlib.metadata.version("groq")
31
31
 
@@ -34,7 +34,7 @@ class GroqInstrumentor(BaseInstrumentor):
34
34
  "groq.resources.chat.completions",
35
35
  "Completions.create",
36
36
  chat(version, environment, application_name,
37
- tracer, pricing_info, trace_content, metrics, disable_metrics),
37
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
38
38
  )
39
39
 
40
40
  #async
@@ -42,7 +42,7 @@ class GroqInstrumentor(BaseInstrumentor):
42
42
  "groq.resources.chat.completions",
43
43
  "AsyncCompletions.create",
44
44
  async_chat(version, environment, application_name,
45
- tracer, pricing_info, trace_content, metrics, disable_metrics),
45
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
46
46
  )
47
47
 
48
48
  def _uninstrument(self, **kwargs):
@@ -21,7 +21,7 @@ from openlit.semcov import SemanticConvetion
21
21
  logger = logging.getLogger(__name__)
22
22
 
23
23
  def async_chat(version, environment, application_name,
24
- tracer, pricing_info, trace_content, metrics, disable_metrics):
24
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
25
25
  """
26
26
  Generates a telemetry wrapper for chat completions to collect metrics.
27
27
 
@@ -31,7 +31,7 @@ def async_chat(version, environment, application_name,
31
31
  application_name: Name of the application using the Groq API.
32
32
  tracer: OpenTelemetry tracer for creating spans.
33
33
  pricing_info: Information used for calculating the cost of Groq usage.
34
- trace_content: Flag indicating whether to trace the actual content.
34
+ capture_message_content: Flag indicating whether to trace the actual content.
35
35
 
36
36
  Returns:
37
37
  A function that wraps the chat completions method to add telemetry.
@@ -221,7 +221,7 @@ def async_chat(version, environment, application_name,
221
221
  self._ttft)
222
222
  self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
223
223
  version)
224
- if trace_content:
224
+ if capture_message_content:
225
225
  self._span.add_event(
226
226
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
227
227
  attributes={
@@ -396,7 +396,7 @@ def async_chat(version, environment, application_name,
396
396
  end_time - start_time)
397
397
  span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
398
398
  version)
399
- if trace_content:
399
+ if capture_message_content:
400
400
  span.add_event(
401
401
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
402
402
  attributes={
@@ -407,7 +407,7 @@ def async_chat(version, environment, application_name,
407
407
  for i in range(kwargs.get('n',1)):
408
408
  span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
409
409
  [response_dict.get('choices')[i].get('finish_reason')])
410
- if trace_content:
410
+ if capture_message_content:
411
411
  span.add_event(
412
412
  name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
413
413
  attributes={
@@ -21,7 +21,7 @@ from openlit.semcov import SemanticConvetion
21
21
  logger = logging.getLogger(__name__)
22
22
 
23
23
  def chat(version, environment, application_name,
24
- tracer, pricing_info, trace_content, metrics, disable_metrics):
24
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
25
25
  """
26
26
  Generates a telemetry wrapper for chat completions to collect metrics.
27
27
 
@@ -31,7 +31,7 @@ def chat(version, environment, application_name,
31
31
  application_name: Name of the application using the Groq API.
32
32
  tracer: OpenTelemetry tracer for creating spans.
33
33
  pricing_info: Information used for calculating the cost of Groq usage.
34
- trace_content: Flag indicating whether to trace the actual content.
34
+ capture_message_content: Flag indicating whether to trace the actual content.
35
35
 
36
36
  Returns:
37
37
  A function that wraps the chat completions method to add telemetry.
@@ -221,7 +221,7 @@ def chat(version, environment, application_name,
221
221
  self._ttft)
222
222
  self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
223
223
  version)
224
- if trace_content:
224
+ if capture_message_content:
225
225
  self._span.add_event(
226
226
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
227
227
  attributes={
@@ -396,7 +396,7 @@ def chat(version, environment, application_name,
396
396
  end_time - start_time)
397
397
  span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
398
398
  version)
399
- if trace_content:
399
+ if capture_message_content:
400
400
  span.add_event(
401
401
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
402
402
  attributes={
@@ -407,7 +407,7 @@ def chat(version, environment, application_name,
407
407
  for i in range(kwargs.get('n',1)):
408
408
  span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
409
409
  [response_dict.get('choices')[i].get('finish_reason')])
410
- if trace_content:
410
+ if capture_message_content:
411
411
  span.add_event(
412
412
  name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
413
413
  attributes={
@@ -29,7 +29,7 @@ class HaystackInstrumentor(BaseInstrumentor):
29
29
  environment = kwargs.get("environment")
30
30
  tracer = kwargs.get("tracer")
31
31
  pricing_info = kwargs.get("pricing_info")
32
- trace_content = kwargs.get("trace_content")
32
+ capture_message_content = kwargs.get("capture_message_content")
33
33
  version = importlib.metadata.version("haystack-ai")
34
34
 
35
35
  for wrapped_method in WRAPPED_METHODS:
@@ -41,7 +41,7 @@ class HaystackInstrumentor(BaseInstrumentor):
41
41
  wrap_package,
42
42
  wrap_object,
43
43
  wrapper(gen_ai_endpoint, version, environment, application_name,
44
- tracer, pricing_info, trace_content),
44
+ tracer, pricing_info, capture_message_content),
45
45
  )
46
46
 
47
47
  @staticmethod
@@ -13,7 +13,7 @@ from openlit.semcov import SemanticConvetion
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
15
  def join_data(gen_ai_endpoint, version, environment, application_name,
16
- tracer, pricing_info, trace_content):
16
+ tracer, pricing_info, capture_message_content):
17
17
  """
18
18
  Creates a wrapper around a function call to trace and log its execution metrics.
19
19
 
@@ -27,7 +27,7 @@ def join_data(gen_ai_endpoint, version, environment, application_name,
27
27
  - application_name (str): Name of the Haystack application.
28
28
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
29
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.
30
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
31
31
 
32
32
  Returns:
33
33
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -30,7 +30,7 @@ class JulepInstrumentor(BaseInstrumentor):
30
30
  tracer = kwargs.get("tracer")
31
31
  metrics = kwargs.get("metrics_dict")
32
32
  pricing_info = kwargs.get("pricing_info", {})
33
- trace_content = kwargs.get("trace_content", False)
33
+ capture_message_content = kwargs.get("capture_message_content", False)
34
34
  disable_metrics = kwargs.get("disable_metrics")
35
35
  version = importlib.metadata.version("julep")
36
36
 
@@ -39,19 +39,19 @@ class JulepInstrumentor(BaseInstrumentor):
39
39
  "julep.resources.agents.agents",
40
40
  "AgentsResource.create",
41
41
  wrap_julep("julep.agents_create", version, environment, application_name,
42
- tracer, pricing_info, trace_content, metrics, disable_metrics),
42
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
43
43
  )
44
44
  wrap_function_wrapper(
45
45
  "julep.resources.tasks",
46
46
  "TasksResource.create",
47
47
  wrap_julep("julep.task_create", version, environment, application_name,
48
- tracer, pricing_info, trace_content, metrics, disable_metrics),
48
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
49
49
  )
50
50
  wrap_function_wrapper(
51
51
  "julep.resources.executions.executions",
52
52
  "ExecutionsResource.create",
53
53
  wrap_julep("julep.execution_create", version, environment, application_name,
54
- tracer, pricing_info, trace_content, metrics, disable_metrics),
54
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
55
55
  )
56
56
 
57
57
  # async
@@ -59,19 +59,19 @@ class JulepInstrumentor(BaseInstrumentor):
59
59
  "julep.resources.agents.agents",
60
60
  "AsyncAgentsResource.create",
61
61
  async_wrap_julep("julep.agents_create", version, environment, application_name,
62
- tracer, pricing_info, trace_content, metrics, disable_metrics),
62
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
63
63
  )
64
64
  wrap_function_wrapper(
65
65
  "julep.resources.tasks",
66
66
  "AsyncTasksResource.create",
67
67
  async_wrap_julep("julep.task_create", version, environment, application_name,
68
- tracer, pricing_info, trace_content, metrics, disable_metrics),
68
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
69
69
  )
70
70
  wrap_function_wrapper(
71
71
  "julep.resources.executions.executions",
72
72
  "AsyncExecutionsResource.create",
73
73
  async_wrap_julep("julep.execution_create", version, environment, application_name,
74
- tracer, pricing_info, trace_content, metrics, disable_metrics),
74
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
75
75
  )
76
76
 
77
77
 
@@ -13,7 +13,7 @@ from openlit.semcov import SemanticConvetion
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
15
  def async_wrap_julep(gen_ai_endpoint, version, environment, application_name,
16
- tracer, pricing_info, trace_content, metrics, disable_metrics):
16
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
17
17
  """
18
18
  Creates a wrapper around a function call to trace and log its execution metrics.
19
19
 
@@ -27,7 +27,7 @@ def async_wrap_julep(gen_ai_endpoint, version, environment, application_name,
27
27
  - application_name (str): Name of the application.
28
28
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
29
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.
30
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
31
31
 
32
32
  Returns:
33
33
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -88,7 +88,7 @@ def async_wrap_julep(gen_ai_endpoint, version, environment, application_name,
88
88
  elif gen_ai_endpoint == "julep.execution_create":
89
89
  span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
90
90
  kwargs.get("task_id", ""))
91
- if trace_content:
91
+ if capture_message_content:
92
92
  span.add_event(
93
93
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
94
94
  attributes={
@@ -13,7 +13,7 @@ from openlit.semcov import SemanticConvetion
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
15
  def wrap_julep(gen_ai_endpoint, version, environment, application_name,
16
- tracer, pricing_info, trace_content, metrics, disable_metrics):
16
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
17
17
  """
18
18
  Creates a wrapper around a function call to trace and log its execution metrics.
19
19
 
@@ -27,7 +27,7 @@ def wrap_julep(gen_ai_endpoint, version, environment, application_name,
27
27
  - application_name (str): Name of the Langchain application.
28
28
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
29
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.
30
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
31
31
 
32
32
  Returns:
33
33
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -88,7 +88,7 @@ def wrap_julep(gen_ai_endpoint, version, environment, application_name,
88
88
  elif gen_ai_endpoint == "julep.execution_create":
89
89
  span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
90
90
  kwargs.get("task_id", ""))
91
- if trace_content:
91
+ if capture_message_content:
92
92
  span.add_event(
93
93
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
94
94
  attributes={
@@ -96,7 +96,7 @@ class LangChainInstrumentor(BaseInstrumentor):
96
96
  environment = kwargs.get("environment")
97
97
  tracer = kwargs.get("tracer")
98
98
  pricing_info = kwargs.get("pricing_info")
99
- trace_content = kwargs.get("trace_content")
99
+ capture_message_content = kwargs.get("capture_message_content")
100
100
  metrics = kwargs.get("metrics_dict")
101
101
  disable_metrics = kwargs.get("disable_metrics")
102
102
  version = importlib.metadata.version("langchain")
@@ -110,7 +110,7 @@ class LangChainInstrumentor(BaseInstrumentor):
110
110
  wrap_package,
111
111
  wrap_object,
112
112
  wrapper(gen_ai_endpoint, version, environment, application_name,
113
- tracer, pricing_info, trace_content, metrics, disable_metrics),
113
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
114
114
  )
115
115
 
116
116
  @staticmethod
@@ -41,7 +41,7 @@ def get_attribute_from_instance_or_kwargs(instance, attribute_name, default=-1):
41
41
  return default
42
42
 
43
43
  def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
44
- tracer, pricing_info, trace_content, metrics, disable_metrics):
44
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
45
45
  """
46
46
  Creates a wrapper around a function call to trace and log its execution metrics.
47
47
 
@@ -55,7 +55,7 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
55
55
  - application_name (str): Name of the Langchain application.
56
56
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
57
57
  - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
58
- - trace_content (bool): Flag indicating whether to trace the content of the response.
58
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
59
59
 
60
60
  Returns:
61
61
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -114,7 +114,7 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
114
114
  return wrapper
115
115
 
116
116
  def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
117
- pricing_info, trace_content, metrics, disable_metrics):
117
+ pricing_info, capture_message_content, metrics, disable_metrics):
118
118
  """
119
119
  Creates a wrapper around Langchain hub operations for tracing and logging.
120
120
 
@@ -129,7 +129,7 @@ def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
129
129
  - application_name (str): Name of the Langchain application.
130
130
  - tracer (opentelemetry.trace.Tracer): The tracer for OpenTelemetry tracing.
131
131
  - pricing_info (dict): Pricing information for the operation (not currently used).
132
- - trace_content (bool): Indicates if the content of the response should be traced.
132
+ - capture_message_content (bool): Indicates if the content of the response should be traced.
133
133
 
134
134
  Returns:
135
135
  - function: A new function that wraps the original hub operation call with added
@@ -189,7 +189,7 @@ def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
189
189
  return wrapper
190
190
 
191
191
  def async_chat(gen_ai_endpoint, version, environment, application_name,
192
- tracer, pricing_info, trace_content, metrics, disable_metrics):
192
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
193
193
  """
194
194
  Creates a wrapper around a function call to trace and log its execution metrics.
195
195
 
@@ -202,7 +202,7 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
202
202
  - application_name (str): Name of the Langchain application.
203
203
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
204
204
  - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
205
- - trace_content (bool): Flag indicating whether to trace the content of the response.
205
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
206
206
 
207
207
  Returns:
208
208
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -287,6 +287,11 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
287
287
  pricing_info, input_tokens, output_tokens
288
288
  )
289
289
 
290
+ try:
291
+ llm_response = response.content
292
+ except AttributeError:
293
+ llm_response = response
294
+
290
295
  # Set base span attribues (OTel Semconv)
291
296
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
292
297
  span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
@@ -328,18 +333,17 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
328
333
  span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
329
334
  version)
330
335
 
331
- if trace_content:
336
+ if capture_message_content:
332
337
  span.add_event(
333
338
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
334
339
  attributes={
335
340
  SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
336
341
  },
337
342
  )
338
- completion_content = getattr(response, 'content', "")
339
343
  span.add_event(
340
344
  name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
341
345
  attributes={
342
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: completion_content,
346
+ SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
343
347
  },
344
348
  )
345
349
 
@@ -41,7 +41,7 @@ def get_attribute_from_instance_or_kwargs(instance, attribute_name, default=-1):
41
41
  return default
42
42
 
43
43
  def general_wrap(gen_ai_endpoint, version, environment, application_name,
44
- tracer, pricing_info, trace_content, metrics, disable_metrics):
44
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
45
45
  """
46
46
  Creates a wrapper around a function call to trace and log its execution metrics.
47
47
 
@@ -55,7 +55,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
55
55
  - application_name (str): Name of the Langchain application.
56
56
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
57
57
  - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
58
- - trace_content (bool): Flag indicating whether to trace the content of the response.
58
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
59
59
 
60
60
  Returns:
61
61
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -114,7 +114,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
114
114
  return wrapper
115
115
 
116
116
  def hub(gen_ai_endpoint, version, environment, application_name, tracer,
117
- pricing_info, trace_content, metrics, disable_metrics):
117
+ pricing_info, capture_message_content, metrics, disable_metrics):
118
118
  """
119
119
  Creates a wrapper around Langchain hub operations for tracing and logging.
120
120
 
@@ -129,7 +129,7 @@ def hub(gen_ai_endpoint, version, environment, application_name, tracer,
129
129
  - application_name (str): Name of the Langchain application.
130
130
  - tracer (opentelemetry.trace.Tracer): The tracer for OpenTelemetry tracing.
131
131
  - pricing_info (dict): Pricing information for the operation (not currently used).
132
- - trace_content (bool): Indicates if the content of the response should be traced.
132
+ - capture_message_content (bool): Indicates if the content of the response should be traced.
133
133
 
134
134
  Returns:
135
135
  - function: A new function that wraps the original hub operation call with added
@@ -189,7 +189,7 @@ def hub(gen_ai_endpoint, version, environment, application_name, tracer,
189
189
  return wrapper
190
190
 
191
191
  def chat(gen_ai_endpoint, version, environment, application_name,
192
- tracer, pricing_info, trace_content, metrics, disable_metrics):
192
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):
193
193
  """
194
194
  Creates a wrapper around a function call to trace and log its execution metrics.
195
195
 
@@ -202,7 +202,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
202
202
  - application_name (str): Name of the Langchain application.
203
203
  - tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
204
204
  - pricing_info (dict): Information about the pricing for internal metrics (currently not used).
205
- - trace_content (bool): Flag indicating whether to trace the content of the response.
205
+ - capture_message_content (bool): Flag indicating whether to trace the content of the response.
206
206
 
207
207
  Returns:
208
208
  - function: A higher-order function that takes a function 'wrapped' and returns
@@ -287,6 +287,11 @@ def chat(gen_ai_endpoint, version, environment, application_name,
287
287
  pricing_info, input_tokens, output_tokens
288
288
  )
289
289
 
290
+ try:
291
+ llm_response = response.content
292
+ except AttributeError:
293
+ llm_response = response
294
+
290
295
  # Set base span attribues (OTel Semconv)
291
296
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
292
297
  span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
@@ -328,7 +333,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
328
333
  span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
329
334
  version)
330
335
 
331
- if trace_content:
336
+ if capture_message_content:
332
337
  span.add_event(
333
338
  name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
334
339
  attributes={
@@ -338,7 +343,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
338
343
  span.add_event(
339
344
  name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
340
345
  attributes={
341
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response,
346
+ SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
342
347
  },
343
348
  )
344
349
 
@@ -26,7 +26,7 @@ class LettaInstrumentor(BaseInstrumentor):
26
26
  tracer = kwargs.get("tracer")
27
27
  metrics = kwargs.get("metrics_dict")
28
28
  pricing_info = kwargs.get("pricing_info", {})
29
- trace_content = kwargs.get("trace_content", False)
29
+ capture_message_content = kwargs.get("capture_message_content", False)
30
30
  disable_metrics = kwargs.get("disable_metrics")
31
31
  version = importlib.metadata.version("letta")
32
32
 
@@ -34,42 +34,42 @@ class LettaInstrumentor(BaseInstrumentor):
34
34
  "letta.client.client",
35
35
  "LocalClient.create_agent",
36
36
  create_agent("letta.create_agent", version, environment, application_name,
37
- tracer, pricing_info, trace_content, metrics, disable_metrics),
37
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
38
38
  )
39
39
 
40
40
  wrap_function_wrapper(
41
41
  "letta.client.client",
42
42
  "LocalClient.get_agent",
43
43
  create_agent("letta.get_agent", version, environment, application_name,
44
- tracer, pricing_info, trace_content, metrics, disable_metrics),
44
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
45
45
  )
46
46
 
47
47
  wrap_function_wrapper(
48
48
  "letta.client.client",
49
49
  "LocalClient.send_message",
50
50
  send_message("letta.send_message", version, environment, application_name,
51
- tracer, pricing_info, trace_content, metrics, disable_metrics),
51
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
52
52
  )
53
53
 
54
54
  wrap_function_wrapper(
55
55
  "letta.client.client",
56
56
  "RESTClient.create_agent",
57
57
  create_agent("letta.create_agent", version, environment, application_name,
58
- tracer, pricing_info, trace_content, metrics, disable_metrics),
58
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
59
59
  )
60
60
 
61
61
  wrap_function_wrapper(
62
62
  "letta.client.client",
63
63
  "RESTClient.get_agent",
64
64
  create_agent("letta.get_agent", version, environment, application_name,
65
- tracer, pricing_info, trace_content, metrics, disable_metrics),
65
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
66
66
  )
67
67
 
68
68
  wrap_function_wrapper(
69
69
  "letta.client.client",
70
70
  "RESTClient.send_message",
71
71
  send_message("letta.send_message", version, environment, application_name,
72
- tracer, pricing_info, trace_content, metrics, disable_metrics),
72
+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),
73
73
  )
74
74
 
75
75
  def _uninstrument(self, **kwargs):