shim: Move ttrpc interceptors to plugins

This makes it so we don't need to import otelttrpc unless the shim is
compiled with the `shim_tracing` build tag.
This way otel is no longer compiled into the binary at all unless
`shim_tracing` is set.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2024-10-02 23:10:27 +00:00
parent 6ffdabf725
commit b2681dfbdb
3 changed files with 67 additions and 19 deletions

View File

@@ -74,7 +74,7 @@ func init() {
}
var (
_ = shim.TTRPCServerOptioner(&taskServiceWithFp{})
_ = shim.TTRPCServerUnaryOptioner(&taskServiceWithFp{})
)
type taskServiceWithFp struct {
@@ -87,7 +87,7 @@ func (s *taskServiceWithFp) RegisterTTRPC(server *ttrpc.Server) error {
return nil
}
func (s *taskServiceWithFp) UnaryInterceptor() ttrpc.UnaryServerInterceptor {
func (s *taskServiceWithFp) UnaryServerInterceptor() ttrpc.UnaryServerInterceptor {
return func(ctx context.Context, unmarshal ttrpc.Unmarshaler, info *ttrpc.UnaryServerInfo, method ttrpc.Method) (interface{}, error) {
methodName := filepath.Base(info.FullMethod)
if fp, ok := s.fps[methodName]; ok {