|
|
|
// Copyright 2023 William Perron. All rights reserved. MIT License.
|
|
|
|
package sqliteexporter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
|
|
"go.opentelemetry.io/collector/consumer"
|
|
|
|
"go.opentelemetry.io/collector/exporter"
|
|
|
|
"go.opentelemetry.io/collector/exporter/exporterhelper"
|
|
|
|
"go.wperron.io/sqliteexporter/internal/metadata"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewFactory() exporter.Factory {
|
|
|
|
return exporter.NewFactory(
|
|
|
|
metadata.Type,
|
|
|
|
createDefaultConfig,
|
|
|
|
exporter.WithTraces(createTracesExporter, metadata.TracesStability),
|
|
|
|
exporter.WithMetrics(nil, metadata.MetricsStability),
|
|
|
|
exporter.WithLogs(nil, metadata.LogsStability),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func createDefaultConfig() component.Config {
|
|
|
|
return &Config{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func createTracesExporter(
|
|
|
|
ctx context.Context,
|
|
|
|
set exporter.CreateSettings,
|
|
|
|
cfg component.Config,
|
|
|
|
) (exporter.Traces, error) {
|
|
|
|
conf := cfg.(*Config)
|
|
|
|
|
|
|
|
se := newSqliteExporter(conf)
|
|
|
|
|
|
|
|
return exporterhelper.NewTracesExporter(
|
|
|
|
ctx, set, cfg,
|
|
|
|
se.ConsumeTraces,
|
|
|
|
exporterhelper.WithStart(se.Start),
|
|
|
|
exporterhelper.WithShutdown(se.Shutdown),
|
|
|
|
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newSqliteExporter(cfg *Config) *sqliteExporter {
|
|
|
|
return &sqliteExporter{}
|
|
|
|
}
|