Przeglądaj źródła

Add application name in diagnostics report file when exporting (#3333)

Ishaan Mittal 8 miesięcy temu
rodzic
commit
d626cd2e91

+ 3 - 0
core/pkg/diagnostics/diagnostics.go

@@ -37,6 +37,9 @@ type DiagnosticResult struct {
 
 // DiagnosticsRunReport is a struct that contains the start time of the diagnostics run, and all of the results.
 type DiagnosticsRunReport struct {
+	// Application contains the name of the application that the diagnostics run belongs to.
+	Application string `json:"application"`
+
 	// StartTime contains the time when the full diagnostics run started
 	StartTime time.Time `json:"startTime"`
 

+ 1 - 1
core/pkg/diagnostics/exporter/controller.go

@@ -14,7 +14,7 @@ func NewDiagnosticsExportController(
 	service diagnostics.DiagnosticService,
 ) *exporter.EventExportController[diagnostics.DiagnosticsRunReport] {
 	return exporter.NewEventExportController(
-		NewDiagnosticSource(service),
+		NewDiagnosticSource(applicationName, service),
 		NewDiagnosticExporter(clusterId, applicationName, store),
 	)
 }

+ 4 - 1
core/pkg/diagnostics/exporter/source.go

@@ -9,13 +9,15 @@ import (
 
 // DiagnosticSource is an `export.ExportSource` implementation that provides the basic data for a `DiagnosticResult` payload.
 type DiagnosticSource struct {
+	applicationName string
 	diagnosticService diagnostics.DiagnosticService
 }
 
 // NewDiagnosticSource creates a new `DiagnosticSource` instance. It accepts the `DiagnosticService` implementation
 // that will be used to retrieve the diagnostic results.
-func NewDiagnosticSource(diagnosticService diagnostics.DiagnosticService) *DiagnosticSource {
+func NewDiagnosticSource(applicationName string, diagnosticService diagnostics.DiagnosticService) *DiagnosticSource {
 	return &DiagnosticSource{
+		applicationName: applicationName,
 		diagnosticService: diagnosticService,
 	}
 }
@@ -31,6 +33,7 @@ func (ds *DiagnosticSource) Make(t time.Time) *diagnostics.DiagnosticsRunReport
 
 	return &diagnostics.DiagnosticsRunReport{
 		StartTime: t,
+		Application: ds.applicationName,
 		Results:   ds.diagnosticService.Run(ctx),
 	}
 }