-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow retrieving data from metadata or adding data to metadata #45
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rogerogers The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: rogerogers <[email protected]>
9c0ea91
to
0feaebb
Compare
1d0e095
to
8ba13b5
Compare
Signed-off-by: rogerogers <[email protected]>
8ba13b5
to
f65e7cd
Compare
Signed-off-by: rogerogers <[email protected]>
"go.opentelemetry.io/otel/propagation" | ||
) | ||
|
||
type metadataSupplier struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个看起来和目前的 propagator 区别不大? https://github.com/kitex-contrib/obs-opentelemetry/blob/main/tracing/propagator.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/google.golang.org/grpc/otelgrpc/metadata_supplier.go
从这里拷来一份,这个md是 map[string][]string
类型的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,主要是考虑是否需要区分 grpc metadata 和普通的 metadata
@@ -43,6 +44,13 @@ func ClientMiddleware(cfg *config) endpoint.Middleware { | |||
|
|||
Inject(ctx, cfg, md) | |||
|
|||
if cfg.enableMetadata { | |||
grpcMd, ok := metadata.FromOutgoingContext(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是可以考虑合并下 md,而非重复实现一个 propogator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可能得考虑一个场景,比如:a -> b -> c
a -> b 走的 kitex thrift 协议, b -> c 走的 kitex grpc 协议
那 a -> b 的 metadata 是否需要通过 grpc metadata 的方式(metadata.AppendToOutgoingContext
)透传给 c
ctx = injectMetadata(ctx, cfg, grpcMd) | ||
} | ||
} | ||
|
||
for k, v := range md { | ||
ctx = metainfo.WithValue(ctx, k, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grpc 的 metadata 传输方式也是这样么?还是说得 metadata.AppendToOutgoingContext
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metadata.NewOutgoingContext
跟 metadata.AppendToOutgoingContext
效果差不多
允许从 metadata 获取信息、设置信息到 metadata
closed: cloudwego/kitex#1323