-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,129 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/stackrox/image-prefetcher/internal/logging" | ||
"github.com/stackrox/image-prefetcher/internal/metrics/server" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// aggregateMetricsCmd represents the aggregate-metrics command | ||
var aggregateMetricsCmd = &cobra.Command{ | ||
Use: "aggregate-metrics", | ||
Short: "Accept metrics submissions and serve them.", | ||
Long: `This subcommand is intended to run in a single pod. | ||
It serves a gRPC endpoint to which individual metrics can be submitted, | ||
and from which the aggregate metrics can be fetched.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return server.Run(logging.GetLogger(), port) | ||
}, | ||
} | ||
|
||
var port int | ||
|
||
func init() { | ||
rootCmd.AddCommand(aggregateMetricsCmd) | ||
logging.AddFlags(aggregateMetricsCmd.Flags()) | ||
aggregateMetricsCmd.Flags().IntVar(&port, "port", 8443, "Port for metrics gRPC endpoint to listen on.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package logging | ||
|
||
import ( | ||
"log/slog" | ||
"os" | ||
|
||
"github.com/spf13/pflag" | ||
) | ||
|
||
var debug bool | ||
|
||
func GetLogger() *slog.Logger { | ||
opts := &slog.HandlerOptions{AddSource: true} | ||
if debug { | ||
opts.Level = slog.LevelDebug | ||
} | ||
return slog.New(slog.NewTextHandler(os.Stderr, opts)) | ||
} | ||
|
||
func AddFlags(flags *pflag.FlagSet) { | ||
flags.BoolVar(&debug, "debug", false, "Whether to enable debug logging.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.gotools/ |
Oops, something went wrong.