rename ExporterWithConfig to be less confusing and closer to otel

This commit is contained in:
2024-05-17 15:36:35 +02:00
parent 3c51f5575b
commit d4dc790298
2 changed files with 18 additions and 14 deletions

View File

@ -15,8 +15,8 @@ type TraceExporter interface {
IntoTraceProviderOption() traceProviderOpt
}
func NewFromSpanExporter(exporter sdktrace.SpanExporter) ExporterWithConfig {
return ExporterWithConfig{
func NewFromSpanExporter(exporter sdktrace.SpanExporter) ExporterWithOptions {
return ExporterWithOptions{
exporter: exporter,
}
}
@ -37,18 +37,18 @@ func NewFromSpanProcessor(processor sdktrace.SpanProcessor) TraceExporter {
}
// Combined exporter with batch processor config
type ExporterWithConfig struct {
type ExporterWithOptions struct {
exporter sdktrace.SpanExporter
config []sdktrace.BatchSpanProcessorOption
opts []sdktrace.BatchSpanProcessorOption
}
func (ecfg ExporterWithConfig) Add(opt sdktrace.BatchSpanProcessorOption) ExporterWithConfig {
ecfg.config = append(ecfg.config, opt)
func (ecfg ExporterWithOptions) AddOption(opt sdktrace.BatchSpanProcessorOption) ExporterWithOptions {
ecfg.opts = append(ecfg.opts, opt)
return ecfg
}
func (ecfg ExporterWithConfig) IntoTraceProviderOption() traceProviderOpt {
return sdktrace.WithBatcher(ecfg.exporter, ecfg.config...)
func (ecfg ExporterWithOptions) IntoTraceProviderOption() traceProviderOpt {
return sdktrace.WithBatcher(ecfg.exporter, ecfg.opts...)
}
// An exporter printing to console with very small delay
@ -63,14 +63,14 @@ func DevConsoleExporter(opts ...console_exporter.ProcessorOptions) TraceExporter
}
// Default exporter to Graylog.
func GelfExporter(opts ...gelf_exporter.Option) (ExporterWithConfig, error) {
func GelfExporter(opts ...gelf_exporter.Option) (ExporterWithOptions, error) {
gelfExp, err := gelf_exporter.New(opts...)
return NewFromSpanExporter(gelfExp), err
}
// Exporter for traces over HTTP. Can be used with Jaeger.
// See documentation of [otlhttp_exporter] for details.
func OtlpHTTPExporter(opts ...otlphttp_exporter.Option) (ExporterWithConfig, error) {
func OtlpHTTPExporter(opts ...otlphttp_exporter.Option) (ExporterWithOptions, error) {
otlpExp, err := otlphttp_exporter.New(context.Background(), opts...)
return NewFromSpanExporter(otlpExp), err
}