plenty of changes to make the package more ergonomic

Including: bug fixes, api changes, new packages, and more!
This commit is contained in:
2024-05-17 15:31:35 +02:00
parent e835318689
commit 3c51f5575b
10 changed files with 378 additions and 178 deletions

View File

@ -9,7 +9,7 @@ import (
"time"
"git.ma-al.com/gora_filip/observer/pkg/tracer"
"git.ma-al.com/gora_filip/pkg/attr"
"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"
"git.ma-al.com/gora_filip/pkg/level"
@ -25,12 +25,13 @@ func main() {
StreamRequestBody: true,
})
exps := make([]exporters.ExporterWithConfig, 2)
exps := make([]exporters.TraceExporter, 0)
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",
@ -40,12 +41,16 @@ func main() {
defer fiber_tracing.ShutdownTracer()
main.Get("/", func(c *fiber.Ctx) error {
ctx, span := tracer.Handler(c)
ctx, span := fiber_tracing.FStart(c, layer_attr.Handler{
Level: level.DEBUG,
}.AsOpts())
defer span.End()
span.AddEvent(
"smthing is happening",
attr.WithAttributes(attr.SeverityLevel(level.INFO), attr.SourceCodeLocation(0)),
layer_attr.Handler{
Level: level.INFO,
}.AsOpts(),
)
err := Serv(ctx)