Skip to content

Commit

Permalink
improve tracing reporting and coverage (#4331)
Browse files Browse the repository at this point in the history
* [tracing] report stack backtrace as part of the tracing timeline

* [tracing] add tracing to more expensive functions
  • Loading branch information
cg505 authored Nov 12, 2024
1 parent 140125e commit b92b47f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,7 @@ def check_network_connection():
'Network seems down.') from e


@timeline.event
def check_owner_identity(cluster_name: str) -> None:
"""Check if current user is the same as the user who created the cluster.
Expand Down
2 changes: 2 additions & 0 deletions sky/clouds/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from sky.clouds import service_catalog
from sky.utils import log_utils
from sky.utils import resources_utils
from sky.utils import timeline
from sky.utils import ux_utils

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -366,6 +367,7 @@ def is_label_valid(cls, label_key: str,
del label_key, label_value
return True, None

@timeline.event
def get_feasible_launchable_resources(
self,
resources: 'resources_lib.Resources',
Expand Down
2 changes: 2 additions & 0 deletions sky/jobs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
from sky.utils import dag_utils
from sky.utils import rich_utils
from sky.utils import subprocess_utils
from sky.utils import timeline
from sky.utils import ux_utils


@timeline.event
@usage_lib.entrypoint
def launch(
task: Union['sky.Task', 'sky.Dag'],
Expand Down
2 changes: 2 additions & 0 deletions sky/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from sky.utils import resources_utils
from sky.utils import rich_utils
from sky.utils import subprocess_utils
from sky.utils import timeline
from sky.utils import ux_utils

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -105,6 +106,7 @@ def _egress_time(src_cloud: clouds.Cloud, dst_cloud: clouds.Cloud,
return egress_time

@staticmethod
@timeline.event
def optimize(dag: 'dag_lib.Dag',
minimize: OptimizeTarget = OptimizeTarget.COST,
blocked_resources: Optional[Iterable[
Expand Down
2 changes: 2 additions & 0 deletions sky/provision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from sky.provision import runpod
from sky.provision import vsphere
from sky.utils import command_runner
from sky.utils import timeline

logger = sky_logging.init_logger(__name__)

Expand Down Expand Up @@ -59,6 +60,7 @@ def _wrapper(*args, **kwargs):
# pylint: disable=unused-argument


@timeline.event
@_route_to_cloud_impl
def query_instances(
provider_name: str,
Expand Down
4 changes: 3 additions & 1 deletion sky/utils/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import threading
import time
import traceback
from typing import Callable, Optional, Union

import filelock
Expand Down Expand Up @@ -48,8 +49,9 @@ def begin(self):
'ph': 'B',
'ts': f'{time.time() * 10 ** 6: .3f}',
})
event_begin['args'] = {'stack': '\n'.join(traceback.format_stack())}
if self._message is not None:
event_begin['args'] = {'message': self._message}
event_begin['args']['message'] = self._message
_events.append(event_begin)

def end(self):
Expand Down

0 comments on commit b92b47f

Please sign in to comment.