WIP: add options to telemetry

This commit is contained in:
Matthew Hooker 2017-11-02 19:46:03 -07:00
parent e19381320c
commit 46f41d1f12
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
3 changed files with 13 additions and 5 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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) {