Skip to content

Commit

Permalink
Backport propagate opt (#3961)
Browse files Browse the repository at this point in the history
* cherry pick - adding propagate option
* adding changelog for tracing propagate
* update change log
  • Loading branch information
asayah committed Dec 8, 2020
1 parent 7635326 commit 841f938
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 36 deletions.
6 changes: 6 additions & 0 deletions changelog/v1.5.13/backport-tracing-propagate-opts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/gloo/issues/3931
description: >
Add the ability to configure the propagation of the tracing header x-envoy-decorator-operation, for me info:
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto.html?highlight=decorator#config-route-v3-decorator
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ See here for additional information about configuring tracing with Gloo: https:/
```yaml
"routeDescriptor": string
"tracePercentages": .tracing.options.gloo.solo.io.TracePercentages
"propagate": .google.protobuf.BoolValue

```

| Field | Type | Description | Default |
| ----- | ---- | ----------- |----------- |
| `routeDescriptor` | `string` | Optional. If set, will be used to identify the route that produced the trace. Note that this value will be overridden if the "x-envoy-decorator-operation" header is passed. | |
| `tracePercentages` | [.tracing.options.gloo.solo.io.TracePercentages](../tracing.proto.sk/#tracepercentages) | Requests can produce traces by random sampling or when the `x-client-trace-id` header is provided. TracePercentages defines the limits for random, forced, and overall tracing percentages. | |
| `propagate` | [.google.protobuf.BoolValue](https://developers.google.com/protocol-buffers/docs/reference/csharp/class/google/protobuf/well-known-types/bool-value) | Optional. Default is true, If set to false, the tracing headers will not propagate to the upstream. | |



Expand Down
2 changes: 2 additions & 0 deletions projects/gloo/api/v1/options/tracing/tracing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ message RouteTracingSettings {
// Requests can produce traces by random sampling or when the `x-client-trace-id` header is provided.
// TracePercentages defines the limits for random, forced, and overall tracing percentages.
TracePercentages trace_percentages = 2;
// Optional. Default is true, If set to false, the tracing headers will not propagate to the upstream.
google.protobuf.BoolValue propagate = 3;
}

// Requests can produce traces by random sampling or when the `x-client-trace-id` header is provided.
Expand Down
77 changes: 45 additions & 32 deletions projects/gloo/pkg/api/v1/options/tracing/tracing.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions projects/gloo/pkg/api/v1/options/tracing/tracing.pb.hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions projects/gloo/pkg/plugins/tracing/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
envoytracing "github.com/envoyproxy/go-control-plane/envoy/type/tracing/v3"
envoy_type "github.com/envoyproxy/go-control-plane/envoy/type/v3"
"github.com/gogo/protobuf/types"
"github.com/solo-io/gloo/pkg/utils/gogoutils"
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/hcm"
"github.com/solo-io/gloo/projects/gloo/pkg/plugins"
Expand Down Expand Up @@ -111,6 +112,7 @@ func (p *Plugin) ProcessRoute(params plugins.RouteParams, in *v1.Route, out *env
if descriptor != "" {
out.Decorator = &envoyroute.Decorator{
Operation: descriptor,
Propagate: gogoutils.BoolGogoToProto(in.Options.Tracing.GetPropagate()),
}
}
return nil
Expand Down
10 changes: 6 additions & 4 deletions projects/gloo/pkg/plugins/tracing/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
envoytracing "github.com/envoyproxy/go-control-plane/envoy/type/tracing/v3"
envoy_type "github.com/envoyproxy/go-control-plane/envoy/type/v3"
"github.com/gogo/protobuf/types"
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/hcm"
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/tracing"

"github.com/golang/protobuf/ptypes/wrappers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/hcm"
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/tracing"
"github.com/solo-io/gloo/projects/gloo/pkg/plugins"
)

Expand Down Expand Up @@ -93,13 +92,15 @@ var _ = Describe("Plugin", func() {
Options: &v1.RouteOptions{
Tracing: &tracing.RouteTracingSettings{
RouteDescriptor: "hello",
Propagate: &types.BoolValue{Value: false},
},
},
}
outFull := &envoyroute.Route{}
err = p.ProcessRoute(plugins.RouteParams{}, inFull, outFull)
Expect(err).NotTo(HaveOccurred())
Expect(outFull.Decorator.Operation).To(Equal("hello"))
Expect(outFull.Decorator.Propagate).To(Equal(&wrappers.BoolValue{Value: false}))
Expect(outFull.Tracing.ClientSampling.Numerator / 10000).To(Equal(uint32(100)))
Expect(outFull.Tracing.RandomSampling.Numerator / 10000).To(Equal(uint32(100)))
Expect(outFull.Tracing.OverallSampling.Numerator / 10000).To(Equal(uint32(100)))
Expand Down Expand Up @@ -128,6 +129,7 @@ var _ = Describe("Plugin", func() {
err = p.ProcessRoute(plugins.RouteParams{}, inFull, outFull)
Expect(err).NotTo(HaveOccurred())
Expect(outFull.Decorator.Operation).To(Equal("hello"))
Expect(outFull.Decorator.Propagate).To(BeNil())
Expect(outFull.Tracing.ClientSampling.Numerator / 10000).To(Equal(uint32(10)))
Expect(outFull.Tracing.RandomSampling.Numerator / 10000).To(Equal(uint32(20)))
Expect(outFull.Tracing.OverallSampling.Numerator / 10000).To(Equal(uint32(30)))
Expand Down

0 comments on commit 841f938

Please sign in to comment.