@@ -188,20 +188,21 @@ type messageAnnotation struct {
188188}
189189
190190type methodAnnotation struct {
191- Name string
192- BuilderName string
193- DocLines []string
194- PathInfo * api.PathInfo
195- Body string
196- ServiceNameToPascal string
197- ServiceNameToCamel string
198- ServiceNameToSnake string
199- OperationInfo * operationInfo
200- SystemParameters []systemParameter
201- ReturnType string
202- HasVeneer bool
203- Attributes []string
204- RoutingRequired bool
191+ Name string
192+ BuilderName string
193+ DocLines []string
194+ PathInfo * api.PathInfo
195+ Body string
196+ ServiceNameToPascal string
197+ ServiceNameToCamel string
198+ ServiceNameToSnake string
199+ OperationInfo * operationInfo
200+ SystemParameters []systemParameter
201+ ReturnType string
202+ HasVeneer bool
203+ Attributes []string
204+ RoutingRequired bool
205+ DetailedTracingAttributes bool
205206}
206207
207208type pathInfoAnnotation struct {
@@ -312,6 +313,9 @@ type pathBindingAnnotation struct {
312313
313314 // The variables to be substituted into the path
314315 Substitutions []* bindingSubstitution
316+
317+ // The codec is configured to generated detailed tracing attributes.
318+ DetailedTracingAttributes bool
315319}
316320
317321// QueryParamsCanFail returns true if we serialize certain query parameters, which can fail. The code we generate
@@ -694,7 +698,7 @@ func (c *codec) annotateMessage(m *api.Message, model *api.API) {
694698}
695699
696700func (c * codec ) annotateMethod (m * api.Method ) {
697- annotatePathInfo (m )
701+ c . annotatePathInfo (m )
698702 for _ , routing := range m .Routing {
699703 for _ , variant := range routing .Variants {
700704 routingVariantAnnotations := & routingVariantAnnotations {
@@ -712,18 +716,19 @@ func (c *codec) annotateMethod(m *api.Method) {
712716 }
713717 serviceName := c .ServiceName (m .Service )
714718 annotation := & methodAnnotation {
715- Name : strcase .ToSnake (m .Name ),
716- BuilderName : toPascal (m .Name ),
717- Body : bodyAccessor (m ),
718- DocLines : c .formatDocComments (m .Documentation , m .ID , m .Model .State , m .Service .Scopes ()),
719- PathInfo : m .PathInfo ,
720- ServiceNameToPascal : toPascal (serviceName ),
721- ServiceNameToCamel : toCamel (serviceName ),
722- ServiceNameToSnake : toSnake (serviceName ),
723- SystemParameters : c .systemParameters ,
724- ReturnType : returnType ,
725- HasVeneer : c .hasVeneer ,
726- RoutingRequired : c .routingRequired ,
719+ Name : strcase .ToSnake (m .Name ),
720+ BuilderName : toPascal (m .Name ),
721+ Body : bodyAccessor (m ),
722+ DocLines : c .formatDocComments (m .Documentation , m .ID , m .Model .State , m .Service .Scopes ()),
723+ PathInfo : m .PathInfo ,
724+ ServiceNameToPascal : toPascal (serviceName ),
725+ ServiceNameToCamel : toCamel (serviceName ),
726+ ServiceNameToSnake : toSnake (serviceName ),
727+ SystemParameters : c .systemParameters ,
728+ ReturnType : returnType ,
729+ HasVeneer : c .hasVeneer ,
730+ RoutingRequired : c .routingRequired ,
731+ DetailedTracingAttributes : c .detailedTracingAttributes ,
727732 }
728733 if annotation .Name == "clone" {
729734 // Some methods look too similar to standard Rust traits. Clippy makes
@@ -831,7 +836,7 @@ func makeBindingSubstitution(v *api.PathVariable, m *api.Method) bindingSubstitu
831836 }
832837}
833838
834- func annotatePathBinding (b * api.PathBinding , m * api.Method ) * pathBindingAnnotation {
839+ func ( c * codec ) annotatePathBinding (b * api.PathBinding , m * api.Method ) * pathBindingAnnotation {
835840 var subs []* bindingSubstitution
836841 for _ , s := range b .PathTemplate .Segments {
837842 if s .Variable != nil {
@@ -840,19 +845,20 @@ func annotatePathBinding(b *api.PathBinding, m *api.Method) *pathBindingAnnotati
840845 }
841846 }
842847 return & pathBindingAnnotation {
843- PathFmt : httpPathFmt (b .PathTemplate ),
844- QueryParams : language .QueryParams (m , b ),
845- Substitutions : subs ,
848+ PathFmt : httpPathFmt (b .PathTemplate ),
849+ QueryParams : language .QueryParams (m , b ),
850+ Substitutions : subs ,
851+ DetailedTracingAttributes : c .detailedTracingAttributes ,
846852 }
847853}
848854
849855// annotatePathInfo annotates the `PathInfo` and all of its `PathBinding`s.
850- func annotatePathInfo (m * api.Method ) {
856+ func ( c * codec ) annotatePathInfo (m * api.Method ) {
851857 seen := make (map [string ]bool )
852858 var uniqueParameters []* bindingSubstitution
853859
854860 for _ , b := range m .PathInfo .Bindings {
855- ann := annotatePathBinding (b , m )
861+ ann := c . annotatePathBinding (b , m )
856862
857863 // We need to keep track of unique path parameters to support
858864 // implicit routing over gRPC. This is go/aip/4222.
0 commit comments