Skip to content

Commit ec673cc

Browse files
to filter client stream span (#270)
* to filter client stream span * delete stream test * delete stream test
1 parent e817c32 commit ec673cc

14 files changed

+53
-2728
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Also there are several [**documents**](./docs) that you may find useful for eith
8888
| go-redis | https://github.com/redis/go-redis | v9.0.5 | v9.5.1 |
8989
| go-redis v8 | https://github.com/redis/go-redis | v8.11.0 | v8.11.5 |
9090
| gorm | https://github.com/go-gorm/gorm | v1.22.0 | v1.25.9 |
91-
| grpc | https://google.golang.org/grpc | v1.44.0 | v1.67.0 |
91+
| grpc | https://google.golang.org/grpc | v1.44.0 | v1.68.2 |
9292
| hertz | https://github.com/cloudwego/hertz | v0.8.0 | v0.9.2 |
9393
| kitex | https://github.com/cloudwego/kitex | v0.5.1 | v0.11.3 |
9494
| kratos | https://github.com/go-kratos/kratos | v2.6.3 | v2.8.2 |

docs/supported-libraries.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
| go-redis | https://github.com/redis/go-redis | v9.0.5 | v9.5.1 |
1313
| go-redis v8 | https://github.com/redis/go-redis | v8.11.0 | v8.11.5 |
1414
| gorm | https://github.com/go-gorm/gorm | v1.22.0 | v1.25.9 |
15-
| grpc | https://google.golang.org/grpc | v1.44.0 | v1.67.0 |
15+
| grpc | https://google.golang.org/grpc | v1.44.0 | v1.68.2 |
1616
| hertz | https://github.com/cloudwego/hertz | v0.8.0 | v0.9.2 |
17-
| kitex | https://github.com/cloudwego/kitex | v0.5.1 | v0.11.3 |
17+
| kitex | https://github.com/cloudwego/kitex | v0.5.1 | v0.11.3 |
1818
| kratos | https://github.com/go-kratos/kratos | v2.6.3 | v2.8.2 |
1919
| log | https://pkg.go.dev/log | - | - |
2020
| logrus | https://github.com/sirupsen/logrus | v1.5.0 | v1.9.3 |
@@ -25,4 +25,8 @@
2525
| redigo | https://github.com/gomodule/redigo | v1.9.0 | v1.9.2 |
2626
| slog | https://pkg.go.dev/log/slog | - | - |
2727
| zap | https://github.com/uber-go/zap | v1.20.0 | v1.27.0 |
28-
| zerolog | https://github.com/rs/zerolog | v1.10.0 | v1.33.0 |
28+
| zerolog | https://github.com/rs/zerolog | v1.10.0 | v1.33.0 |
29+
30+
### Notice
31+
32+
#### grpc stream is not support yet

pkg/data/default.json

+9
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,15 @@
512512
"OnExit": "grpcServerOnExit",
513513
"Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc"
514514
},
515+
{
516+
"Version": "[1.44.0,)",
517+
"ImportPath": "google.golang.org/grpc",
518+
"ReceiverType": "*ClientConn",
519+
"Function": "NewStream",
520+
"OnEnter": "grpcClientNewStreamOnEnter",
521+
"OnExit": "grpcClientNewStreamOnExit",
522+
"Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc"
523+
},
515524
{
516525
"ImportPath": "github.com/cloudwego/hertz/pkg/app/server",
517526
"Function": "New",
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2024 Alibaba Group Holding Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package grpc
16+
17+
import (
18+
"context"
19+
"github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/api"
20+
"google.golang.org/grpc"
21+
)
22+
23+
func grpcClientNewStreamOnEnter(call api.CallContext, cc *grpc.ClientConn, ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) {
24+
var stream_filter bool
25+
stream_filter = true
26+
ctx = context.WithValue(ctx, "stream_filter", &stream_filter)
27+
call.SetParam(1, ctx)
28+
}
29+
30+
func grpcClientNewStreamOnExit(call api.CallContext, cs grpc.ClientStream, err error) {
31+
return
32+
}

pkg/rules/grpc/grpc_new_client_setup.go

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ func NewClientNewHandler(opts ...Option) stats.Handler {
4949

5050
// TagRPC can attach some information to the given context.
5151
func (h *clientNewHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
52+
filter, _ := ctx.Value("stream_filter").(*bool)
53+
if filter != nil && *filter {
54+
return ctx
55+
}
5256
nCtx := grpcClientInstrument.Start(ctx, grpcRequest{
5357
methodName: info.FullMethodName,
5458
serverAddress: h.serverAddr,

test/grpc_stream/client/client.go

-210
This file was deleted.

test/grpc_stream/go.mod

-30
This file was deleted.

test/grpc_stream/go.sum

-43
This file was deleted.

0 commit comments

Comments
 (0)