openinference-instrumentation-beeai 0.1.8__tar.gz → 0.1.9__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 (22) hide show
  1. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/PKG-INFO +1 -1
  2. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/__init__.py +3 -1
  3. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/_span.py +15 -0
  4. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/_utils.py +9 -2
  5. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/base.py +3 -4
  6. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/tool.py +2 -0
  7. openinference_instrumentation_beeai-0.1.9/src/openinference/instrumentation/beeai/version.py +1 -0
  8. openinference_instrumentation_beeai-0.1.8/src/openinference/instrumentation/beeai/version.py +0 -1
  9. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/.gitignore +0 -0
  10. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/README.md +0 -0
  11. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/pyproject.toml +0 -0
  12. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/__init__.py +0 -0
  13. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/agents/__init__.py +0 -0
  14. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/agents/base.py +0 -0
  15. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/agents/react.py +0 -0
  16. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/agents/requirement_agent.py +0 -0
  17. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/agents/tool_calling.py +0 -0
  18. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/chat.py +0 -0
  19. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/embedding.py +0 -0
  20. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/locator.py +0 -0
  21. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/requirement.py +0 -0
  22. {openinference_instrumentation_beeai-0.1.8 → openinference_instrumentation_beeai-0.1.9}/src/openinference/instrumentation/beeai/processors/workflow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openinference-instrumentation-beeai
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: OpenInference BeeAI Instrumentation
5
5
  Project-URL: Homepage, https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-beeai
6
6
  Author: IBM Corp.
@@ -2,6 +2,8 @@ import logging
2
2
  from importlib.metadata import PackageNotFoundError, version
3
3
  from typing import TYPE_CHECKING, Any, Callable, Collection
4
4
 
5
+ from opentelemetry.trace import StatusCode
6
+
5
7
  if TYPE_CHECKING:
6
8
  from beeai_framework.emitter import EventMeta
7
9
 
@@ -82,7 +84,7 @@ class BeeAIInstrumentor(BaseInstrumentor): # type: ignore
82
84
  self._build_tree(children)
83
85
 
84
86
  current_span.set_status(node.status)
85
- if node.error is not None:
87
+ if node.error is not None and node.status == StatusCode.ERROR:
86
88
  current_span.record_exception(node.error)
87
89
 
88
90
  current_span.end(_datetime_to_span_time(node.ended_at) if node.ended_at else None)
@@ -77,5 +77,20 @@ class SpanWrapper:
77
77
  def set_status(self, status: StatusCode) -> None:
78
78
  self.status = status
79
79
 
80
+ def reset_exception(self) -> None:
81
+ self.error = None
82
+ self.set_status(StatusCode.OK)
83
+
80
84
  def record_exception(self, error: Exception) -> None:
85
+ from beeai_framework.errors import FrameworkError
86
+
81
87
  self.error = error
88
+ self.set_status(StatusCode.ERROR)
89
+ self.set_attributes(
90
+ {
91
+ SpanAttributes.OUTPUT_VALUE: error.explain()
92
+ if isinstance(error, FrameworkError)
93
+ else str(error),
94
+ SpanAttributes.OUTPUT_MIME_TYPE: OpenInferenceMimeTypeValues.TEXT.value,
95
+ }
96
+ )
@@ -22,7 +22,7 @@ def _unpack_object(obj: dict[str, Any] | list[Any] | BaseModel, prefix: str = ""
22
22
  obj_ref = obj
23
23
  obj = json.loads(stringify(obj))
24
24
  if not isinstance(obj, dict) and not isinstance(obj, list):
25
- logger.warning(f"Cannot unpack object of type {type(obj_ref)} (prefix={prefix})")
25
+ logger.debug(f"Cannot unpack object of type {type(obj_ref)} (prefix={prefix})")
26
26
  return {"value": str(obj)}
27
27
 
28
28
  if prefix and prefix.startswith("."):
@@ -34,7 +34,7 @@ def _unpack_object(obj: dict[str, Any] | list[Any] | BaseModel, prefix: str = ""
34
34
  for key, value in obj.items() if isinstance(obj, dict) else enumerate(obj):
35
35
  if value is None:
36
36
  continue
37
- if is_primitive(value):
37
+ if is_primitive(value) or has_custom_str(value):
38
38
  output[f"{prefix}{key}"] = str(value)
39
39
  else:
40
40
  output.update(_unpack_object(value, prefix=f"{prefix}{key}"))
@@ -45,6 +45,13 @@ def is_primitive(value: Any) -> bool:
45
45
  return isinstance(value, str | bool | int | float | type(None))
46
46
 
47
47
 
48
+ def has_custom_str(value: Any) -> bool:
49
+ if value.__class__.__module__ == "builtins":
50
+ return False
51
+
52
+ return value.__class__.__str__ is not object.__str__
53
+
54
+
48
55
  def stringify(value: Any, pretty: bool = False) -> str:
49
56
  if is_primitive(value):
50
57
  return str(value)
@@ -43,6 +43,9 @@ class Processor:
43
43
  pass
44
44
 
45
45
  async def end(self, event: "RunContextFinishEvent", meta: "EventMeta") -> None:
46
+ if event.error is not None:
47
+ self.span.record_exception(event.error)
48
+
46
49
  if event.output is not None:
47
50
  if SpanAttributes.OUTPUT_VALUE not in self.span.attributes:
48
51
  self.span.attributes.update(
@@ -53,8 +56,4 @@ class Processor:
53
56
  )
54
57
  self.span.set_status(StatusCode.OK)
55
58
 
56
- if event.error is not None:
57
- self.span.set_status(StatusCode.ERROR)
58
- self.span.record_exception(event.error)
59
-
60
59
  self.span.ended_at = meta.created_at
@@ -51,6 +51,7 @@ class ToolProcessor(Processor):
51
51
  case ToolSuccessEvent():
52
52
  output_cls = type(event.output)
53
53
 
54
+ self.span.reset_exception()
54
55
  self.span.set_attributes(
55
56
  {
56
57
  SpanAttributes.OUTPUT_VALUE: event.output.get_text_content(),
@@ -62,6 +63,7 @@ class ToolProcessor(Processor):
62
63
  case ToolErrorEvent():
63
64
  span = self.span.child(meta.name, event=(event, meta))
64
65
  span.record_exception(event.error)
66
+ self.span.record_exception(event.error)
65
67
  case ToolRetryEvent():
66
68
  self.span.child(meta.name, event=(event, meta))
67
69
  case _: