haiway 0.8.1__py3-none-any.whl → 0.8.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.
haiway/context/access.py CHANGED
@@ -46,11 +46,6 @@ class ScopeContext:
46
46
  self._state: tuple[State, ...] = state
47
47
  self._disposables: Disposables | None = disposables
48
48
  # pre-building metrics context to ensure nested context registering
49
- if __debug__:
50
- if self._identifier.is_root and metrics is None:
51
- from haiway.helpers import MetricsLogger
52
-
53
- metrics = MetricsLogger.handler()
54
49
  self._metrics_context: MetricsContext = MetricsContext.scope(
55
50
  self._identifier,
56
51
  metrics=metrics,
haiway/helpers/metrics.py CHANGED
@@ -1,19 +1,16 @@
1
1
  from collections.abc import Sequence
2
2
  from itertools import chain
3
3
  from time import monotonic
4
- from typing import Any, Final, Self, cast, final
4
+ from typing import Any, Self, cast, final
5
5
 
6
6
  from haiway.context import MetricsHandler, ScopeIdentifier, ctx
7
7
  from haiway.state import State
8
8
  from haiway.types import MISSING, Missing
9
- from haiway.utils import getenv_bool
10
9
 
11
10
  __all_ = [
12
11
  "MetricsLogger",
13
12
  ]
14
13
 
15
- DEBUG_LOGGING: Final[bool] = getenv_bool("DEBUG_LOGGING", __debug__)
16
-
17
14
 
18
15
  class MetricsScopeStore:
19
16
  def __init__(
@@ -96,13 +93,12 @@ class MetricsLogger:
96
93
  metrics[type(metric)] = current.__add__(metric) # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue]
97
94
 
98
95
  metrics[type(metric)] = metric
99
- if DEBUG_LOGGING:
100
- if log := _state_log(
101
- metric,
102
- list_items_limit=self.items_limit,
103
- redact_content=self.redact_content,
104
- ):
105
- ctx.log_info(f"Recorded metric:\n⎡ {type(metric).__qualname__}:{log}\n⌊")
96
+ if log := _state_log(
97
+ metric,
98
+ list_items_limit=self.items_limit,
99
+ redact_content=self.redact_content,
100
+ ):
101
+ ctx.log_debug(f"Recorded metric:\n⎡ {type(metric).__qualname__}:{log}\n⌊")
106
102
 
107
103
  def enter_scope[Metric: State](
108
104
  self,
@@ -118,7 +114,7 @@ class MetricsLogger:
118
114
  self.scopes[key].nested.append(scope_metrics)
119
115
  return
120
116
 
121
- ctx.log_error(
117
+ ctx.log_debug(
122
118
  "Attempting to enter nested scope metrics without entering its parent first"
123
119
  )
124
120
 
@@ -130,14 +126,13 @@ class MetricsLogger:
130
126
  assert scope in self.scopes # nosec: B101
131
127
  self.scopes[scope].exited = monotonic()
132
128
 
133
- if DEBUG_LOGGING:
134
- if scope.is_root and self.scopes[scope].finished:
135
- if log := _tree_log(
136
- self.scopes[scope],
137
- list_items_limit=self.items_limit,
138
- redact_content=self.redact_content,
139
- ):
140
- ctx.log_info(f"Metrics summary:\n{log}")
129
+ if scope.is_root and self.scopes[scope].finished:
130
+ if log := _tree_log(
131
+ self.scopes[scope],
132
+ list_items_limit=self.items_limit,
133
+ redact_content=self.redact_content,
134
+ ):
135
+ ctx.log_debug(f"Metrics summary:\n{log}")
141
136
 
142
137
 
143
138
  def _tree_log(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: haiway
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: Framework for dependency injection and state management within structured concurrency model.
5
5
  Maintainer-email: Kacper Kaliński <kacper.kalinski@miquido.com>
6
6
  License: MIT License
@@ -1,7 +1,7 @@
1
1
  haiway/__init__.py,sha256=W11mHfW3WnYhVAuNOHeEHVc-BQkOodHM9j4_o36j4dA,1669
2
2
  haiway/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  haiway/context/__init__.py,sha256=FDPD92cVaZKbQoyXl8lO1GzrscfTSrvST_gtfxOxxcM,620
4
- haiway/context/access.py,sha256=sQSokJ2dHm4phbhP5VylqwaEYVgGFtKbtaKjyCCD9eU,15844
4
+ haiway/context/access.py,sha256=7UfhtDCjkVtdLfdWc5nR58KwKI3r693LcjFAlRtYHa0,15653
5
5
  haiway/context/disposables.py,sha256=DZjnMp-wMfF-em2Wjhbm1MvXubNpuzFBT70BQNIxC7M,2019
6
6
  haiway/context/identifier.py,sha256=f5-vZOnhKZmYj__emS51WcgsJqfD_yz6ilr3GUo9z1k,2034
7
7
  haiway/context/logging.py,sha256=ptwgENuyw-WFgokVsYx9OXZGhJENuO_wgfVjcBryUKM,4251
@@ -12,7 +12,7 @@ haiway/context/types.py,sha256=VvJA7wAPZ3ISpgyThVguioYUXqhHf0XkPfRd0M1ERiQ,142
12
12
  haiway/helpers/__init__.py,sha256=a2x-geUNGKe8HqqmCCZO-6GNUic-bARSnKeUNJeWQpY,543
13
13
  haiway/helpers/asynchrony.py,sha256=rh_Hwo0MQHfKnw5dLUCFTAm3Fk3SVS8Or8cTcQFdPA8,6042
14
14
  haiway/helpers/caching.py,sha256=Ok_WE5Whe7XqnIuLZo4rNNBFeWap-aUWX799s4b1JAQ,9536
15
- haiway/helpers/metrics.py,sha256=GQn8RjLbkB4TAJWeLqqKmRL3Rbr2l6BLfC5qKC3Y1w0,8977
15
+ haiway/helpers/metrics.py,sha256=Xre7t5ZfR3RnvpX6-9o8t1nWwtrmGJOuUeZ0dy8E0rc,8761
16
16
  haiway/helpers/retries.py,sha256=gIkyUlqJLDYaxIZd3qzeqGFY9y5Gp8dgZLlZ6hs8hoc,7538
17
17
  haiway/helpers/throttling.py,sha256=zo0OwFq64si5KUwhd58cFHLmGAmYwRbFRJMbv9suhPs,3844
18
18
  haiway/helpers/timeouted.py,sha256=1xU09hQnFdj6p48BwZl5xUvtIr3zC0ZUXehkdrduCjs,3074
@@ -34,8 +34,8 @@ haiway/utils/logs.py,sha256=oDsc1ZdqKDjlTlctLbDcp9iX98Acr-1tdw-Pyg3DElo,1577
34
34
  haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
35
35
  haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
36
36
  haiway/utils/queue.py,sha256=oQ3GXCJ-PGNtMEr6EPdgqAvYZoj8lAa7Z2drBKBEoBM,2345
37
- haiway-0.8.1.dist-info/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
38
- haiway-0.8.1.dist-info/METADATA,sha256=u8n59l4iBGB7o-mS_h7F3m_oEVgEz1jJ4RXbQOim6es,3898
39
- haiway-0.8.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
40
- haiway-0.8.1.dist-info/top_level.txt,sha256=_LdXVLzUzgkvAGQnQJj5kQfoFhpPW6EF4Kj9NapniLg,7
41
- haiway-0.8.1.dist-info/RECORD,,
37
+ haiway-0.8.2.dist-info/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
38
+ haiway-0.8.2.dist-info/METADATA,sha256=2yT8bWdZuQZa_3HecsgNxVFsESFWNDvnBxw79KSO6LY,3898
39
+ haiway-0.8.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
40
+ haiway-0.8.2.dist-info/top_level.txt,sha256=_LdXVLzUzgkvAGQnQJj5kQfoFhpPW6EF4Kj9NapniLg,7
41
+ haiway-0.8.2.dist-info/RECORD,,
File without changes