mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Bump github.com/opentracing-contrib/go-grpc Bumps [github.com/opentracing-contrib/go-grpc](https://github.com/opentracing-contrib/go-grpc) from 0.0.0-20210225150812-73cb765af46e to 0.1.0. - [Release notes](https://github.com/opentracing-contrib/go-grpc/releases) - [Commits](https://github.com/opentracing-contrib/go-grpc/commits/v0.1.0) --- updated-dependencies: - dependency-name: github.com/opentracing-contrib/go-grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update serverless gomod --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: tempo-gh-bot[bot] <[email protected]>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package otgrpc
|
|
|
|
import (
|
|
"strings"
|
|
|
|
opentracing "github.com/opentracing/opentracing-go"
|
|
"github.com/opentracing/opentracing-go/ext"
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
// Morally a const:.
|
|
var gRPCComponentTag = opentracing.Tag{Key: string(ext.Component), Value: "gRPC"}
|
|
|
|
// metadataReaderWriter satisfies both the opentracing.TextMapReader and
|
|
// opentracing.TextMapWriter interfaces.
|
|
type metadataReaderWriter struct {
|
|
metadata.MD
|
|
}
|
|
|
|
func (w metadataReaderWriter) Set(key, val string) {
|
|
// The GRPC HPACK implementation rejects any uppercase keys here.
|
|
//
|
|
// As such, since the HTTP_HEADERS format is case-insensitive anyway, we
|
|
// blindly lowercase the key (which is guaranteed to work in the
|
|
// Inject/Extract sense per the OpenTracing spec).
|
|
key = strings.ToLower(key)
|
|
w.MD[key] = append(w.MD[key], val)
|
|
}
|
|
|
|
func (w metadataReaderWriter) ForeachKey(handler func(key, val string) error) error {
|
|
for k, vals := range w.MD {
|
|
for _, v := range vals {
|
|
if err := handler(k, v); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|