Please answer these questions before submitting a bug report.
What version of OpenCensus are you using?
v0.22.5
What version of Go are you using?
1.15
What did you do?
I wanted to add an extra label/tag to the ocgcrpc-generated server metrics: client ID, and export them with a custom view. See a sample gRPC+metrics server. In particular lines around clientIDValue.
Then I send a grpc.health.v1.Health/Check() request and check the /metrics output.
What did you expect to see?
I expected the value for the KeyGRPCClient OC tag to show up in the ocgrpc view, i.e. get populated in the prom exporter hander as client="foo@bar.com" label
What did you see instead?
The value from the Go/OC context is not propagated to the ocgrpc context. The exported metrics have the label client=""
Currently there's a NewContext() method in the tag module to overwrite the tags map and New() which is used with mutators to add/remove single value.
At a first glance the solution might be to add a new mutator to merge the provided map (similar to the one in New()) into the current context and use the mutator instead of tag.NewContext().
This looks somewhat related to #746 but this one seems to have an easy solution that doesn't introduce the mutability concerns.
Please answer these questions before submitting a bug report.
What version of OpenCensus are you using?
v0.22.5
What version of Go are you using?
1.15
What did you do?
I wanted to add an extra label/tag to the ocgcrpc-generated server metrics: client ID, and export them with a custom view. See a sample gRPC+metrics server. In particular lines around
clientIDValue
.Then I send a
grpc.health.v1.Health/Check()
request and check the /metrics output.What did you expect to see?
I expected the value for the
KeyGRPCClient
OC tag to show up in the ocgrpc view, i.e. get populated in the prom exporter hander asclient="foo@bar.com"
labelWhat did you see instead?
The value from the Go/OC context is not propagated to the ocgrpc context. The exported metrics have the label
client=""
Additional context
I believe the problem is at https://github.com/census-instrumentation/opencensus-go/blob/e736602bcaf5ed1e2191a730813ac2bc7caed9eb/plugin/ocgrpc/server_stats_handler.go#L43, where the oc tag map in the context is overwritten with
tag.NewContext()
to populate it with the tags from grpc metadata.Currently there's a
NewContext()
method in thetag
module to overwrite the tags map andNew()
which is used with mutators to add/remove single value.At a first glance the solution might be to add a new mutator to merge the provided map (similar to the one in
New()
) into the current context and use the mutator instead oftag.NewContext()
.This looks somewhat related to #746 but this one seems to have an easy solution that doesn't introduce the mutability concerns.