Merge pull request #3633 from jsternberg/debugger-build-metrics
commands: adds metrics associated with the debugger
This commit is contained in:
+15
-4
@@ -239,10 +239,12 @@ const (
|
||||
commandOptionsHash = attribute.Key("command.options.hash")
|
||||
driverNameAttribute = attribute.Key("driver.name")
|
||||
driverTypeAttribute = attribute.Key("driver.type")
|
||||
debuggerName = attribute.Key("debugger.name")
|
||||
debuggerUserAgent = attribute.Key("debugger.user.agent")
|
||||
)
|
||||
|
||||
func buildMetricAttributes(dockerCli command.Cli, driverType string, options *buildOptions) attribute.Set {
|
||||
return attribute.NewSet(
|
||||
func buildMetricAttributes(dockerCli command.Cli, driverType string, options *buildOptions, debugger debuggerOptions) attribute.Set {
|
||||
kvs := []attribute.KeyValue{
|
||||
commandNameAttribute.String("build"),
|
||||
attribute.Stringer(string(commandOptionsHash), &buildOptionsHash{
|
||||
buildOptions: options,
|
||||
@@ -250,7 +252,16 @@ func buildMetricAttributes(dockerCli command.Cli, driverType string, options *bu
|
||||
}),
|
||||
driverNameAttribute.String(options.builder),
|
||||
driverTypeAttribute.String(driverType),
|
||||
)
|
||||
}
|
||||
|
||||
if debugger != nil {
|
||||
d := debugger.Info()
|
||||
kvs = append(kvs,
|
||||
debuggerName.String(d.Name),
|
||||
debuggerUserAgent.String(d.UserAgent),
|
||||
)
|
||||
}
|
||||
return attribute.NewSet(kvs...)
|
||||
}
|
||||
|
||||
// buildOptionsHash computes a hash for the buildOptions when the String method is invoked.
|
||||
@@ -331,7 +342,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, debugOpts debuggerOpti
|
||||
}
|
||||
driverType := b.Driver
|
||||
|
||||
attributes := buildMetricAttributes(dockerCli, driverType, &options)
|
||||
attributes := buildMetricAttributes(dockerCli, driverType, &options, debugOpts)
|
||||
|
||||
ctx2, cancel := context.WithCancelCause(context.TODO())
|
||||
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||
|
||||
@@ -18,6 +18,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
dapEnvUserAgent = "BUILDX_DAP_USER_AGENT"
|
||||
)
|
||||
|
||||
func dapCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
||||
var options dapOptions
|
||||
cmd := &cobra.Command{
|
||||
@@ -51,6 +55,13 @@ func (d *dapOptions) New(in ioset.In) (debuggerInstance, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *dapOptions) Info() debuggerInfo {
|
||||
return debuggerInfo{
|
||||
Name: "dap",
|
||||
UserAgent: os.Getenv(dapEnvUserAgent),
|
||||
}
|
||||
}
|
||||
|
||||
type LaunchConfig struct {
|
||||
Dockerfile string `json:"dockerfile,omitempty"`
|
||||
ContextPath string `json:"contextPath,omitempty"`
|
||||
|
||||
@@ -26,9 +26,15 @@ type debugOptions struct {
|
||||
OnFlag string
|
||||
}
|
||||
|
||||
type debuggerInfo struct {
|
||||
Name string
|
||||
UserAgent string
|
||||
}
|
||||
|
||||
// debuggerOptions will start a debuggerOptions instance.
|
||||
type debuggerOptions interface {
|
||||
New(in ioset.In) (debuggerInstance, error)
|
||||
Info() debuggerInfo
|
||||
}
|
||||
|
||||
// debuggerInstance is an instance of a Debugger that has been started.
|
||||
@@ -71,6 +77,12 @@ func (d *debugOptions) New(in ioset.In) (debuggerInstance, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *debugOptions) Info() debuggerInfo {
|
||||
return debuggerInfo{
|
||||
Name: "debug",
|
||||
}
|
||||
}
|
||||
|
||||
type monitorDebuggerInstance struct {
|
||||
cfg *build.InvokeConfig
|
||||
in io.ReadCloser
|
||||
|
||||
Reference in New Issue
Block a user