mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
25ef3da9d5
chore(fmt): run gci on complete project Fix global import formatting in go code by running the `gci` command. This allows us to just use the command directly, instead of fixing the import order manually for the linter, on each PR. Co-authored-by: Elio Bischof <elio@zitadel.com>
35 lines
852 B
Go
35 lines
852 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
grpc_trace "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
|
"google.golang.org/grpc"
|
|
|
|
grpc_utils "github.com/zitadel/zitadel/internal/api/grpc"
|
|
)
|
|
|
|
type GRPCMethod string
|
|
|
|
func DefaultTracingServer() grpc.UnaryServerInterceptor {
|
|
return TracingServer(grpc_utils.Healthz, grpc_utils.Readiness, grpc_utils.Validation)
|
|
}
|
|
|
|
func TracingServer(ignoredMethods ...GRPCMethod) grpc.UnaryServerInterceptor {
|
|
return func(
|
|
ctx context.Context,
|
|
req interface{},
|
|
info *grpc.UnaryServerInfo,
|
|
handler grpc.UnaryHandler,
|
|
) (interface{}, error) {
|
|
|
|
for _, ignoredMethod := range ignoredMethods {
|
|
if strings.HasSuffix(info.FullMethod, string(ignoredMethod)) {
|
|
return handler(ctx, req)
|
|
}
|
|
}
|
|
return grpc_trace.UnaryServerInterceptor()(ctx, req, info, handler)
|
|
}
|
|
}
|