Skip to content

Commit

Permalink
Fix nits
Browse files Browse the repository at this point in the history
Simplification in listener v3 to be tested.

Signed-off-by: Paul Salaberria <[email protected]>
  • Loading branch information
psalaberria002 committed Jun 9, 2022
1 parent 83d2f0b commit 8dbe260
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
4 changes: 4 additions & 0 deletions manifests/emissary/emissary-crds.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3756,6 +3756,8 @@ spec:
type: array
v3CustomTags:
items:
description: TracingCustomTag provides a data structure for capturing
envoy's `type.tracing.v3.CustomTag`
properties:
environment:
description: Environment explicitly specifies the protocol stack
Expand Down Expand Up @@ -3870,6 +3872,8 @@ spec:
type: object
custom_tags:
items:
description: TracingCustomTag provides a data structure for capturing
envoy's `type.tracing.v3.CustomTag`
properties:
environment:
description: Environment explicitly specifies the protocol stack
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/getambassador.io/v2/handwritten.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ func Convert_v2_TracingServiceSpec_To_v3alpha1_TracingServiceSpec(in *TracingSer
// WARNING: in.TagHeaders requires manual conversion: does not exist in peer-type
// if only tag_headers are set, translate to custom_tags.
// if both are set, ignore tag_headers.
if in.TagHeaders != nil && in.V3CustomTags == nil {
if in.TagHeaders != nil && in.V3CustomTags == nil {
out.CustomTags = []v3alpha1.TracingCustomTag{}
for _, tag := range in.TagHeaders {
out.CustomTags = append(out.CustomTags, v3alpha1.TracingCustomTag{
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/getambassador.io/v3alpha1/crd_tracingservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,27 @@ type TraceConfig struct {
ServiceName string `json:"service_name,omitempty"`
}

// TracingCustomTagTypeLiteral provides a data structure for capturing envoy's `type.tracing.v3.CustomTag.Literal`
type TracingCustomTagTypeLiteral struct {
// +kubebuilder:validation:Required
Value string `json:"value"`
}

// TracingCustomTagTypeEnvironment provides a data structure for capturing envoy's `type.tracing.v3.CustomTag.Environment`
type TracingCustomTagTypeEnvironment struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
DefaultValue *string `json:"default_value,omitempty"`
}

// TracingCustomTagTypeRequestHeader provides a data structure for capturing envoy's `type.tracing.v3.CustomTag.Header`
type TracingCustomTagTypeRequestHeader struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
DefaultValue *string `json:"default_value,omitempty"`
}

// TracingCustomTag provides a data structure for capturing envoy's `type.tracing.v3.CustomTag`
type TracingCustomTag struct {
// +kubebuilder:validation:Required
Tag string `json:"tag"`
Expand Down
17 changes: 2 additions & 15 deletions python/ambassador/envoy/v3/v3listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,22 +447,9 @@ def base_http_config(self) -> Dict[str, Any]:
base_http_config["tracing"] = {}
self.traffic_direction = "OUTBOUND"

finalCustomTags = []
custom_tags = self.config.ir.tracing.get('custom_tags', [])
req_hdrs = self.config.ir.tracing.get('tag_headers', [])
if custom_tags or req_hdrs:
finalCustomTags += custom_tags
if req_hdrs:
for hdr in req_hdrs:
custom_tag = {
"request_header": {
"name": hdr,
},
"tag": hdr,
}
finalCustomTags.append(custom_tag)
base_http_config["tracing"]["custom_tags"] = finalCustomTags

if custom_tags:
base_http_config["tracing"]["custom_tags"] = custom_tags

sampling = self.config.ir.tracing.get('sampling', {})
if sampling:
Expand Down
1 change: 1 addition & 0 deletions python/ambassador/ir/irtracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class IRTracing(IRResource):
service: str
driver: str
driver_config: dict
# TODO: tag_headers is deprecated and should be removed once migrated to CRD v3
tag_headers: list
custom_tags: list
host_rewrite: Optional[str]
Expand Down

0 comments on commit 8dbe260

Please sign in to comment.