reorganize exporters and simplify their use

This commit is contained in:
2024-05-17 10:37:05 +02:00
parent fc92995cc8
commit e9c3ae1a7b
9 changed files with 93 additions and 55 deletions

View File

@ -10,8 +10,7 @@ import (
"git.ma-al.com/gora_filip/observer/pkg/tracer"
"git.ma-al.com/gora_filip/pkg/attr"
"git.ma-al.com/gora_filip/pkg/combined_exporter"
"git.ma-al.com/gora_filip/pkg/console_exporter"
"git.ma-al.com/gora_filip/pkg/exporters"
"git.ma-al.com/gora_filip/pkg/fiber_tracing"
"git.ma-al.com/gora_filip/pkg/level"
"github.com/gofiber/fiber/v2"
@ -26,19 +25,17 @@ func main() {
StreamRequestBody: true,
})
lvl := level.DEBUG
exporter := combined_exporter.NewExporter(
console_exporter.NewExporter(
console_exporter.ExporterOptions{
FilterOnLevel: &lvl,
//EmitOnlyOnError: true,
},
))
exps := make([]exporters.ExporterWithConfig, 2)
exps = append(exps, exporters.DevConsoleExporter())
gelfExp, err := exporters.GelfExporter()
if err == nil {
exps = append(exps, gelfExp)
}
main.Use(fiber_tracing.NewMiddleware(fiber_tracing.Config{
AppName: "example",
Version: "0.0.0",
ServiceProvider: "maal",
Exporter: exporter,
Exporters: exps,
}))
defer fiber_tracing.ShutdownTracer()