mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-03 19:32:48 +02:00
Fix many instances of contexts and loggers not being propagated (#5340)
This also replaces instances where we manually write "return ctx.Err()" with "return context.Cause(ctx)" which is functionally identical, but will also correctly propagate cause errors if present.
This commit is contained in:
parent
e1880ba20f
commit
fe31799eb5
77 changed files with 297 additions and 221 deletions
|
@ -1,11 +1,14 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/pomerium/protoutil/streams"
|
||||
"github.com/rs/zerolog"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/middleware/responsewriter"
|
||||
"github.com/pomerium/pomerium/pkg/telemetry/requestid"
|
||||
|
@ -121,3 +124,17 @@ func HeadersHandler(headers []string) func(next http.Handler) http.Handler {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func StreamServerInterceptor(lg *zerolog.Logger) grpc.StreamServerInterceptor {
|
||||
return func(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
s := streams.NewServerStreamWithContext(ss)
|
||||
s.SetContext(lg.WithContext(s.Ctx))
|
||||
return handler(srv, s)
|
||||
}
|
||||
}
|
||||
|
||||
func UnaryServerInterceptor(lg *zerolog.Logger) grpc.UnaryServerInterceptor {
|
||||
return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
return handler(lg.WithContext(ctx), req)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue