frostfs-observability/tracing/grpc/carrier.go
Dmitrii Stepanov 7f9eba1b19 [#3] tracing: Move from api-go
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-05-31 11:27:42 +03:00

29 lines
506 B
Go

package grpc
import (
"google.golang.org/grpc/metadata"
)
type grpcMetadataCarrier struct {
md *metadata.MD
}
func (c *grpcMetadataCarrier) Get(key string) string {
values := c.md.Get(key)
if len(values) > 0 {
return values[0]
}
return ""
}
func (c *grpcMetadataCarrier) Set(key string, value string) {
c.md.Set(key, value)
}
func (c *grpcMetadataCarrier) Keys() []string {
result := make([]string, 0, c.md.Len())
for key := range *c.md {
result = append(result, key)
}
return result
}