Skip to content

Commit 9f89a97

Browse files
committed
Stop printing stack traces in debug messages in the channel registry
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent e98da18 commit 9f89a97

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/frequenz/sdk/_internal/_channels.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import abc
77
import dataclasses
88
import logging
9-
import traceback
109
import typing
1110

1211
from frequenz.channels import Broadcast, Receiver
@@ -140,13 +139,9 @@ def get_or_create(self, message_type: type[T], key: str) -> Broadcast[T]:
140139
ValueError: If the channel exists and the message type does not match.
141140
"""
142141
if key not in self._channels:
143-
if _logger.isEnabledFor(logging.DEBUG):
144-
_logger.debug(
145-
"Creating a new channel for key %r with type %s at:\n%s",
146-
key,
147-
message_type,
148-
"".join(traceback.format_stack(limit=10)[:9]),
149-
)
142+
_logger.debug(
143+
"Creating a new channel for key %r with type %s.", key, message_type
144+
)
150145
self._channels[key] = _Entry(
151146
message_type, Broadcast(name=f"{self._name}-{key}")
152147
)
@@ -158,14 +153,7 @@ def get_or_create(self, message_type: type[T], key: str) -> Broadcast[T]:
158153
f"message type {message_type} is not the same as the existing "
159154
f"message type {entry.message_type}."
160155
)
161-
if _logger.isEnabledFor(logging.DEBUG):
162-
_logger.debug(
163-
"%s at:\n%s",
164-
error_message,
165-
# We skip the last frame because it's this method, and limit the
166-
# stack to 9 frames to avoid adding too much noise.
167-
"".join(traceback.format_stack(limit=10)[:9]),
168-
)
156+
_logger.debug("%s", error_message)
169157
raise ValueError(error_message)
170158

171159
return typing.cast(Broadcast[T], entry.channel)

0 commit comments

Comments
 (0)