From 46f41d1f1210ad40b88a43325b02caa6130f5e8e Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 2 Nov 2017 19:46:03 -0700 Subject: [PATCH] WIP: add options to telemetry --- packer/build.go | 4 ++-- packer/provisioner.go | 2 +- packer/telemetry.go | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packer/build.go b/packer/build.go index 996c9a331..9e406ac63 100644 --- a/packer/build.go +++ b/packer/build.go @@ -221,7 +221,7 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) { } 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) ts.End(err) if err != nil { @@ -248,7 +248,7 @@ PostProcessorRunSeqLoop: } 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) ts.End(err) if err != nil { diff --git a/packer/provisioner.go b/packer/provisioner.go index 639e8b1a8..a9782bb92 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -63,7 +63,7 @@ func (h *ProvisionHook) Run(name string, ui Ui, comm Communicator, data interfac h.runningProvisioner = p h.lock.Unlock() - ts := CheckpointReporter.AddSpan(h.ProvisionerTypes[i], "provisioner") + ts := CheckpointReporter.AddSpan(h.ProvisionerTypes[i], "provisioner", p) err := p.Provision(ui, comm) ts.End(err) if err != nil { diff --git a/packer/telemetry.go b/packer/telemetry.go index 7224de582..60005e606 100644 --- a/packer/telemetry.go +++ b/packer/telemetry.go @@ -11,7 +11,7 @@ import ( 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" var CheckpointReporter *CheckpointTelemetry @@ -85,11 +85,18 @@ func (c *CheckpointTelemetry) ReportPanic(m string) error { 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 { return nil } 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{ Name: name, Type: pluginType, @@ -130,6 +137,7 @@ type TelemetrySpan struct { StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` Error string `json:"error"` + Options []string `json:"options"` } func (s *TelemetrySpan) End(err error) {