opentelemetry-instrumentation-llamaindex 0.16.5__tar.gz → 0.16.7__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 opentelemetry-instrumentation-llamaindex might be problematic. Click here for more details.

Files changed (17) hide show
  1. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/PKG-INFO +1 -1
  2. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/__init__.py +5 -0
  3. opentelemetry_instrumentation_llamaindex-0.16.7/opentelemetry/instrumentation/llamaindex/config.py +2 -0
  4. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/custom_llm_instrumentor.py +3 -0
  5. opentelemetry_instrumentation_llamaindex-0.16.7/opentelemetry/instrumentation/llamaindex/utils.py +49 -0
  6. opentelemetry_instrumentation_llamaindex-0.16.7/opentelemetry/instrumentation/llamaindex/version.py +1 -0
  7. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/pyproject.toml +4 -4
  8. opentelemetry_instrumentation_llamaindex-0.16.5/opentelemetry/instrumentation/llamaindex/utils.py +0 -27
  9. opentelemetry_instrumentation_llamaindex-0.16.5/opentelemetry/instrumentation/llamaindex/version.py +0 -1
  10. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/README.md +0 -0
  11. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py +0 -0
  12. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/base_embedding_instrumentor.py +0 -0
  13. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/base_retriever_instrumentor.py +0 -0
  14. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/base_synthesizer_instrumentor.py +0 -0
  15. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/base_tool_instrumentor.py +0 -0
  16. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/query_pipeline_instrumentor.py +0 -0
  17. {opentelemetry_instrumentation_llamaindex-0.16.5 → opentelemetry_instrumentation_llamaindex-0.16.7}/opentelemetry/instrumentation/llamaindex/retriever_query_engine_instrumentor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentelemetry-instrumentation-llamaindex
3
- Version: 0.16.5
3
+ Version: 0.16.7
4
4
  Summary: OpenTelemetry LlamaIndex instrumentation
5
5
  Home-page: https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-llamaindex
6
6
  License: Apache-2.0
@@ -3,6 +3,7 @@
3
3
  import logging
4
4
  from typing import Collection
5
5
 
6
+ from opentelemetry.instrumentation.llamaindex.config import Config
6
7
  from opentelemetry.trace import get_tracer
7
8
 
8
9
  from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
@@ -41,6 +42,10 @@ _instruments = ("llama-index >= 0.7.0",)
41
42
  class LlamaIndexInstrumentor(BaseInstrumentor):
42
43
  """An instrumentor for LlamaIndex SDK."""
43
44
 
45
+ def __init__(self, exception_logger=None):
46
+ super().__init__()
47
+ Config.exception_logger = exception_logger
48
+
44
49
  def instrumentation_dependencies(self) -> Collection[str]:
45
50
  return _instruments
46
51
 
@@ -0,0 +1,2 @@
1
+ class Config:
2
+ exception_logger = None
@@ -10,6 +10,7 @@ from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
10
10
  from opentelemetry.semconv.ai import SpanAttributes, LLMRequestTypeValues
11
11
  from opentelemetry.instrumentation.llamaindex.utils import (
12
12
  _with_tracer_wrapper,
13
+ dont_throw,
13
14
  start_as_current_span_async,
14
15
  should_send_prompts,
15
16
  )
@@ -139,6 +140,7 @@ async def acomplete_wrapper(tracer, wrapped, instance: CustomLLM, args, kwargs):
139
140
  return response
140
141
 
141
142
 
143
+ @dont_throw
142
144
  def _handle_request(span, llm_request_type, args, kwargs, instance: CustomLLM):
143
145
  _set_span_attribute(span, SpanAttributes.LLM_VENDOR, instance.__class__.__name__)
144
146
  _set_span_attribute(span, SpanAttributes.LLM_REQUEST_TYPE, llm_request_type.value)
@@ -164,6 +166,7 @@ def _handle_request(span, llm_request_type, args, kwargs, instance: CustomLLM):
164
166
  return
165
167
 
166
168
 
169
+ @dont_throw
167
170
  def _handle_response(span, llm_request_type, instance, response):
168
171
  _set_span_attribute(
169
172
  span, SpanAttributes.LLM_RESPONSE_MODEL, instance.metadata.model_name
@@ -0,0 +1,49 @@
1
+ import os
2
+ import logging
3
+ from contextlib import asynccontextmanager
4
+
5
+ from opentelemetry import context as context_api
6
+ from opentelemetry.instrumentation.llamaindex.config import Config
7
+
8
+
9
+ def _with_tracer_wrapper(func):
10
+ def _with_tracer(tracer):
11
+ def wrapper(wrapped, instance, args, kwargs):
12
+ return func(tracer, wrapped, instance, args, kwargs)
13
+
14
+ return wrapper
15
+
16
+ return _with_tracer
17
+
18
+
19
+ @asynccontextmanager
20
+ async def start_as_current_span_async(tracer, *args, **kwargs):
21
+ with tracer.start_as_current_span(*args, **kwargs) as span:
22
+ yield span
23
+
24
+
25
+ def should_send_prompts():
26
+ return (
27
+ os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
28
+ ).lower() == "true" or context_api.get_value("override_enable_content_tracing")
29
+
30
+
31
+ def dont_throw(func):
32
+ """
33
+ A decorator that wraps the passed in function and logs exceptions instead of throwing them.
34
+
35
+ @param func: The function to wrap
36
+ @return: The wrapper function
37
+ """
38
+ # Obtain a logger specific to the function's module
39
+ logger = logging.getLogger(func.__module__)
40
+
41
+ def wrapper(*args, **kwargs):
42
+ try:
43
+ return func(*args, **kwargs)
44
+ except Exception as e:
45
+ logger.warning("Failed to execute %s, error: %s", func.__name__, str(e))
46
+ if Config.exception_logger:
47
+ Config.exception_logger(e)
48
+
49
+ return wrapper
@@ -8,7 +8,7 @@ show_missing = true
8
8
 
9
9
  [tool.poetry]
10
10
  name = "opentelemetry-instrumentation-llamaindex"
11
- version = "0.16.5"
11
+ version = "0.16.7"
12
12
  description = "OpenTelemetry LlamaIndex instrumentation"
13
13
  authors = [
14
14
  "Gal Kleinman <gal@traceloop.com>",
@@ -44,9 +44,9 @@ openai = "=1.12.0"
44
44
  opentelemetry-sdk = "^1.23.0"
45
45
  llama-index = "^0.10.10"
46
46
  llama-index-postprocessor-cohere-rerank = "^0.1.2"
47
- opentelemetry-instrumentation-openai = "==0.16.5"
48
- opentelemetry-instrumentation-cohere = "==0.16.5"
49
- opentelemetry-instrumentation-chromadb = "==0.16.5"
47
+ opentelemetry-instrumentation-openai = "==0.16.7"
48
+ opentelemetry-instrumentation-cohere = "==0.16.7"
49
+ opentelemetry-instrumentation-chromadb = "==0.16.7"
50
50
  sqlalchemy = "^2.0.27"
51
51
  llama-index-agent-openai = ">=0.1.5,<0.3.0"
52
52
  llama-index-vector-stores-chroma = "^0.1.5"
@@ -1,27 +0,0 @@
1
- import os
2
-
3
- from contextlib import asynccontextmanager
4
-
5
- from opentelemetry import context as context_api
6
-
7
-
8
- def _with_tracer_wrapper(func):
9
- def _with_tracer(tracer):
10
- def wrapper(wrapped, instance, args, kwargs):
11
- return func(tracer, wrapped, instance, args, kwargs)
12
-
13
- return wrapper
14
-
15
- return _with_tracer
16
-
17
-
18
- @asynccontextmanager
19
- async def start_as_current_span_async(tracer, *args, **kwargs):
20
- with tracer.start_as_current_span(*args, **kwargs) as span:
21
- yield span
22
-
23
-
24
- def should_send_prompts():
25
- return (
26
- os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
27
- ).lower() == "true" or context_api.get_value("override_enable_content_tracing")