exporter.go 830 B

123456789101112131415161718192021222324
  1. package exporter
  2. import (
  3. "github.com/opencost/opencost/core/pkg/exporter"
  4. "github.com/opencost/opencost/core/pkg/exporter/pathing"
  5. "github.com/opencost/opencost/core/pkg/heartbeat"
  6. "github.com/opencost/opencost/core/pkg/log"
  7. "github.com/opencost/opencost/core/pkg/storage"
  8. )
  9. // NewHeartbeatExporter creates a new `StorageExporter[Heartbeat]` instance for exporting Heartbeat events.
  10. func NewHeartbeatExporter(applicationName string, clusterId string, storage storage.Storage) exporter.EventExporter[heartbeat.Heartbeat] {
  11. pathing, err := pathing.NewEventStoragePathFormatter(applicationName, clusterId, heartbeat.HeartbeatEventName)
  12. if err != nil {
  13. log.Errorf("failed to create pathing formatter: %v", err)
  14. return nil
  15. }
  16. return exporter.NewEventStorageExporter(
  17. pathing,
  18. NewHeartbeatEncoder(),
  19. storage,
  20. )
  21. }