1 // Copyright 2017, OpenCensus Authors
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
21 "go.opencensus.io/tag"
22 "golang.org/x/net/context"
23 "google.golang.org/grpc/grpclog"
24 "google.golang.org/grpc/stats"
27 // statsTagRPC gets the tag.Map populated by the application code, serializes
28 // its tags into the GRPC metadata in order to be sent to the server.
29 func (h *ClientHandler) statsTagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
30 startTime := time.Now()
33 grpclog.Infof("clientHandler.TagRPC called with nil info.", info.FullMethodName)
40 method: info.FullMethodName,
42 ts := tag.FromContext(ctx)
44 encoded := tag.Encode(ts)
45 ctx = stats.SetTags(ctx, encoded)
48 return context.WithValue(ctx, rpcDataKey, d)