rename ExporterWithConfig to be less confusing and closer to otel
This commit is contained in:
parent
3c51f5575b
commit
d4dc790298
@ -11,7 +11,7 @@ import (
|
||||
"git.ma-al.com/gora_filip/observer/pkg/tracer"
|
||||
"git.ma-al.com/gora_filip/pkg/attr/layer_attr"
|
||||
"git.ma-al.com/gora_filip/pkg/exporters"
|
||||
"git.ma-al.com/gora_filip/pkg/fiber_tracing"
|
||||
tracing "git.ma-al.com/gora_filip/pkg/fiber_tracing"
|
||||
"git.ma-al.com/gora_filip/pkg/level"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@ -31,17 +31,21 @@ func main() {
|
||||
if err == nil {
|
||||
exps = append(exps, gelfExp)
|
||||
}
|
||||
jaegerExp, err := exporters.OtlpHTTPExporter()
|
||||
if err == nil {
|
||||
exps = append(exps, jaegerExp)
|
||||
}
|
||||
|
||||
main.Use(fiber_tracing.NewMiddleware(fiber_tracing.Config{
|
||||
main.Use(tracing.NewMiddleware(tracing.Config{
|
||||
AppName: "example",
|
||||
Version: "0.0.0",
|
||||
ServiceProvider: "maal",
|
||||
Exporters: exps,
|
||||
}))
|
||||
defer fiber_tracing.ShutdownTracer()
|
||||
defer tracing.ShutdownTracer()
|
||||
|
||||
main.Get("/", func(c *fiber.Ctx) error {
|
||||
ctx, span := fiber_tracing.FStart(c, layer_attr.Handler{
|
||||
ctx, span := tracing.FStart(c, layer_attr.Handler{
|
||||
Level: level.DEBUG,
|
||||
}.AsOpts())
|
||||
defer span.End()
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user