Skip to content

Commit 26036d5

Browse files
committed
api: support Formatter trace tag
Signed-off-by: zirain <[email protected]>
1 parent f65d853 commit 26036d5

File tree

10 files changed

+408
-2
lines changed

10 files changed

+408
-2
lines changed

api/v1alpha1/envoyproxy_tracing_types.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@ const (
9494
CustomTagTypeEnvironment CustomTagType = "Environment"
9595
// CustomTagTypeRequestHeader adds value from request header to each span.
9696
CustomTagTypeRequestHeader CustomTagType = "RequestHeader"
97+
// CustomTagTypeFormatter adds value using formatter to each span.
98+
CustomTagTypeFormatter CustomTagType = "Formatter"
9799
)
98100

101+
// CustomTag defines a custom tag to add to each span.
102+
//
103+
// +kubebuilder:validation:XValidation:message="formatter cannot be null when using Formatter type.",rule="self.type != 'Formatter' || has(self.formatter)"
104+
// +kubebuilder:validation:XValidation:message="requestHeader cannot be null when using RequestHeader type.",rule="self.type != 'RequestHeader' || has(self.requestHeader)"
105+
// +kubebuilder:validation:XValidation:message="environment cannot be null when using Environment type.",rule="self.type != 'Environment' || has(self.environment)"
106+
// +kubebuilder:validation:XValidation:message="literal cannot be null when using Literal type.",rule="self.type != 'Literal' || has(self.literal)"
99107
type CustomTag struct {
100108
// Type defines the type of custom tag.
101-
// +kubebuilder:validation:Enum=Literal;Environment;RequestHeader
109+
// +kubebuilder:validation:Enum=Literal;Environment;RequestHeader;Formatter
102110
// +unionDiscriminator
103111
// +kubebuilder:default=Literal
104112
Type CustomTagType `json:"type"`
@@ -111,6 +119,10 @@ type CustomTag struct {
111119
// RequestHeader adds value from request header to each span.
112120
// It's required when the type is "RequestHeader".
113121
RequestHeader *RequestHeaderCustomTag `json:"requestHeader,omitempty"`
122+
// Formatter adds value using formatter to each span.
123+
// It's required when the type is "Formatter".
124+
// +optional
125+
Formatter *FormatterCustomTag `json:"formatter,omitempty"`
114126

115127
// TODO: add support for Metadata tags in the future.
116128
// EG currently doesn't support metadata for route or cluster.
@@ -140,6 +152,15 @@ type RequestHeaderCustomTag struct {
140152
DefaultValue *string `json:"defaultValue,omitempty"`
141153
}
142154

155+
type FormatterCustomTag struct {
156+
// Values defines the formatter value to use,
157+
// same formatter as HTTP access logging
158+
// (e.g. %REQUESTED_SERVER_NAME%).
159+
// Unknown specifier values are replaced
160+
// with the empty string.
161+
Value string `json:"value"`
162+
}
163+
143164
// ZipkinTracingProvider defines the Zipkin tracing provider configuration.
144165
type ZipkinTracingProvider struct {
145166
// Enable128BitTraceID determines whether a 128bit trace id will be used

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,8 @@ spec:
22882288
properties:
22892289
customTags:
22902290
additionalProperties:
2291+
description: CustomTag defines a custom tag to add to each
2292+
span.
22912293
properties:
22922294
environment:
22932295
description: |-
@@ -2305,6 +2307,22 @@ spec:
23052307
required:
23062308
- name
23072309
type: object
2310+
formatter:
2311+
description: |-
2312+
Formatter adds value using formatter to each span.
2313+
It's required when the type is "Formatter".
2314+
properties:
2315+
value:
2316+
description: |-
2317+
Values defines the formatter value to use,
2318+
same formatter as HTTP access logging
2319+
(e.g. %REQUESTED_SERVER_NAME%).
2320+
Unknown specifier values are replaced
2321+
with the empty string.
2322+
type: string
2323+
required:
2324+
- value
2325+
type: object
23082326
literal:
23092327
description: |-
23102328
Literal adds hard-coded value to each span.
@@ -2340,10 +2358,23 @@ spec:
23402358
- Literal
23412359
- Environment
23422360
- RequestHeader
2361+
- Formatter
23432362
type: string
23442363
required:
23452364
- type
23462365
type: object
2366+
x-kubernetes-validations:
2367+
- message: formatter cannot be null when using Formatter
2368+
type.
2369+
rule: self.type != 'Formatter' || has(self.formatter)
2370+
- message: requestHeader cannot be null when using RequestHeader
2371+
type.
2372+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
2373+
- message: environment cannot be null when using Environment
2374+
type.
2375+
rule: self.type != 'Environment' || has(self.environment)
2376+
- message: literal cannot be null when using Literal type.
2377+
rule: self.type != 'Literal' || has(self.literal)
23472378
description: |-
23482379
CustomTags defines the custom tags to add to each span.
23492380
If provider is kubernetes, pod name and namespace are added by default.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_envoyproxies.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14683,6 +14683,8 @@ spec:
1468314683
properties:
1468414684
customTags:
1468514685
additionalProperties:
14686+
description: CustomTag defines a custom tag to add to each
14687+
span.
1468614688
properties:
1468714689
environment:
1468814690
description: |-
@@ -14700,6 +14702,22 @@ spec:
1470014702
required:
1470114703
- name
1470214704
type: object
14705+
formatter:
14706+
description: |-
14707+
Formatter adds value using formatter to each span.
14708+
It's required when the type is "Formatter".
14709+
properties:
14710+
value:
14711+
description: |-
14712+
Values defines the formatter value to use,
14713+
same formatter as HTTP access logging
14714+
(e.g. %REQUESTED_SERVER_NAME%).
14715+
Unknown specifier values are replaced
14716+
with the empty string.
14717+
type: string
14718+
required:
14719+
- value
14720+
type: object
1470314721
literal:
1470414722
description: |-
1470514723
Literal adds hard-coded value to each span.
@@ -14735,10 +14753,23 @@ spec:
1473514753
- Literal
1473614754
- Environment
1473714755
- RequestHeader
14756+
- Formatter
1473814757
type: string
1473914758
required:
1474014759
- type
1474114760
type: object
14761+
x-kubernetes-validations:
14762+
- message: formatter cannot be null when using Formatter
14763+
type.
14764+
rule: self.type != 'Formatter' || has(self.formatter)
14765+
- message: requestHeader cannot be null when using RequestHeader
14766+
type.
14767+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
14768+
- message: environment cannot be null when using Environment
14769+
type.
14770+
rule: self.type != 'Environment' || has(self.environment)
14771+
- message: literal cannot be null when using Literal type.
14772+
rule: self.type != 'Literal' || has(self.literal)
1474214773
description: |-
1474314774
CustomTags defines the custom tags to add to each span.
1474414775
If provider is kubernetes, pod name and namespace are added by default.

charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,8 @@ spec:
22872287
properties:
22882288
customTags:
22892289
additionalProperties:
2290+
description: CustomTag defines a custom tag to add to each
2291+
span.
22902292
properties:
22912293
environment:
22922294
description: |-
@@ -2304,6 +2306,22 @@ spec:
23042306
required:
23052307
- name
23062308
type: object
2309+
formatter:
2310+
description: |-
2311+
Formatter adds value using formatter to each span.
2312+
It's required when the type is "Formatter".
2313+
properties:
2314+
value:
2315+
description: |-
2316+
Values defines the formatter value to use,
2317+
same formatter as HTTP access logging
2318+
(e.g. %REQUESTED_SERVER_NAME%).
2319+
Unknown specifier values are replaced
2320+
with the empty string.
2321+
type: string
2322+
required:
2323+
- value
2324+
type: object
23072325
literal:
23082326
description: |-
23092327
Literal adds hard-coded value to each span.
@@ -2339,10 +2357,23 @@ spec:
23392357
- Literal
23402358
- Environment
23412359
- RequestHeader
2360+
- Formatter
23422361
type: string
23432362
required:
23442363
- type
23452364
type: object
2365+
x-kubernetes-validations:
2366+
- message: formatter cannot be null when using Formatter
2367+
type.
2368+
rule: self.type != 'Formatter' || has(self.formatter)
2369+
- message: requestHeader cannot be null when using RequestHeader
2370+
type.
2371+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
2372+
- message: environment cannot be null when using Environment
2373+
type.
2374+
rule: self.type != 'Environment' || has(self.environment)
2375+
- message: literal cannot be null when using Literal type.
2376+
rule: self.type != 'Literal' || has(self.literal)
23462377
description: |-
23472378
CustomTags defines the custom tags to add to each span.
23482379
If provider is kubernetes, pod name and namespace are added by default.

charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14682,6 +14682,8 @@ spec:
1468214682
properties:
1468314683
customTags:
1468414684
additionalProperties:
14685+
description: CustomTag defines a custom tag to add to each
14686+
span.
1468514687
properties:
1468614688
environment:
1468714689
description: |-
@@ -14699,6 +14701,22 @@ spec:
1469914701
required:
1470014702
- name
1470114703
type: object
14704+
formatter:
14705+
description: |-
14706+
Formatter adds value using formatter to each span.
14707+
It's required when the type is "Formatter".
14708+
properties:
14709+
value:
14710+
description: |-
14711+
Values defines the formatter value to use,
14712+
same formatter as HTTP access logging
14713+
(e.g. %REQUESTED_SERVER_NAME%).
14714+
Unknown specifier values are replaced
14715+
with the empty string.
14716+
type: string
14717+
required:
14718+
- value
14719+
type: object
1470214720
literal:
1470314721
description: |-
1470414722
Literal adds hard-coded value to each span.
@@ -14734,10 +14752,23 @@ spec:
1473414752
- Literal
1473514753
- Environment
1473614754
- RequestHeader
14755+
- Formatter
1473714756
type: string
1473814757
required:
1473914758
- type
1474014759
type: object
14760+
x-kubernetes-validations:
14761+
- message: formatter cannot be null when using Formatter
14762+
type.
14763+
rule: self.type != 'Formatter' || has(self.formatter)
14764+
- message: requestHeader cannot be null when using RequestHeader
14765+
type.
14766+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
14767+
- message: environment cannot be null when using Environment
14768+
type.
14769+
rule: self.type != 'Environment' || has(self.environment)
14770+
- message: literal cannot be null when using Literal type.
14771+
rule: self.type != 'Literal' || has(self.literal)
1474114772
description: |-
1474214773
CustomTags defines the custom tags to add to each span.
1474314774
If provider is kubernetes, pod name and namespace are added by default.

site/content/en/latest/api/extension_types.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ _Appears in:_
10951095

10961096

10971097

1098-
1098+
CustomTag defines a custom tag to add to each span.
10991099

11001100
_Appears in:_
11011101
- [ProxyTracing](#proxytracing)
@@ -1107,6 +1107,7 @@ _Appears in:_
11071107
| `literal` | _[LiteralCustomTag](#literalcustomtag)_ | true | | Literal adds hard-coded value to each span.<br />It's required when the type is "Literal". |
11081108
| `environment` | _[EnvironmentCustomTag](#environmentcustomtag)_ | true | | Environment adds value from environment variable to each span.<br />It's required when the type is "Environment". |
11091109
| `requestHeader` | _[RequestHeaderCustomTag](#requestheadercustomtag)_ | true | | RequestHeader adds value from request header to each span.<br />It's required when the type is "RequestHeader". |
1110+
| `formatter` | _[FormatterCustomTag](#formattercustomtag)_ | false | | Formatter adds value using formatter to each span.<br />It's required when the type is "Formatter". |
11101111

11111112

11121113
#### CustomTagType
@@ -1123,6 +1124,7 @@ _Appears in:_
11231124
| `Literal` | CustomTagTypeLiteral adds hard-coded value to each span.<br /> |
11241125
| `Environment` | CustomTagTypeEnvironment adds value from environment variable to each span.<br /> |
11251126
| `RequestHeader` | CustomTagTypeRequestHeader adds value from request header to each span.<br /> |
1127+
| `Formatter` | CustomTagTypeFormatter adds value using formatter to each span.<br /> |
11261128

11271129

11281130
#### DNS
@@ -2144,6 +2146,20 @@ _Appears in:_
21442146
| --- | --- | --- | --- | --- |
21452147

21462148

2149+
#### FormatterCustomTag
2150+
2151+
2152+
2153+
2154+
2155+
_Appears in:_
2156+
- [CustomTag](#customtag)
2157+
2158+
| Field | Type | Required | Default | Description |
2159+
| --- | --- | --- | --- | --- |
2160+
| `value` | _string_ | true | | Values defines the formatter value to use,<br />same formatter as HTTP access logging<br />(e.g. %REQUESTED_SERVER_NAME%).<br />Unknown specifier values are replaced<br />with the empty string. |
2161+
2162+
21472163
#### GRPCActiveHealthChecker
21482164

21492165

0 commit comments

Comments
 (0)