go.undefinedlabs.com/scopeagent@v0.4.2/agent/report.go (about)

     1  package agent
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  )
     7  
     8  func (a *Agent) PrintReport() {
     9  	a.printReportOnce.Do(func() {
    10  		if a.recorder != nil && a.testingMode && a.recorder.stats.totalTestSpans > 0 {
    11  			fmt.Printf("\n** Scope Test Report **\n")
    12  			if a.recorder.stats.testSpansNotSent == 0 && a.recorder.stats.testSpansRejected == 0 {
    13  				fmt.Println("Access the detailed test report for this build at:")
    14  				fmt.Printf("   %s\n\n", a.getUrl(fmt.Sprintf("external/v1/results/%s", a.agentId)))
    15  			} else {
    16  				if !a.debugMode {
    17  					a.logMetadata()
    18  				}
    19  				a.recorder.writeStats()
    20  				fmt.Println("There was a problem sending data to Scope.")
    21  				if a.recorder.stats.testSpansSent > 0 {
    22  					fmt.Println("Partial results for this build are available at:")
    23  					fmt.Printf("   %s\n\n", a.getUrl(fmt.Sprintf("external/v1/results/%s", a.agentId)))
    24  				}
    25  				fmt.Printf("Check the agent logs at %s for more information.\n\n", a.recorderFilename)
    26  			}
    27  		}
    28  	})
    29  }
    30  
    31  func (a *Agent) logMetadata() {
    32  	metaBytes, _ := json.Marshal(a.metadata)
    33  	strMetadata := string(metaBytes)
    34  	a.logger.Println("Agent Metadata:", strMetadata)
    35  }