Skip to content

Commit

Permalink
Stop using deprecated functions
Browse files Browse the repository at this point in the history
otelgrpc has deprecated otelgrpc.UnaryClientInterceptor and
otelgrpc.UnaryServerInterceptor, instead you should use NewClientHandler
with grpc.WithStatsHandler to instrument a gRPC client, and
NewServerHandler with grpc.StatsHandler to instrument a gRPC server.

Signed-off-by: Kim Christensen <[email protected]>
  • Loading branch information
kichristensen committed May 10, 2024
1 parent 179f85a commit 072c99b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/plugins/pluggable/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (c *PluginConnection) Start(ctx context.Context, pluginCfg io.Reader) error
// Configure gRPC to propagate the span context so the plugin's traces
// show up under the current span
GRPCDialOptions: []grpc.DialOption{
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
},
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ func ServeMany(c *portercontext.Context, pluginMap map[int]plugin.PluginSet) {
VersionedPlugins: pluginMap,
GRPCServer: func(opts []grpc.ServerOption) *grpc.Server {
opts = append(opts,
grpc.StatsHandler(otelgrpc.NewServerHandler()),
// These handlers are called from left to right. The right-most handler is the one that calls the actual implementation
// the grpc_recovery handler should always be last so that it can recover from a panic, and then the other handlers only get
// a nice error (created from the panic) to deal with
grpc.ChainUnaryInterceptor(
otelgrpc.UnaryServerInterceptor(),
makeLogUnaryHandler(c),
makePanicHandler()),
)
Expand Down

0 comments on commit 072c99b

Please sign in to comment.