-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1843926: SPCS service events & metrics #1954
base: main
Are you sure you want to change the base?
SNOW-1843926: SPCS service events & metrics #1954
Conversation
0700514
to
70cc699
Compare
great job with design doc and description on the pr! |
@app.command(requires_connection=True) | ||
def events( | ||
name: FQN = ServiceNameArgument, | ||
container_name: str = typer.Option( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a few of these flags are defined in exactly the same way - could you define them once outside the function and refer them here? You can check _plugins.git.commands
for an example
elif isinstance(until, str) and until: | ||
until_clause = f"and timestamp <= sysdate() - interval '{until}'" | ||
|
||
return since_clause, until_clause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since_clause
and until_clause
are always used together - how about returning them as a single string (" AND ".join([since_clause, until_clause])
)
"snowflake.cli.api.feature_flags.FeatureFlag.ENABLE_SPCS_SERVICE_METRICS.is_disabled" | ||
) | ||
@patch("snowflake.cli._plugins.spcs.services.manager.ServiceManager.execute_query") | ||
def test_latest_metrics(mock_execute_query, mock_is_disabled, runner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check what rows were printed as well (to check whether formatting / show all columns flag works as expected). snapshot
fixture and pytest.mark.parametrize
might be useful - you can check out test_help_messages
for usage example :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
72e4916
to
d8e47b7
Compare
14a6bf9
to
5411ad2
Compare
5411ad2
to
5f38795
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments were marked as resolved without a change - did you forget to push?
(if not - please leave a comment why)
Pre-review checklist
Changes description
Design Document
1. Events Command:
snow spcs service events
2. Metrics Command:
snow spcs service metrics
Change Motivation
Alternate Approach: Standalone Command (
snow spcs events
)Unified Command Consideration: Instead of separate commands for metrics and events, a unified
snow spcs events
command was considered. This would handle both service and compute pool telemetry.Given these drawbacks, the current design with distinct commands was chosen for clarity and future extensibility.
Design Logic
Required Parameters
For both events and metrics, the following parameters are mandatory to ensure precise identification of the service and its resources:
name
: Service identifier (Service name).--container-name
: Name of the container.--instance-id
: Instance ID of the service (starting with 0).Filtering Options
Time-Based Filters:
--since
: Fetch telemetry data newer than the specified time (e.g.,1h
,5d
).--until
: Fetch telemetry data older than the specified time.Pagination (for Events Only):
--first <N>
: Fetch only the first N events.--last <N>
: Fetch only the last N events.--first
and--last
are mutually exclusive.All Columns Display:
--all
: Fetch all columns from the event or metrics table.Behavior for Metrics
No Filters Provided (
--since
,--until
not used):With Any Filters (
--since
,--until
):Data Formats
Events (Formatted Data)
Metrics (Formatted Data)
Raw Data (
--all
Flag)Use Cases
snow spcs service events
Narrow the time range using interval syntax:
snow spcs service events LOG_EVENT --container-name log-printer --instance-id 0 --since '5 minutes'
Output :
snow spcs service events LOG_EVENT --container-name log-printer --instance-id 0 --until '1 hour'
Retrieve all events with all columns displayed:
Output: Raw table including all available columns.
Retrieve events formatted for JSON output:
Output (JSON):
snow spcs service metrics
Retrieve a subset of metrics with pagination:
Fetch the first 5 metrics:
Or fetch the last 5 metrics:
Output: Formatted table showing the first or last 5 metrics.
Retrieve metrics within a time range:
Fetch metrics newer than 1 hour:
snow spcs service metrics LOG_EVENT --container-name log-printer --instance-id 0 --since '1 hour'
Fetch metrics older than 2 hours:
snow spcs service metrics LOG_EVENT --container-name log-printer --instance-id 0 --until '2 hours'
Output: Metrics within the specified time range.
Retrieve metrics with all columns:
Output: Raw table showing the last metric with all columns.
Retrieve metrics formatted for JSON output:
Output (JSON):