mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
36 lines
921 B
Go
36 lines
921 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
grpc_utils "github.com/zitadel/zitadel/internal/api/grpc"
|
|
grpc_trace "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type GRPCMethod string
|
|
|
|
func DefaultTracingClient() grpc.UnaryClientInterceptor {
|
|
return TracingServer(grpc_utils.Healthz, grpc_utils.Readiness, grpc_utils.Validation)
|
|
}
|
|
|
|
func TracingServer(ignoredMethods ...GRPCMethod) grpc.UnaryClientInterceptor {
|
|
return func(
|
|
ctx context.Context,
|
|
method string,
|
|
req, reply interface{},
|
|
cc *grpc.ClientConn,
|
|
invoker grpc.UnaryInvoker,
|
|
opts ...grpc.CallOption,
|
|
) error {
|
|
|
|
for _, ignoredMethod := range ignoredMethods {
|
|
if strings.HasSuffix(method, string(ignoredMethod)) {
|
|
return invoker(ctx, method, req, reply, cc, opts...)
|
|
}
|
|
}
|
|
return grpc_trace.UnaryClientInterceptor()(ctx, method, req, reply, cc, invoker, opts...)
|
|
}
|
|
}
|