lmnr 0.4.46__py3-none-any.whl → 0.4.48__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.
@@ -191,4 +191,5 @@ def _should_send_prompts():
191
191
 
192
192
 
193
193
  def _process_exception(span: Span, e: Exception):
194
- span.record_exception(e)
194
+ # Note that this `escaped` is sent as a StringValue("True"), not a boolean.
195
+ span.record_exception(e, escaped=True)
lmnr/sdk/laminar.py CHANGED
@@ -12,6 +12,7 @@ from lmnr.openllmetry_sdk.tracing.attributes import (
12
12
  from lmnr.openllmetry_sdk.decorators.base import json_dumps
13
13
  from opentelemetry import context, trace
14
14
  from opentelemetry.context import attach, detach, set_value
15
+ from opentelemetry.sdk.trace import SpanProcessor
15
16
  from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
16
17
  from opentelemetry.util.types import AttributeValue
17
18
 
@@ -79,6 +80,7 @@ class Laminar:
79
80
  http_port: Optional[int] = None,
80
81
  grpc_port: Optional[int] = None,
81
82
  instruments: Optional[Set[Instruments]] = None,
83
+ _processor: Optional[SpanProcessor] = None,
82
84
  ):
83
85
  """Initialize Laminar context across the application.
84
86
  This method must be called before using any other Laminar methods or
@@ -133,7 +135,16 @@ class Laminar:
133
135
  cls.__env = env
134
136
  cls.__initialized = True
135
137
  cls._initialize_logger()
138
+
139
+ if _processor is not None:
140
+ cls.__logger.warning(
141
+ "Using a custom span processor. This feature is added for tests only. "
142
+ "Any use of this feature outside of tests is not supported and "
143
+ "advised against."
144
+ )
145
+
136
146
  Traceloop.init(
147
+ processor=_processor,
137
148
  exporter=OTLPSpanExporter(
138
149
  endpoint=cls.__base_grpc_url,
139
150
  headers={"authorization": f"Bearer {cls.__project_api_key}"},
@@ -268,13 +279,9 @@ class Laminar:
268
279
  value: Optional[AttributeValue] = None,
269
280
  timestamp: Optional[Union[datetime.datetime, int]] = None,
270
281
  ):
271
- """Associate an event with the current span. If event with such
272
- name never existed, Laminar will create a new event and infer its type
273
- from the value. If the event already exists, Laminar will append the
274
- value to the event if and only if the value is of a matching type.
275
- Otherwise, the event won't be recorded.
276
- Supported types are string, numeric, and boolean. If the value
277
- is `None`, event is considered a boolean tag with the value of `True`.
282
+ """Associate an event with the current span. If using manual\
283
+ instrumentation, use raw OpenTelemetry `span.add_event()` instead.\
284
+ `value` will be saved as a `lmnr.event.value` attribute.
278
285
 
279
286
  Args:
280
287
  name (str): event name
@@ -672,9 +679,9 @@ class Laminar:
672
679
  def clear_metadata(cls):
673
680
  """Clear the metadata from the context"""
674
681
  props: dict = copy.copy(context.get_value("association_properties"))
675
- for k in props.keys():
676
- if k.startswith("metadata."):
677
- props.pop(k)
682
+ metadata_keys = [k for k in props.keys() if k.startswith("metadata.")]
683
+ for k in metadata_keys:
684
+ props.pop(k)
678
685
  set_association_properties(props)
679
686
 
680
687
  @classmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.4.46
3
+ Version: 0.4.48
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -5,7 +5,7 @@ lmnr/openllmetry_sdk/.python-version,sha256=9OLQBQVbD4zE4cJsPePhnAfV_snrPSoqEQw-
5
5
  lmnr/openllmetry_sdk/__init__.py,sha256=vVSGTAwUnJvdulHtslkGAd8QCBuv78WUK3bgfBpH6Do,2390
6
6
  lmnr/openllmetry_sdk/config/__init__.py,sha256=DliMGp2NjYAqRFLKpWQPUKjGMHRO8QsVfazBA1qENQ8,248
7
7
  lmnr/openllmetry_sdk/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- lmnr/openllmetry_sdk/decorators/base.py,sha256=f8kh7TG3Q99RGXLMrLNlq12s1FWRBftWjzFBpc813k4,6027
8
+ lmnr/openllmetry_sdk/decorators/base.py,sha256=rZC5BgLULll0fZFRZ_Oe1XN-BhctKCpTo4TDsKvSfL4,6121
9
9
  lmnr/openllmetry_sdk/instruments.py,sha256=CGGUEELldrXkQwAzAkDeAtDq07_pjhz7i14a92P7C_E,1036
10
10
  lmnr/openllmetry_sdk/tracing/__init__.py,sha256=xT73L1t2si2CM6QmMiTZ7zn-dKKYBLNrpBBWq6WfVBw,68
11
11
  lmnr/openllmetry_sdk/tracing/attributes.py,sha256=B_4KVYWAUu-6DQmsm2eCJQcTxm8pG1EByCBK3uOPkuI,1293
@@ -22,12 +22,12 @@ lmnr/sdk/datasets.py,sha256=KNMp_v3z1ocIltIw7kTgj8o-l9R8N8Tgj0sw1ajQ9C8,1582
22
22
  lmnr/sdk/decorators.py,sha256=ja2EUWUWvFOp28ER0k78PRuxNahwCVyH0TdM3U-xY7U,1856
23
23
  lmnr/sdk/eval_control.py,sha256=G6Fg3Xx_KWv72iBaWlNMdyRTF2bZFQnwJ68sJNSpIcY,177
24
24
  lmnr/sdk/evaluations.py,sha256=gLImD_uB9uXgw07QiJ_OYRTFDGxiPtFCO1c8HyOq2s0,15935
25
- lmnr/sdk/laminar.py,sha256=4Saelm9m6pB9GWquCdHWY-1VhAB8Q2tWlq6hnmorzHU,31250
25
+ lmnr/sdk/laminar.py,sha256=pgvkCswo9csOIWD3DWr6EW2UqMbUWc-AomVVOGD2U2E,31418
26
26
  lmnr/sdk/log.py,sha256=cZBeUoSK39LMEV-X4-eEhTWOciULRfHaKfRK8YqIM8I,1532
27
27
  lmnr/sdk/types.py,sha256=FCNoFoa0ingOvpXGfbiETVsakYyq9Zpoc56MXJ1YDzQ,6390
28
28
  lmnr/sdk/utils.py,sha256=Uk8y15x-sd5tP2ERONahElLDJVEy_3dA_1_5g9A6auY,3358
29
- lmnr-0.4.46.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
30
- lmnr-0.4.46.dist-info/METADATA,sha256=cL1X2RUUQ9jI6m8iybxhBOE1LsoKVxXUYYHp_WmzqNA,12244
31
- lmnr-0.4.46.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
- lmnr-0.4.46.dist-info/entry_points.txt,sha256=K1jE20ww4jzHNZLnsfWBvU3YKDGBgbOiYG5Y7ivQcq4,37
33
- lmnr-0.4.46.dist-info/RECORD,,
29
+ lmnr-0.4.48.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
30
+ lmnr-0.4.48.dist-info/METADATA,sha256=KCZg8NS72mThs3tAJ4SL9OwDSTcvsosx5JxzpDTtVTw,12244
31
+ lmnr-0.4.48.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
+ lmnr-0.4.48.dist-info/entry_points.txt,sha256=K1jE20ww4jzHNZLnsfWBvU3YKDGBgbOiYG5Y7ivQcq4,37
33
+ lmnr-0.4.48.dist-info/RECORD,,
File without changes
File without changes