Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/gengapic/gengapic.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,12 @@ func (g *generator) insertRequestHeaders(m *descriptorpb.MethodDescriptorProto,
}

if host != "" {
p(` ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//%s/%%v", req%s))`, host, fieldGetter(resField))
p(` ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//%s/%%v", req%s))`, host, fieldGetter(resField))
} else {
p(` ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("%%v", req%s))`, fieldGetter(resField))
p(` ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("%%v", req%s))`, fieldGetter(resField))
}
p("}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc/metadata"}] = true
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/callctx"}] = true
g.imports[pbinfo.ImportSpec{Path: "fmt"}] = true
}
}
Expand All @@ -545,12 +545,12 @@ func (g *generator) insertRequestHeaders(m *descriptorpb.MethodDescriptorProto,
}

if host != "" {
p(` ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//%s/%%v", req%s))`, host, fieldGetter(resField))
p(` ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//%s/%%v", req%s))`, host, fieldGetter(resField))
} else {
p(` ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("%%v", req%s))`, fieldGetter(resField))
p(` ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("%%v", req%s))`, fieldGetter(resField))
}
p("}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc/metadata"}] = true
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/callctx"}] = true
g.imports[pbinfo.ImportSpec{Path: "fmt"}] = true
}
}
Expand Down
60 changes: 30 additions & 30 deletions internal/gengapic/gengapic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ func TestGenGRPCMethods(t *testing.T) {
Options: opts,
},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
},
}, {
m: &descriptorpb.MethodDescriptorProto{
Expand All @@ -433,11 +433,11 @@ func TestGenGRPCMethods(t *testing.T) {
Options: opts,
},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
},
},
{
Expand All @@ -448,12 +448,12 @@ func TestGenGRPCMethods(t *testing.T) {
Options: opts,
},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "google.golang.org/api/iterator"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "google.golang.org/protobuf/proto"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
{Path: "fmt"}: true,
{Path: "google.golang.org/api/iterator"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "google.golang.org/protobuf/proto"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
},
}, {
m: &descriptorpb.MethodDescriptorProto{
Expand All @@ -463,12 +463,12 @@ func TestGenGRPCMethods(t *testing.T) {
Options: opts,
},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "google.golang.org/api/iterator"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "google.golang.org/protobuf/proto"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
{Path: "fmt"}: true,
{Path: "google.golang.org/api/iterator"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "google.golang.org/protobuf/proto"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
},
},
{
Expand All @@ -481,9 +481,9 @@ func TestGenGRPCMethods(t *testing.T) {
},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "net/url"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
},
},
{
Expand Down Expand Up @@ -521,11 +521,11 @@ func TestGenGRPCMethods(t *testing.T) {
},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
{Path: "strings"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
{Path: "strings"}: true,
{Name: "mypackagepb", Path: "mypackage"}: true,
},
},
// Test for empty dynamic routing annotation, so no headers should be sent.
Expand Down
16 changes: 8 additions & 8 deletions internal/gengapic/genrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,9 @@ func (g *generator) serverStreamRESTCall(servName string, s *descriptorpb.Servic
g.insertRequestHeaders(m, rest)
if info != nil && g.featureEnabled(OpenTelemetryTracingFeature) {
p("if gax.IsFeatureEnabled(\"TRACING\") {")
p(" ctx = metadata.AppendToOutgoingContext(ctx, \"url.template\", %q)", info.url)
p(" ctx = callctx.WithTelemetryContext(ctx, \"url_template\", %q)", info.url)
p("}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc/metadata"}] = true
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/callctx"}] = true
}
p("var streamClient *%s", streamClient)
p("e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {")
Expand Down Expand Up @@ -959,9 +959,9 @@ func (g *generator) lroRESTCall(servName string, m *descriptorpb.MethodDescripto
g.insertRequestHeaders(m, rest)
if info != nil && g.featureEnabled(OpenTelemetryTracingFeature) {
p("if gax.IsFeatureEnabled(\"TRACING\") {")
p(" ctx = metadata.AppendToOutgoingContext(ctx, \"url.template\", %q)", info.url)
p(" ctx = callctx.WithTelemetryContext(ctx, \"url_template\", %q)", info.url)
p("}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc/metadata"}] = true
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/callctx"}] = true
}
p("unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}")
p("resp := &%s.%s{}", outSpec.Name, outType.GetName())
Expand Down Expand Up @@ -1061,9 +1061,9 @@ func (g *generator) emptyUnaryRESTCall(servName string, m *descriptorpb.MethodDe
g.insertRequestHeaders(m, rest)
if info != nil && g.featureEnabled(OpenTelemetryTracingFeature) {
p("if gax.IsFeatureEnabled(\"TRACING\") {")
p(" ctx = metadata.AppendToOutgoingContext(ctx, \"url.template\", %q)", info.url)
p(" ctx = callctx.WithTelemetryContext(ctx, \"url_template\", %q)", info.url)
p("}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc/metadata"}] = true
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/callctx"}] = true
}
p("return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {")
p(` if settings.Path != "" {`)
Expand Down Expand Up @@ -1156,9 +1156,9 @@ func (g *generator) unaryRESTCall(servName string, m *descriptorpb.MethodDescrip
g.insertRequestHeaders(m, rest)
if info != nil && g.featureEnabled(OpenTelemetryTracingFeature) {
p("if gax.IsFeatureEnabled(\"TRACING\") {")
p(" ctx = metadata.AppendToOutgoingContext(ctx, \"url.template\", %q)", info.url)
p(" ctx = callctx.WithTelemetryContext(ctx, \"url_template\", %q)", info.url)
p("}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc/metadata"}] = true
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/callctx"}] = true
}
g.appendCallOpts(m)
if !isHTTPBodyMessage {
Expand Down
39 changes: 20 additions & 19 deletions internal/gengapic/genrest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func TestGenRestMethod(t *testing.T) {
method: opRPC,
cfg: &generatorConfig{generateAsDIREGAPIC: true, featureEnablement: map[featureID]struct{}{OpenTelemetryTracingFeature: {}}},
imports: map[pbinfo.ImportSpec]bool{
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "google.golang.org/protobuf/encoding/protojson"}: true,
{Path: "net/url"}: true,
{Path: "fmt"}: true,
Expand All @@ -774,10 +774,10 @@ func TestGenRestMethod(t *testing.T) {
method: emptyRPC,
cfg: &generatorConfig{featureEnablement: map[featureID]struct{}{OpenTelemetryTracingFeature: {}}},
imports: map[pbinfo.ImportSpec]bool{
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "net/url"}: true,
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "net/url"}: true,
{Name: "foopb", Path: "google.golang.org/genproto/cloud/foo/v1"}: true,
},
},
Expand All @@ -786,14 +786,14 @@ func TestGenRestMethod(t *testing.T) {
method: unaryRPC,
cfg: &generatorConfig{restNumericEnum: true, featureEnablement: map[featureID]struct{}{OpenTelemetryTracingFeature: {}}},
imports: map[pbinfo.ImportSpec]bool{
{Path: "bytes"}: true,
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "bytes"}: true,
{Path: "fmt"}: true,
{Path: "github.com/google/uuid"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "google.golang.org/protobuf/encoding/protojson"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
{Path: "strings"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
{Path: "strings"}: true,
{Name: "foopb", Path: "google.golang.org/genproto/cloud/foo/v1"}: true,
},
},
Expand All @@ -820,10 +820,11 @@ func TestGenRestMethod(t *testing.T) {
{Path: "context"}: true,
{Path: "errors"}: true,
{Path: "fmt"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
{Path: "strings"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
{Path: "strings"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "google.golang.org/protobuf/encoding/protojson"}: true,
{Name: "foopb", Path: "google.golang.org/genproto/cloud/foo/v1"}: true,
},
Expand All @@ -843,7 +844,7 @@ func TestGenRestMethod(t *testing.T) {
method: lroRPC,
cfg: &generatorConfig{transports: []transport{rest}, featureEnablement: map[featureID]struct{}{OpenTelemetryTracingFeature: {}}},
imports: map[pbinfo.ImportSpec]bool{
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "bytes"}: true,
{Path: "cloud.google.com/go/longrunning"}: true,
{Path: "fmt"}: true,
Expand All @@ -860,7 +861,7 @@ func TestGenRestMethod(t *testing.T) {
imports: map[pbinfo.ImportSpec]bool{
{Path: "bytes"}: true,
{Path: "fmt"}: true,
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "google.golang.org/protobuf/encoding/protojson"}: true,
{Path: "net/url"}: true,
{Path: "regexp"}: true,
Expand All @@ -874,7 +875,7 @@ func TestGenRestMethod(t *testing.T) {
method: updateRPC,
cfg: &generatorConfig{restNumericEnum: true, featureEnablement: map[featureID]struct{}{OpenTelemetryTracingFeature: {}}},
imports: map[pbinfo.ImportSpec]bool{
{Path: "google.golang.org/grpc/metadata"}: true,
{Path: "github.com/googleapis/gax-go/v2/callctx"}: true,
{Path: "bytes"}: true,
{Path: "fmt"}: true,
{Path: "google.golang.org/protobuf/encoding/protojson"}: true,
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_GetAnotherThing.want
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *fooGRPCClient) GetAnotherThing(ctx context.Context, req *mypackagepb.In
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
opts = append((*c.CallOptions).GetAnotherThing[0:len((*c.CallOptions).GetAnotherThing):len((*c.CallOptions).GetAnotherThing)], opts...)
var resp *mypackagepb.OutputType
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_GetEmptyThing.want
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func (c *fooGRPCClient) GetEmptyThing(ctx context.Context, req *mypackagepb.Inpu
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
if req != nil && req.RequestId == nil {
req.RequestId = proto.String(uuid.NewString())
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_GetManyThings.want
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func (c *fooGRPCClient) GetManyThings(ctx context.Context, req *mypackagepb.Page
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
opts = append((*c.CallOptions).GetManyThings[0:len((*c.CallOptions).GetManyThings):len((*c.CallOptions).GetManyThings)], opts...)
it := &StringIterator{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func (c *fooGRPCClient) GetManyThingsOptional(ctx context.Context, req *mypackag
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
opts = append((*c.CallOptions).GetManyThingsOptional[0:len((*c.CallOptions).GetManyThingsOptional):len((*c.CallOptions).GetManyThingsOptional)], opts...)
it := &StringIterator{}
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_GetOneThing.want
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func (c *fooGRPCClient) GetOneThing(ctx context.Context, req *mypackagepb.InputT
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
if req != nil && req.RequestId == nil {
req.RequestId = proto.String(uuid.NewString())
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_ServerThings.want
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func (c *fooGRPCClient) ServerThings(ctx context.Context, req *mypackagepb.Input
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
opts = append((*c.CallOptions).ServerThings[0:len((*c.CallOptions).ServerThings):len((*c.CallOptions).ServerThings)], opts...)
var resp mypackagepb.Foo_ServerThingsClient
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/rest_CustomOp.want
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (c *fooRESTClient) CustomOp(ctx context.Context, req *foopb.Foo, opts ...ga
hds := append(c.xGoogHeaders, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "url.template", "/v1/foo")
ctx = callctx.WithTelemetryContext(ctx, "url_template", "/v1/foo")
}
opts = append((*c.CallOptions).CustomOp[0:len((*c.CallOptions).CustomOp):len((*c.CallOptions).CustomOp)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/rest_EmptyRPC.want
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func (c *fooRESTClient) EmptyRPC(ctx context.Context, req *foopb.Foo, opts ...ga
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "url.template", "/v1/foo/{other=*}")
ctx = callctx.WithTelemetryContext(ctx, "url_template", "/v1/foo/{other=*}")
}
return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
if settings.Path != "" {
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/rest_HttpBodyRPC.want
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func (c *fooRESTClient) HttpBodyRPC(ctx context.Context, req *foopb.Foo, opts ..
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "gcp.resource.name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
ctx = callctx.WithTelemetryContext(ctx, "resource_name", fmt.Sprintf("//foo.googleapis.com/%v", req.GetOther()))
}
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "url.template", "/v1/foo")
ctx = callctx.WithTelemetryContext(ctx, "url_template", "/v1/foo")
}
opts = append((*c.CallOptions).HttpBodyRPC[0:len((*c.CallOptions).HttpBodyRPC):len((*c.CallOptions).HttpBodyRPC)], opts...)
resp := &httpbodypb.HttpBody{}
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/rest_LongrunningRPC.want
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (c *fooRESTClient) LongrunningRPC(ctx context.Context, req *foopb.Foo, opts
hds := append(c.xGoogHeaders, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
if gax.IsFeatureEnabled("TRACING") {
ctx = metadata.AppendToOutgoingContext(ctx, "url.template", "/v1/foo")
ctx = callctx.WithTelemetryContext(ctx, "url_template", "/v1/foo")
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &longrunningpb.Operation{}
Expand Down
Loading
Loading