factory.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. //go:generate mdatagen metadata.yaml
  4. package logicmonitorexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/logicmonitorexporter"
  5. import (
  6. "context"
  7. "go.opentelemetry.io/collector/component"
  8. "go.opentelemetry.io/collector/consumer"
  9. "go.opentelemetry.io/collector/exporter"
  10. "go.opentelemetry.io/collector/exporter/exporterhelper"
  11. "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/logicmonitorexporter/internal/metadata"
  12. )
  13. // NewFactory creates a LogicMonitor exporter factory
  14. func NewFactory() exporter.Factory {
  15. return exporter.NewFactory(
  16. metadata.Type,
  17. createDefaultConfig,
  18. exporter.WithLogs(createLogsExporter, metadata.LogsStability),
  19. exporter.WithTraces(createTracesExporter, metadata.TracesStability),
  20. )
  21. }
  22. func createDefaultConfig() component.Config {
  23. return &Config{
  24. RetrySettings: exporterhelper.NewDefaultRetrySettings(),
  25. QueueSettings: exporterhelper.NewDefaultQueueSettings(),
  26. }
  27. }
  28. func createLogsExporter(ctx context.Context, set exporter.CreateSettings, cfg component.Config) (exporter.Logs, error) {
  29. lmLogExp := newLogsExporter(ctx, cfg, set)
  30. c := cfg.(*Config)
  31. return exporterhelper.NewLogsExporter(
  32. ctx,
  33. set,
  34. cfg,
  35. lmLogExp.PushLogData,
  36. exporterhelper.WithStart(lmLogExp.start),
  37. exporterhelper.WithQueue(c.QueueSettings),
  38. exporterhelper.WithRetry(c.RetrySettings),
  39. )
  40. }
  41. func createTracesExporter(ctx context.Context, set exporter.CreateSettings, cfg component.Config) (exporter.Traces, error) {
  42. lmTraceExp := newTracesExporter(ctx, cfg, set)
  43. c := cfg.(*Config)
  44. return exporterhelper.NewTracesExporter(
  45. ctx,
  46. set,
  47. cfg,
  48. lmTraceExp.PushTraceData,
  49. exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
  50. exporterhelper.WithStart(lmTraceExp.start),
  51. exporterhelper.WithRetry(c.RetrySettings),
  52. exporterhelper.WithQueue(c.QueueSettings))
  53. }