Skip to content

Commit

Permalink
feature: support higher versions of grpc-go (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alipebt authored May 26, 2024
1 parent 9549d21 commit 8c78e5a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Release Notes.
* Support [Pulsar](https://github.com/apache/pulsar-client-go) MQ.
* Support [Segmentio-Kafka](https://github.com/segmentio/kafka-go) MQ.
* Support http headers collection for Gin
* Support higher versions of grpc.

#### Chore
* Enhance the observability of makefile execution
Expand Down
13 changes: 1 addition & 12 deletions plugins/grpc/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,63 +70,52 @@ func (i *Instrument) Points() []*instrument.Point {
{
PackagePath: "",
At: instrument.NewMethodEnhance("*Server", "handleStream",
instrument.WithArgsCount(3),
instrument.WithArgType(0, "transport.ServerTransport")),
Interceptor: "ServerHandleStreamInterceptor ",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*Server", "sendResponse",
instrument.WithArgsCount(6),
instrument.WithArgType(0, "transport.ServerTransport"),
instrument.WithResultType(0, "error")),
Interceptor: "ServerSendResponseInterceptor",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*Server", "processUnaryRPC",
instrument.WithArgsCount(5),
instrument.WithArgType(0, "transport.ServerTransport"),
instrument.WithResultType(0, "error")),
Interceptor: "ServerUnaryInterceptor",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*Server", "processStreamingRPC",
instrument.WithArgsCount(3),
instrument.WithArgType(0, "transport.ServerTransport"),
instrument.WithArgType(1, "*transport.Stream")),
instrument.WithResultType(0, "error")),
Interceptor: "ServerStreamingInterceptor",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*clientStream", "SendMsg",
instrument.WithArgsCount(1),
instrument.WithArgType(0, "interface{}"),
instrument.WithResultType(0, "error")),
Interceptor: "ClientSendMsgInterceptor",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*clientStream", "RecvMsg",
instrument.WithArgsCount(1),
instrument.WithArgType(0, "interface{}"),
instrument.WithResultType(0, "error")),
Interceptor: "ClientRecvMsgInterceptor",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*serverStream", "SendMsg",
instrument.WithArgsCount(1),
instrument.WithArgType(0, "interface{}"),
instrument.WithResultType(0, "error")),
Interceptor: "ServerSendMsgInterceptor",
},
{
PackagePath: "",
At: instrument.NewMethodEnhance("*serverStream", "RecvMsg",
instrument.WithArgsCount(1),
instrument.WithArgType(0, "interface{}"),
instrument.WithResultType(0, "error")),
Interceptor: "ServerRecvMsgInterceptor",
},
Expand Down
10 changes: 9 additions & 1 deletion plugins/grpc/server_sendresponse_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ func (h *ServerSendResponseInterceptor) BeforeInvoke(invocation operator.Invocat
if tracing.ActiveSpan() == nil {
return nil
}
cs := invocation.Args()[1].(*nativeStream)
var cs *nativeStream
if arg1, ok := invocation.Args()[1].(*nativeStream); ok {
cs = arg1
} else if arg2, ok := invocation.Args()[2].(*nativeStream); ok {
cs = arg2
} else {
return nil
}

method := cs.Method()
s, err := tracing.CreateLocalSpan(formatOperationName(method, "/Server/Response/SendResponse"),
tracing.WithLayer(tracing.SpanLayerRPCFramework),
Expand Down
7 changes: 7 additions & 0 deletions test/plugins/scenarios/grpc/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ support-version:
- v1.55.0
- v1.56.0
- v1.57.0
- v1.58.0
- go: 1.19
framework:
- v1.59.0
- v1.60.0
- v1.62.0
- v1.64.0

0 comments on commit 8c78e5a

Please sign in to comment.