Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion samcli/commands/sync/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from samcli.cli.cli_config_file import configuration_option, TomlProvider
from samcli.commands._utils.click_mutex import ClickMutex
from samcli.lib.telemetry.event import EventTracker
from samcli.lib.telemetry.event import EventTracker, track_long_event
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.version_checker import check_newer_version
from samcli.lib.bootstrap.bootstrap import manage_stack
Expand Down Expand Up @@ -144,6 +144,7 @@
@capabilities_option(default=DEFAULT_CAPABILITIES) # pylint: disable=E1120
@experimental
@pass_context
@track_long_event("SyncUsed", "Start", "SyncUsed", "End")
Comment thread
Leo10Gama marked this conversation as resolved.
@track_command
@image_repository_validation
@track_template_warnings([CodeDeployWarning.__name__, CodeDeployConditionWarning.__name__])
Expand Down
10 changes: 10 additions & 0 deletions samcli/lib/sync/sync_flow_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from concurrent.futures import ThreadPoolExecutor, Future

from botocore.exceptions import ClientError
from samcli.lib.telemetry.event import EventName, EventTracker, EventType

from samcli.lib.utils.colors import Colored
from samcli.lib.providers.exceptions import MissingLocalDefinition
Expand Down Expand Up @@ -331,12 +332,21 @@ def _sync_flow_execute_wrapper(sync_flow: SyncFlow) -> SyncFlowResult:
SyncFlowException
"""
dependent_sync_flows = []
sync_types = EventType.get_accepted_values(EventName.SYNC_FLOW_START)
sync_type: Optional[str] = type(sync_flow).__name__
if sync_type not in sync_types:
sync_type = None
try:
if sync_type:
EventTracker.track_event("SyncFlowStart", sync_type)
dependent_sync_flows = sync_flow.execute()
except ClientError as e:
if e.response.get("Error", dict()).get("Code", "") == "ResourceNotFoundException":
raise SyncFlowException(sync_flow, MissingPhysicalResourceError()) from e
raise SyncFlowException(sync_flow, e) from e
except Exception as e:
raise SyncFlowException(sync_flow, e) from e
finally:
if sync_type:
EventTracker.track_event("SyncFlowEnd", sync_type)
return SyncFlowResult(sync_flow=sync_flow, dependent_sync_flows=dependent_sync_flows)
23 changes: 23 additions & 0 deletions samcli/lib/telemetry/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,28 @@ class EventName(Enum):
USED_FEATURE = "UsedFeature"
DEPLOY = "Deploy"
BUILD_FUNCTION_RUNTIME = "BuildFunctionRuntime"
SYNC_USED = "SyncUsed"
SYNC_FLOW_START = "SyncFlowStart"
SYNC_FLOW_END = "SyncFlowEnd"


class EventType:
"""Class for Events and the types of values they may have."""

_SYNC_FLOWS = [
Comment thread
Leo10Gama marked this conversation as resolved.
"AliasVersionSyncFlow",
Comment thread
Leo10Gama marked this conversation as resolved.
"AutoDependencyLayerSyncFlow",
"AutoDependencyLayerParentSyncFlow",
"FunctionSyncFlow",
"FunctionLayerReferenceSync",
"GenericApiSyncFlow",
"HttpApiSyncFlow",
"ImageFunctionSyncFlow",
"LayerSyncFlow",
"RestApiSyncFlow",
"StepFunctionsSyncFlow",
"ZipFunctionSyncFlow",
]
_events = {
EventName.USED_FEATURE: [
"ESBuild",
Expand All @@ -39,6 +56,12 @@ class EventType:
"CreateChangeSetSuccess",
],
EventName.BUILD_FUNCTION_RUNTIME: INIT_RUNTIMES,
EventName.SYNC_USED: [
"Start",
"End",
],
EventName.SYNC_FLOW_START: _SYNC_FLOWS,
EventName.SYNC_FLOW_END: _SYNC_FLOWS,
}

@staticmethod
Expand Down