Skip to content

Commit c99dd6e

Browse files
eliothedemanfacebook-github-bot
authored andcommitted
psudo paft
Differential Revision: D76075484
1 parent 4f0b525 commit c99dd6e

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

python/monarch/bootstrap_main.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,9 @@ def invoke_main():
3030
# behavior of std out as if it were a terminal.
3131
sys.stdout.reconfigure(line_buffering=True)
3232
global bootstrap_main
33-
from monarch._rust_bindings.hyperactor_extension.telemetry import ( # @manual=//monarch/monarch_extension:monarch_extension # @manual=//monarch/monarch_extension:monarch_extension
34-
forward_to_tracing,
35-
)
3633

3734
# TODO: figure out what from worker_main.py we should reproduce here.
38-
39-
class TracingForwarder(logging.Handler):
40-
def emit(self, record: logging.LogRecord) -> None:
41-
try:
42-
forward_to_tracing(
43-
record.getMessage(),
44-
record.filename or "",
45-
record.lineno or 0,
46-
record.levelno,
47-
)
48-
except AttributeError:
49-
forward_to_tracing(
50-
record.__str__(),
51-
record.filename or "",
52-
record.lineno or 0,
53-
record.levelno,
54-
)
35+
from monarch.telemetry import TracingForwarder
5536

5637
if os.environ.get("MONARCH_ERROR_DURING_BOOTSTRAP_FOR_TESTING") == "1":
5738
raise RuntimeError("Error during bootstrap for testing")

python/monarch/telemetry.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# pyre-strict
8+
9+
10+
import logging
11+
12+
from monarch._rust_bindings.hyperactor_extension.telemetry import ( # @manual=//monarch/monarch_extension:monarch_extension
13+
forward_to_tracing,
14+
)
15+
16+
17+
class TracingForwarder(logging.Handler):
18+
def emit(self, record: logging.LogRecord) -> None:
19+
try:
20+
forward_to_tracing(
21+
record.getMessage(),
22+
record.filename or "",
23+
record.lineno or 0,
24+
record.levelno,
25+
)
26+
except AttributeError:
27+
forward_to_tracing(
28+
record.__str__(),
29+
record.filename or "",
30+
record.lineno or 0,
31+
record.levelno,
32+
)

0 commit comments

Comments
 (0)