Skip to content

Commit

Permalink
hook up start and shutdown functions in fileexporter (#3260)
Browse files Browse the repository at this point in the history
* hook up start and shutdown functions in fileexporter

* fix tests

* Revert "fix tests"

This reverts commit f296b10.

* check file closed

* Revert changes in exporter.go

* Update factory.go

Co-authored-by: Bogdan Drutu <[email protected]>
  • Loading branch information
sincejune and Bogdan Drutu authored May 24, 2021
1 parent f0840a9 commit b424269
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions exporter/fileexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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.
Expand Down

0 comments on commit b424269

Please sign in to comment.