opentelemetry-instrumentation-llamaindex 0.39.1__py3-none-any.whl → 0.39.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of opentelemetry-instrumentation-llamaindex might be problematic. Click here for more details.

@@ -38,24 +38,39 @@ from opentelemetry.instrumentation.llamaindex.dispatcher_wrapper import instrume
38
38
 
39
39
  logger = logging.getLogger(__name__)
40
40
 
41
- _instruments = ("llama-index >= 0.7.0",)
41
+ _core_instruments = ("llama-index-core >= 0.7.0", )
42
+ _full_instruments = ("llama-index >= 0.7.0",)
42
43
 
43
44
 
44
45
  class LlamaIndexInstrumentor(BaseInstrumentor):
45
- """An instrumentor for LlamaIndex SDK."""
46
+ """An instrumentor for both: core and legacy LlamaIndex SDK."""
46
47
 
47
48
  def __init__(self, exception_logger=None):
48
- super().__init__()
49
- Config.exception_logger = exception_logger
49
+ self.legacy = LlamaIndexInstrumentorFull(exception_logger)
50
+ self.core = LlamaIndexInstrumentorCore(exception_logger)
50
51
 
51
52
  def instrumentation_dependencies(self) -> Collection[str]:
52
- return _instruments
53
+ return ()
53
54
 
54
55
  def _instrument(self, **kwargs):
56
+ # Try to use the legacy entry point for instrumentation
57
+ if self.legacy._check_dependency_conflicts() is None:
58
+ self.legacy.instrument(**kwargs)
59
+ if not self.legacy._is_instrumented_by_opentelemetry:
60
+ # it didn't work -> try the new package
61
+ if self.core._check_dependency_conflicts() is None:
62
+ self.core.instrument(**kwargs)
63
+
64
+ def _uninstrument(self, **kwargs):
65
+ self.legacy.uninstrument(**kwargs)
66
+ self.core.uninstrument(**kwargs)
67
+
68
+ @staticmethod
69
+ def apply_instrumentation(name, **kwargs):
55
70
  tracer_provider = kwargs.get("tracer_provider")
56
71
  tracer = get_tracer(__name__, __version__, tracer_provider)
57
72
 
58
- if import_version("llama-index") >= "0.10.20":
73
+ if import_version(name) >= "0.10.20":
59
74
  instrument_with_dispatcher(tracer)
60
75
  else:
61
76
  RetrieverQueryEngineInstrumentor(tracer).instrument()
@@ -67,5 +82,36 @@ class LlamaIndexInstrumentor(BaseInstrumentor):
67
82
  BaseAgentInstrumentor(tracer).instrument()
68
83
  BaseToolInstrumentor(tracer).instrument()
69
84
 
85
+
86
+ class LlamaIndexInstrumentorCore(BaseInstrumentor):
87
+ """An instrumentor for core LlamaIndex SDK."""
88
+
89
+ def __init__(self, exception_logger=None):
90
+ super().__init__()
91
+ Config.exception_logger = exception_logger
92
+
93
+ def instrumentation_dependencies(self) -> Collection[str]:
94
+ return _core_instruments
95
+
96
+ def _instrument(self, **kwargs):
97
+ LlamaIndexInstrumentor.apply_instrumentation("llama-index-core", **kwargs)
98
+
99
+ def _uninstrument(self, **kwargs):
100
+ pass
101
+
102
+
103
+ class LlamaIndexInstrumentorFull(BaseInstrumentor):
104
+ """An instrumentor for legacy LlamaIndex SDK."""
105
+
106
+ def __init__(self, exception_logger=None):
107
+ super().__init__()
108
+ Config.exception_logger = exception_logger
109
+
110
+ def instrumentation_dependencies(self) -> Collection[str]:
111
+ return _full_instruments
112
+
113
+ def _instrument(self, **kwargs):
114
+ LlamaIndexInstrumentor.apply_instrumentation("llama-index", **kwargs)
115
+
70
116
  def _uninstrument(self, **kwargs):
71
117
  pass
@@ -1 +1 @@
1
- __version__ = "0.39.1"
1
+ __version__ = "0.39.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: opentelemetry-instrumentation-llamaindex
3
- Version: 0.39.1
3
+ Version: 0.39.3
4
4
  Summary: OpenTelemetry LlamaIndex instrumentation
5
5
  License: Apache-2.0
6
6
  Author: Gal Kleinman
@@ -1,4 +1,4 @@
1
- opentelemetry/instrumentation/llamaindex/__init__.py,sha256=m5ycp9c8Zt5gT-G5QkUC-0bWb0wGiTsjxAKHSZUuSs8,2622
1
+ opentelemetry/instrumentation/llamaindex/__init__.py,sha256=chlwxW79qgH42JXjRzV3EJxmiONJwoFpTLdWa9GO1pU,4270
2
2
  opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py,sha256=WvPuSECoouFQ3MzItWDcnWVQXULjskfLxE-zyH5HrTg,2645
3
3
  opentelemetry/instrumentation/llamaindex/base_embedding_instrumentor.py,sha256=SsbAhMtIiC5Djrc32LOkCMxETJlz4653aeC1x0uXm4g,2207
4
4
  opentelemetry/instrumentation/llamaindex/base_retriever_instrumentor.py,sha256=aHuH7VNz6D1fWsc0jXV3U3vbqG-Mo20mhHIHcfJbuzo,2346
@@ -10,8 +10,8 @@ opentelemetry/instrumentation/llamaindex/dispatcher_wrapper.py,sha256=a4l-dnUCjz
10
10
  opentelemetry/instrumentation/llamaindex/query_pipeline_instrumentor.py,sha256=PfUens1GisvbU98TLXEJ8_ALWGhnbOdsQkMwhFom8ZA,2496
11
11
  opentelemetry/instrumentation/llamaindex/retriever_query_engine_instrumentor.py,sha256=OtQ7uZckFtzq9mzqSlKDhvO-Uffl99axuZ2TJXCqDRQ,2627
12
12
  opentelemetry/instrumentation/llamaindex/utils.py,sha256=7NfuSbIf5Uohxo79AUM_gB-8RQtxgUO5glCWzXHeueQ,2349
13
- opentelemetry/instrumentation/llamaindex/version.py,sha256=cg7Dz0Iq1rY6w0Q0CcrPmBwg1BFyVuHpxRW72zbf07c,23
14
- opentelemetry_instrumentation_llamaindex-0.39.1.dist-info/METADATA,sha256=uqg-45GlXbYLIGLZag9aq9b1STtn5Dt8Ovv8VyomARo,2212
15
- opentelemetry_instrumentation_llamaindex-0.39.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
16
- opentelemetry_instrumentation_llamaindex-0.39.1.dist-info/entry_points.txt,sha256=gtV40W4oFCp6VNvgowTKa0zQjfIrvfdlYflgGdSsA5A,106
17
- opentelemetry_instrumentation_llamaindex-0.39.1.dist-info/RECORD,,
13
+ opentelemetry/instrumentation/llamaindex/version.py,sha256=GYnnsRVgceT_tJ60Z37OvvWZHZCwQZoLzh7147BZRDs,23
14
+ opentelemetry_instrumentation_llamaindex-0.39.3.dist-info/METADATA,sha256=E1WXduE6-SuWmVBWRi4TPf3youkNqHZKfDXRwRLVFTU,2212
15
+ opentelemetry_instrumentation_llamaindex-0.39.3.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
16
+ opentelemetry_instrumentation_llamaindex-0.39.3.dist-info/entry_points.txt,sha256=gtV40W4oFCp6VNvgowTKa0zQjfIrvfdlYflgGdSsA5A,106
17
+ opentelemetry_instrumentation_llamaindex-0.39.3.dist-info/RECORD,,