Skip to content

Commit 2f212c6

Browse files
committed
api: support Formatter trace tag
Signed-off-by: zirain <[email protected]>
1 parent d1b87c0 commit 2f212c6

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
@@ -2271,6 +2271,8 @@ spec:
22712271
properties:
22722272
customTags:
22732273
additionalProperties:
2274+
description: CustomTag defines a custom tag to add to each
2275+
span.
22742276
properties:
22752277
environment:
22762278
description: |-
@@ -2288,6 +2290,22 @@ spec:
22882290
required:
22892291
- name
22902292
type: object
2293+
formatter:
2294+
description: |-
2295+
Formatter adds value using formatter to each span.
2296+
It's required when the type is "Formatter".
2297+
properties:
2298+
value:
2299+
description: |-
2300+
Values defines the formatter value to use,
2301+
same formatter as HTTP access logging
2302+
(e.g. %REQUESTED_SERVER_NAME%).
2303+
Unknown specifier values are replaced
2304+
with the empty string.
2305+
type: string
2306+
required:
2307+
- value
2308+
type: object
22912309
literal:
22922310
description: |-
22932311
Literal adds hard-coded value to each span.
@@ -2323,10 +2341,23 @@ spec:
23232341
- Literal
23242342
- Environment
23252343
- RequestHeader
2344+
- Formatter
23262345
type: string
23272346
required:
23282347
- type
23292348
type: object
2349+
x-kubernetes-validations:
2350+
- message: formatter cannot be null when using Formatter
2351+
type.
2352+
rule: self.type != 'Formatter' || has(self.formatter)
2353+
- message: requestHeader cannot be null when using RequestHeader
2354+
type.
2355+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
2356+
- message: environment cannot be null when using Environment
2357+
type.
2358+
rule: self.type != 'Environment' || has(self.environment)
2359+
- message: literal cannot be null when using Literal type.
2360+
rule: self.type != 'Literal' || has(self.literal)
23302361
description: |-
23312362
CustomTags defines the custom tags to add to each span.
23322363
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
@@ -2270,6 +2270,8 @@ spec:
22702270
properties:
22712271
customTags:
22722272
additionalProperties:
2273+
description: CustomTag defines a custom tag to add to each
2274+
span.
22732275
properties:
22742276
environment:
22752277
description: |-
@@ -2287,6 +2289,22 @@ spec:
22872289
required:
22882290
- name
22892291
type: object
2292+
formatter:
2293+
description: |-
2294+
Formatter adds value using formatter to each span.
2295+
It's required when the type is "Formatter".
2296+
properties:
2297+
value:
2298+
description: |-
2299+
Values defines the formatter value to use,
2300+
same formatter as HTTP access logging
2301+
(e.g. %REQUESTED_SERVER_NAME%).
2302+
Unknown specifier values are replaced
2303+
with the empty string.
2304+
type: string
2305+
required:
2306+
- value
2307+
type: object
22902308
literal:
22912309
description: |-
22922310
Literal adds hard-coded value to each span.
@@ -2322,10 +2340,23 @@ spec:
23222340
- Literal
23232341
- Environment
23242342
- RequestHeader
2343+
- Formatter
23252344
type: string
23262345
required:
23272346
- type
23282347
type: object
2348+
x-kubernetes-validations:
2349+
- message: formatter cannot be null when using Formatter
2350+
type.
2351+
rule: self.type != 'Formatter' || has(self.formatter)
2352+
- message: requestHeader cannot be null when using RequestHeader
2353+
type.
2354+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
2355+
- message: environment cannot be null when using Environment
2356+
type.
2357+
rule: self.type != 'Environment' || has(self.environment)
2358+
- message: literal cannot be null when using Literal type.
2359+
rule: self.type != 'Literal' || has(self.literal)
23292360
description: |-
23302361
CustomTags defines the custom tags to add to each span.
23312362
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
@@ -1080,7 +1080,7 @@ _Appears in:_
10801080

10811081

10821082

1083-
1083+
CustomTag defines a custom tag to add to each span.
10841084

10851085
_Appears in:_
10861086
- [ProxyTracing](#proxytracing)
@@ -1092,6 +1092,7 @@ _Appears in:_
10921092
| `literal` | _[LiteralCustomTag](#literalcustomtag)_ | true | | Literal adds hard-coded value to each span.<br />It's required when the type is "Literal". |
10931093
| `environment` | _[EnvironmentCustomTag](#environmentcustomtag)_ | true | | Environment adds value from environment variable to each span.<br />It's required when the type is "Environment". |
10941094
| `requestHeader` | _[RequestHeaderCustomTag](#requestheadercustomtag)_ | true | | RequestHeader adds value from request header to each span.<br />It's required when the type is "RequestHeader". |
1095+
| `formatter` | _[FormatterCustomTag](#formattercustomtag)_ | false | | Formatter adds value using formatter to each span.<br />It's required when the type is "Formatter". |
10951096

10961097

10971098
#### CustomTagType
@@ -1108,6 +1109,7 @@ _Appears in:_
11081109
| `Literal` | CustomTagTypeLiteral adds hard-coded value to each span.<br /> |
11091110
| `Environment` | CustomTagTypeEnvironment adds value from environment variable to each span.<br /> |
11101111
| `RequestHeader` | CustomTagTypeRequestHeader adds value from request header to each span.<br /> |
1112+
| `Formatter` | CustomTagTypeFormatter adds value using formatter to each span.<br /> |
11111113

11121114

11131115
#### DNS
@@ -2113,6 +2115,20 @@ _Appears in:_
21132115
| --- | --- | --- | --- | --- |
21142116

21152117

2118+
#### FormatterCustomTag
2119+
2120+
2121+
2122+
2123+
2124+
_Appears in:_
2125+
- [CustomTag](#customtag)
2126+
2127+
| Field | Type | Required | Default | Description |
2128+
| --- | --- | --- | --- | --- |
2129+
| `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. |
2130+
2131+
21162132
#### GRPCActiveHealthChecker
21172133

21182134

0 commit comments

Comments
 (0)