haiway 0.18.1__py3-none-any.whl → 0.18.2__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.
@@ -10,9 +10,8 @@ from types import TracebackType
10
10
  from typing import Any, Final, Protocol, Self, final, runtime_checkable
11
11
 
12
12
  from haiway.context.identifier import ScopeIdentifier
13
-
14
- # from haiway.context.logging import LoggerContext
15
13
  from haiway.state import State
14
+ from haiway.types import MISSING, Missing
16
15
 
17
16
  __all__ = (
18
17
  "DEBUG",
@@ -46,7 +45,16 @@ INFO: Final[int] = ObservabilityLevel.INFO
46
45
  DEBUG: Final[int] = ObservabilityLevel.DEBUG
47
46
 
48
47
  type ObservabilityAttribute = (
49
- Sequence[str] | Sequence[float] | Sequence[int] | Sequence[bool] | str | float | int | bool
48
+ Sequence[str]
49
+ | Sequence[float]
50
+ | Sequence[int]
51
+ | Sequence[bool]
52
+ | str
53
+ | float
54
+ | int
55
+ | bool
56
+ | None
57
+ | Missing
50
58
  )
51
59
 
52
60
 
@@ -256,7 +264,7 @@ def _logger_observability(
256
264
  logger.log(
257
265
  INFO,
258
266
  f"{scope.unique_name} Recorded attributes:"
259
- f"\n{'\n'.join([f'{k}: {v}' for k, v in attributes.items()])}",
267
+ f"\n{'\n'.join(f'{k}: {v}' for k, v in attributes.items() if v is not None and v is not MISSING)}", # noqa: E501
260
268
  )
261
269
 
262
270
  def scope_entering[Metric: State](
@@ -1,10 +1,11 @@
1
- from collections.abc import Sequence
2
1
  from logging import Logger
3
2
  from time import monotonic
4
3
  from typing import Any
5
4
 
6
5
  from haiway.context import Observability, ObservabilityLevel, ScopeIdentifier
6
+ from haiway.context.observability import ObservabilityAttribute
7
7
  from haiway.state import State
8
+ from haiway.types import MISSING
8
9
 
9
10
  __all__ = ("LoggerObservability",)
10
11
 
@@ -133,14 +134,14 @@ def LoggerObservability( # noqa: C901, PLR0915
133
134
  def attributes_recording(
134
135
  scope: ScopeIdentifier,
135
136
  /,
136
- **attributes: Sequence[str | float | int] | str | float | int,
137
+ **attributes: ObservabilityAttribute,
137
138
  ) -> None:
138
139
  if not attributes:
139
140
  return
140
141
 
141
142
  attributes_str: str = (
142
143
  f"{scope.unique_name} Attributes:"
143
- f"\n{'\n'.join([f'{k}: {v}' for k, v in attributes.items()])}"
144
+ f"\n{'\n'.join(f'{k}: {v}' for k, v in attributes.items() if v is not None and v is not MISSING)}" # noqa: E501
144
145
  )
145
146
  if summarize_context: # store only for summary
146
147
  scopes[scope.scope_id].store.append(attributes_str)
haiway/helpers/tracing.py CHANGED
@@ -96,11 +96,10 @@ def _traced_sync[**Args, Result](
96
96
  **kwargs: Args.kwargs,
97
97
  ) -> Result:
98
98
  with ctx.scope(label):
99
- for idx, arg in enumerate(args):
100
- ctx.attributes(**{f"[{idx}]": f"{arg}"})
101
-
102
- for key, arg in kwargs.items():
103
- ctx.attributes(**{key: f"{arg}"})
99
+ ctx.attributes(
100
+ **{f"[{idx}]": f"{arg}" for idx, arg in enumerate(args) if arg is not MISSING}
101
+ )
102
+ ctx.attributes(**{key: f"{arg}" for key, arg in kwargs.items() if arg is not MISSING})
104
103
 
105
104
  try:
106
105
  result: Result = function(*args, **kwargs)
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from collections.abc import Mapping
3
- from typing import Any, Self, final
3
+ from typing import Any, Self, cast, final
4
4
 
5
5
  from opentelemetry import metrics, trace
6
6
  from opentelemetry._logs import get_logger, set_logger_provider
@@ -31,10 +31,9 @@ from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExport
31
31
  from opentelemetry.trace import Span, StatusCode, Tracer
32
32
 
33
33
  from haiway.context import Observability, ObservabilityLevel, ScopeIdentifier
34
-
35
- ###
36
34
  from haiway.context.observability import ObservabilityAttribute
37
35
  from haiway.state import State
36
+ from haiway.types import MISSING
38
37
 
39
38
  __all__ = ("OpenTelemetry",)
40
39
 
@@ -168,10 +167,11 @@ class ScopeStore:
168
167
  *,
169
168
  value: ObservabilityAttribute,
170
169
  ) -> None:
171
- self.span.set_attribute(
172
- name,
173
- value=value,
174
- )
170
+ if value is not None and value is not MISSING:
171
+ self.span.set_attribute(
172
+ name,
173
+ value=cast(Any, value),
174
+ )
175
175
 
176
176
 
177
177
  @final
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiway
3
- Version: 0.18.1
3
+ Version: 0.18.2
4
4
  Summary: Framework for dependency injection and state management within structured concurrency model.
5
5
  Project-URL: Homepage, https://miquido.com
6
6
  Project-URL: Repository, https://github.com/miquido/haiway.git
@@ -4,20 +4,20 @@ haiway/context/__init__.py,sha256=eoxqxUmFtkWLhc_gH6tqax9m90tSDie-jiP1BHruTdk,11
4
4
  haiway/context/access.py,sha256=49yzFt9yJU6p0pDE3jV_ZIvmgSk6_czzOOT2gijSJk8,18648
5
5
  haiway/context/disposables.py,sha256=xE8RZYsYgXiOZY_TjWR7UiPG6dirna6y2LBZvMwTkIs,2588
6
6
  haiway/context/identifier.py,sha256=i6nO-tozps7iDnpS5Se7CRch7hh6z2akjZthutxHte8,3943
7
- haiway/context/observability.py,sha256=Z89y2MYTMBwfsEprm9fGP-s_ZqrA9NLtLZo4Fj2JDGM,13738
7
+ haiway/context/observability.py,sha256=jgmRP2iKu3AF2UbAh6o3w7wZK9Qrr8bsKlUF4eyOZh4,13831
8
8
  haiway/context/state.py,sha256=0oq7ctNO0urJd7rVzwwNtgpguoXuI6Tp1exfCsxrS2M,5981
9
9
  haiway/context/tasks.py,sha256=QOxFdjmMp4IYff0ihHElKLCQrcVksSJmxqTlOKfoH4o,2907
10
10
  haiway/context/types.py,sha256=WulPvpqUbI1vYyny-s2NItldDnk3zh1O-n_hGibFZRY,142
11
11
  haiway/helpers/__init__.py,sha256=awAEVFv9_talefS6ymMbofDXigB-Klsxkj2uth8la-g,615
12
12
  haiway/helpers/asynchrony.py,sha256=k_A0yCWUKSFfzYZ8WvqK4wqTMljv6ykMivmERrDLHIU,6266
13
13
  haiway/helpers/caching.py,sha256=4WX2Md5AOncduYB_RLLENI2s9C2zD5kNJgKZjMzPIGY,13257
14
- haiway/helpers/observability.py,sha256=-UXr7dHWTq-rmGe5HAR-tx2gzCbzAIoO42mwTISnMDE,6990
14
+ haiway/helpers/observability.py,sha256=Su9C4H_w8RuAXM0S24Yv6UDU5A6jnhZgwYhc9UNTL84,7075
15
15
  haiway/helpers/retries.py,sha256=unssUKBDOENvquh6R4Ud65TuSKl4mTHgZ5N_b7mAYa4,7533
16
16
  haiway/helpers/throttling.py,sha256=U6HJvSzffw47730VeiXxXSW4VVxpDx48k0oIAOpL-O4,4115
17
17
  haiway/helpers/timeouted.py,sha256=_M8diuD_GN49pl5KQA5fMKn4iUHsUuhkDSatAwWXiK8,3331
18
- haiway/helpers/tracing.py,sha256=0KIpr-phVHikfoFrbgzeQi581tjp65fZnMqX0h0MRDo,3653
18
+ haiway/helpers/tracing.py,sha256=v4vRpkXKV5AEdrnvQ3MGsaXHKKqXvwQ0V5xWXOg6RrU,3692
19
19
  haiway/opentelemetry/__init__.py,sha256=TV-1C14mDAtcHhFZ29ActFQdrGH6x5KuGV9w-JlKYJg,91
20
- haiway/opentelemetry/observability.py,sha256=oOjIVZldk14SfffWQh5FO1lGMW3Dce1PMLbiDZ9lV5s,14264
20
+ haiway/opentelemetry/observability.py,sha256=71jDpoxwye-_dEqSxRd_g6Z9_8fz0dYUOwdfOHla1uk,14380
21
21
  haiway/state/__init__.py,sha256=AaMqlMhO4zKS_XNevy3A7BHh5PxmguA-Sk_FnaNDY1Q,355
22
22
  haiway/state/attributes.py,sha256=p6jUBzg62bOl0zAYTCa7NIllsaNY2Kt68IooQ9tb-y8,23311
23
23
  haiway/state/path.py,sha256=-IpbUpF2QHWg3hEITkWYHJ6ZPoRVixu-SOSuWk-bbBY,21318
@@ -38,7 +38,7 @@ haiway/utils/mimic.py,sha256=L5AS4WEL2aPMZAQZlvLvRzHl0cipI7ivky60_eL4iwY,1822
38
38
  haiway/utils/noop.py,sha256=f54PSLHGEwCQNYXQHkPAW5NDE-tk5yjzkNL1pZj0TJQ,344
39
39
  haiway/utils/queue.py,sha256=YTvCn3wgSwLJiLqolMx44sa3304Xkv3tJG77gvfWnZs,4114
40
40
  haiway/utils/stream.py,sha256=Mjhy2S-ZDR1g_NsgS_nuBA8AgVbhrGXKvG3wjJ5mCJQ,2826
41
- haiway-0.18.1.dist-info/METADATA,sha256=dIvIkA3j0iGbQuF5VGH2vhdgPMTWYQS0LXG7GwDKw7E,4527
42
- haiway-0.18.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
- haiway-0.18.1.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
44
- haiway-0.18.1.dist-info/RECORD,,
41
+ haiway-0.18.2.dist-info/METADATA,sha256=Sf5zs_gFdyGBy5MtZQyM68b4zTnvuf9M2otV7_3ricM,4527
42
+ haiway-0.18.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
+ haiway-0.18.2.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
44
+ haiway-0.18.2.dist-info/RECORD,,