WIP: add options to telemetry
This commit is contained in:
parent
e19381320c
commit
46f41d1f12
|
@ -221,7 +221,7 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Running builder: %s", b.builderType)
|
log.Printf("Running builder: %s", b.builderType)
|
||||||
ts := CheckpointReporter.AddSpan(b.builderType, "builder")
|
ts := CheckpointReporter.AddSpan(b.builderType, "builder", b.builderConfig)
|
||||||
builderArtifact, err := b.builder.Run(builderUi, hook, cache)
|
builderArtifact, err := b.builder.Run(builderUi, hook, cache)
|
||||||
ts.End(err)
|
ts.End(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -248,7 +248,7 @@ PostProcessorRunSeqLoop:
|
||||||
}
|
}
|
||||||
|
|
||||||
builderUi.Say(fmt.Sprintf("Running post-processor: %s", corePP.processorType))
|
builderUi.Say(fmt.Sprintf("Running post-processor: %s", corePP.processorType))
|
||||||
ts := CheckpointReporter.AddSpan(corePP.processorType, "post-processor")
|
ts := CheckpointReporter.AddSpan(corePP.processorType, "post-processor", corePP.config)
|
||||||
artifact, keep, err := corePP.processor.PostProcess(ppUi, priorArtifact)
|
artifact, keep, err := corePP.processor.PostProcess(ppUi, priorArtifact)
|
||||||
ts.End(err)
|
ts.End(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (h *ProvisionHook) Run(name string, ui Ui, comm Communicator, data interfac
|
||||||
h.runningProvisioner = p
|
h.runningProvisioner = p
|
||||||
h.lock.Unlock()
|
h.lock.Unlock()
|
||||||
|
|
||||||
ts := CheckpointReporter.AddSpan(h.ProvisionerTypes[i], "provisioner")
|
ts := CheckpointReporter.AddSpan(h.ProvisionerTypes[i], "provisioner", p)
|
||||||
err := p.Provision(ui, comm)
|
err := p.Provision(ui, comm)
|
||||||
ts.End(err)
|
ts.End(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
packerVersion "github.com/hashicorp/packer/version"
|
packerVersion "github.com/hashicorp/packer/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TelemetryVersion string = "beta/packer/4"
|
const TelemetryVersion string = "beta/packer/5"
|
||||||
const TelemetryPanicVersion string = "beta/packer_panic/4"
|
const TelemetryPanicVersion string = "beta/packer_panic/4"
|
||||||
|
|
||||||
var CheckpointReporter *CheckpointTelemetry
|
var CheckpointReporter *CheckpointTelemetry
|
||||||
|
@ -85,11 +85,18 @@ func (c *CheckpointTelemetry) ReportPanic(m string) error {
|
||||||
return checkpoint.Report(ctx, panicParams)
|
return checkpoint.Report(ctx, panicParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CheckpointTelemetry) AddSpan(name, pluginType string) *TelemetrySpan {
|
func (c *CheckpointTelemetry) AddSpan(name, pluginType string, options interface{}) *TelemetrySpan {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Printf("[INFO] (telemetry) Starting %s %s", pluginType, name)
|
log.Printf("[INFO] (telemetry) Starting %s %s", pluginType, name)
|
||||||
|
|
||||||
|
//strOpts := []string{}
|
||||||
|
if m, ok := options.(map[string]interface{}); ok {
|
||||||
|
for k, _ := range m {
|
||||||
|
log.Println("AddSpan options:", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
ts := &TelemetrySpan{
|
ts := &TelemetrySpan{
|
||||||
Name: name,
|
Name: name,
|
||||||
Type: pluginType,
|
Type: pluginType,
|
||||||
|
@ -130,6 +137,7 @@ type TelemetrySpan struct {
|
||||||
StartTime time.Time `json:"start_time"`
|
StartTime time.Time `json:"start_time"`
|
||||||
EndTime time.Time `json:"end_time"`
|
EndTime time.Time `json:"end_time"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
|
Options []string `json:"options"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TelemetrySpan) End(err error) {
|
func (s *TelemetrySpan) End(err error) {
|
||||||
|
|
Loading…
Reference in New Issue