feat(gengapic): expose resource names and static identity for OpenTelemetry tracing#1690
Conversation
…emetry tracing Modify grpcClientOptions and restClientOptions to populate internaloption.WithTelemetryAttributes. Modify insertRequestHeaders to expose resource names via metadata.AppendToOutgoingContext.
Add url.template to RPC data
…rce_reference annotation
ba42568 to
f5f0947
Compare
ca73707 to
1dd4a39
Compare
shollyman
left a comment
There was a problem hiding this comment.
Generally LGTM.
Something we'll probably want to think about is whether having a matrix-like approach to golden testfiles is going to be useful, so we can validate the expectations with different generator features being enabled. That's a problem we can shift to tomorrow, however.
|
This LGTM. Something to consider for a future Issue/PR: for both URL templates and resource names we are selecting a 'template' in the generator to include in the telemetry. This might not match exactly the URL template or resource name entered by the customer, in the case where there are multiple HTTP bindings or multiple resource reference fields and the "wrong" one is selected by the generator. It could be more correct (but more complex) to select the template based on the actual fields present at request time. I'd like to see how this PR performs before planning that work. As for follow-ups in the "Missing" list, I would just add:
|
Replace gRPC metadata Context management with new telemetry Context helpers. refs: googleapis#1690 refs: googleapis/gax-go#472
In this PR:
NewClient(gRPC) andNewRESTClient(HTTP) generation to includegcp.client.version(viagetVersionClient()) andgcp.client.repo("googleapis/google-cloud-go") in theWithTelemetryAttributesinternal option.resourceNameFieldhelper that scans request fields for thegoogle.api.resource_referenceannotation, including tie-breaking logic that prioritizes fields appearing in the HTTP path pattern.fmt.Sprintf("//service.host/%v", req.GetResourceNameField())).url.templatemetadata key containing the raw HTTP path pattern.gengapic_test.goandgenrest_test.gofixtures to includeresource_referenceanddefault_host, and regenerated all golden files.Missing from this PR:
Heuristic Logic
projects,instances,buckets) from literals in HTTP path patterns.:accessor sub-resource actions) from the end of the reconstructed name.