mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-30 14:56:15 +00:00
## 📄 Summary
- Instead of relying on JWT for session management, we are adding another token system: opaque. This gives the benefits of expiration and revocation.
- We are now ensuring that emails are regex checked throughout the backend.
- Support has been added for OIDC protocol
38 lines
811 B
Go
38 lines
811 B
Go
package loghandler
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
)
|
|
|
|
type correlation struct{}
|
|
|
|
func NewCorrelation() *correlation {
|
|
return &correlation{}
|
|
}
|
|
|
|
func (h *correlation) Wrap(next LogHandler) LogHandler {
|
|
return LogHandlerFunc(func(ctx context.Context, record slog.Record) error {
|
|
span := trace.SpanFromContext(ctx)
|
|
if span == nil || !span.IsRecording() {
|
|
return next.Handle(ctx, record)
|
|
}
|
|
|
|
// Adding span info to log record.
|
|
spanContext := span.SpanContext()
|
|
if spanContext.HasTraceID() {
|
|
traceID := spanContext.TraceID().String()
|
|
record.AddAttrs(slog.String("trace_id", traceID))
|
|
}
|
|
|
|
if spanContext.HasSpanID() {
|
|
spanID := spanContext.SpanID().String()
|
|
record.AddAttrs(slog.String("span_id", spanID))
|
|
}
|
|
|
|
return next.Handle(ctx, record)
|
|
})
|
|
}
|