From b424269dc438f7dc4db5e53186dcf8f651fd989b Mon Sep 17 00:00:00 2001 From: Chao <19381524+sincejune@users.noreply.github.com> Date: Tue, 25 May 2021 07:01:36 +0800 Subject: [PATCH] hook up start and shutdown functions in fileexporter (#3260) * hook up start and shutdown functions in fileexporter * fix tests * Revert "fix tests" This reverts commit f296b1035c298e854941b982f49e831d9ee53101. * check file closed * Revert changes in exporter.go * Update factory.go Co-authored-by: Bogdan Drutu --- exporter/fileexporter/factory.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/exporter/fileexporter/factory.go b/exporter/fileexporter/factory.go index 3ff16a986ab..0dcbb87d5d0 100644 --- a/exporter/fileexporter/factory.go +++ b/exporter/fileexporter/factory.go @@ -52,7 +52,13 @@ func createTracesExporter( fe := exporters.GetOrAdd(cfg, func() component.Component { return &fileExporter{path: cfg.(*Config).Path} }) - return exporterhelper.NewTracesExporter(cfg, params.Logger, fe.Unwrap().(*fileExporter).ConsumeTraces) + return exporterhelper.NewTracesExporter( + cfg, + params.Logger, + fe.Unwrap().(*fileExporter).ConsumeTraces, + exporterhelper.WithStart(fe.Start), + exporterhelper.WithShutdown(fe.Shutdown), + ) } func createMetricsExporter( @@ -63,7 +69,13 @@ func createMetricsExporter( fe := exporters.GetOrAdd(cfg, func() component.Component { return &fileExporter{path: cfg.(*Config).Path} }) - return exporterhelper.NewMetricsExporter(cfg, params.Logger, fe.Unwrap().(*fileExporter).ConsumeMetrics) + return exporterhelper.NewMetricsExporter( + cfg, + params.Logger, + fe.Unwrap().(*fileExporter).ConsumeMetrics, + exporterhelper.WithStart(fe.Start), + exporterhelper.WithShutdown(fe.Shutdown), + ) } func createLogsExporter( @@ -74,7 +86,13 @@ func createLogsExporter( fe := exporters.GetOrAdd(cfg, func() component.Component { return &fileExporter{path: cfg.(*Config).Path} }) - return exporterhelper.NewLogsExporter(cfg, params.Logger, fe.Unwrap().(*fileExporter).ConsumeLogs) + return exporterhelper.NewLogsExporter( + cfg, + params.Logger, + fe.Unwrap().(*fileExporter).ConsumeLogs, + exporterhelper.WithStart(fe.Start), + exporterhelper.WithShutdown(fe.Shutdown), + ) } // This is the map of already created File exporters for particular configurations.