-
Notifications
You must be signed in to change notification settings - Fork 13
Add dartboard summarize subcommand #157
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,117 @@ | ||||||||||
| /* | ||||||||||
| Copyright © 2024 SUSE LLC | ||||||||||
|
|
||||||||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| you may not use this file except in compliance with the License. | ||||||||||
| You may obtain a copy of the License at | ||||||||||
|
|
||||||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
|
|
||||||||||
| Unless required by applicable law or agreed to in writing, software | ||||||||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| See the License for the specific language governing permissions and | ||||||||||
| limitations under the License. | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| package subcommands | ||||||||||
|
|
||||||||||
| import ( | ||||||||||
| "fmt" | ||||||||||
| "os" | ||||||||||
| "os/exec" | ||||||||||
| "path/filepath" | ||||||||||
| "time" | ||||||||||
|
|
||||||||||
| "github.com/urfave/cli/v2" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| func Summarize(cli *cli.Context) error { | ||||||||||
| tf, _, err := prepare(cli) | ||||||||||
| if err != nil { | ||||||||||
| return err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| clusters, err := tf.OutputClusters(cli.Context) | ||||||||||
| if err != nil { | ||||||||||
| return err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Refresh k6 files | ||||||||||
MSpencer87 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| upstream := clusters["upstream"] | ||||||||||
|
|
||||||||||
| //TODO: Logic to target defined cluster from darts/aws.yaml | ||||||||||
|
||||||||||
| //TODO: Logic to target defined cluster from darts/aws.yaml | |
| // Currently, summarization targets the "upstream" cluster returned by tf.OutputClusters. | |
| // To support targeting clusters defined in darts/aws.yaml, this is the place to extend | |
| // the selection logic to choose a different entry from the clusters map based on config. |
MSpencer87 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
Copilot
AI
Jan 26, 2026
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.
The defer statement to remove binaries is inside a loop, so all three deferred removals will capture the last value of 'bin' variable ("./summarize-tools/export-metrics/export-metrics"). This means only the last binary will be removed three times, leaving the first two binaries on disk. Move the defer outside the loop or use an immediately invoked function to capture the correct value.
MSpencer87 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [[ "${DEBUG:-}" == "1" ]] && set -x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Path to the Go source code for the collector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COLLECTOR_SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Output binary path (place binary next to this script) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OUTPUT_BINARY="${COLLECTOR_SRC_DIR}/collect-profile" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Building collect-profile..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Source directory: ${COLLECTOR_SRC_DIR}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Output binary: ${OUTPUT_BINARY}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ensure we are in the correct directory to resolve modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "${COLLECTOR_SRC_DIR}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Tidy and build the Go application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| go mod tidy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| go build -o "${OUTPUT_BINARY}" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+20
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ensure we are in the correct directory to resolve modules | |
| cd "${COLLECTOR_SRC_DIR}" | |
| # Tidy and build the Go application | |
| go mod tidy | |
| go build -o "${OUTPUT_BINARY}" . | |
| # Find the nearest Go module root (directory containing go.mod) | |
| REPO_ROOT="${COLLECTOR_SRC_DIR}" | |
| while [[ "${REPO_ROOT}" != "/" && ! -f "${REPO_ROOT}/go.mod" ]]; do | |
| REPO_ROOT="$(dirname "${REPO_ROOT}")" | |
| done | |
| if [[ ! -f "${REPO_ROOT}/go.mod" ]]; then | |
| echo "Error: could not find go.mod in any parent directory of ${COLLECTOR_SRC_DIR}" >&2 | |
| exit 1 | |
| fi | |
| # Compute the package directory relative to the module root | |
| if [[ "${COLLECTOR_SRC_DIR}" == "${REPO_ROOT}" ]]; then | |
| PACKAGE_DIR_REL="." | |
| else | |
| PACKAGE_DIR_REL="${COLLECTOR_SRC_DIR#${REPO_ROOT}/}" | |
| fi | |
| echo "Using Go module root: ${REPO_ROOT}" | |
| echo "Package directory (relative): ${PACKAGE_DIR_REL}" | |
| # Tidy and build the Go application from the module root | |
| cd "${REPO_ROOT}" | |
| go mod tidy | |
| go build -o "${OUTPUT_BINARY}" "./${PACKAGE_DIR_REL}" |
Uh oh!
There was an error while loading. Please reload this page.