Skip to content

Commit c3e48e4

Browse files
committed
api: support Formatter trace tag
Signed-off-by: zirain <[email protected]>
1 parent 35e3b60 commit c3e48e4

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
@@ -2309,6 +2309,8 @@ spec:
23092309
properties:
23102310
customTags:
23112311
additionalProperties:
2312+
description: CustomTag defines a custom tag to add to each
2313+
span.
23122314
properties:
23132315
environment:
23142316
description: |-
@@ -2326,6 +2328,22 @@ spec:
23262328
required:
23272329
- name
23282330
type: object
2331+
formatter:
2332+
description: |-
2333+
Formatter adds value using formatter to each span.
2334+
It's required when the type is "Formatter".
2335+
properties:
2336+
value:
2337+
description: |-
2338+
Values defines the formatter value to use,
2339+
same formatter as HTTP access logging
2340+
(e.g. %REQUESTED_SERVER_NAME%).
2341+
Unknown specifier values are replaced
2342+
with the empty string.
2343+
type: string
2344+
required:
2345+
- value
2346+
type: object
23292347
literal:
23302348
description: |-
23312349
Literal adds hard-coded value to each span.
@@ -2361,10 +2379,23 @@ spec:
23612379
- Literal
23622380
- Environment
23632381
- RequestHeader
2382+
- Formatter
23642383
type: string
23652384
required:
23662385
- type
23672386
type: object
2387+
x-kubernetes-validations:
2388+
- message: formatter cannot be null when using Formatter
2389+
type.
2390+
rule: self.type != 'Formatter' || has(self.formatter)
2391+
- message: requestHeader cannot be null when using RequestHeader
2392+
type.
2393+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
2394+
- message: environment cannot be null when using Environment
2395+
type.
2396+
rule: self.type != 'Environment' || has(self.environment)
2397+
- message: literal cannot be null when using Literal type.
2398+
rule: self.type != 'Literal' || has(self.literal)
23682399
description: |-
23692400
CustomTags defines the custom tags to add to each span.
23702401
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
@@ -14817,6 +14817,8 @@ spec:
1481714817
properties:
1481814818
customTags:
1481914819
additionalProperties:
14820+
description: CustomTag defines a custom tag to add to each
14821+
span.
1482014822
properties:
1482114823
environment:
1482214824
description: |-
@@ -14834,6 +14836,22 @@ spec:
1483414836
required:
1483514837
- name
1483614838
type: object
14839+
formatter:
14840+
description: |-
14841+
Formatter adds value using formatter to each span.
14842+
It's required when the type is "Formatter".
14843+
properties:
14844+
value:
14845+
description: |-
14846+
Values defines the formatter value to use,
14847+
same formatter as HTTP access logging
14848+
(e.g. %REQUESTED_SERVER_NAME%).
14849+
Unknown specifier values are replaced
14850+
with the empty string.
14851+
type: string
14852+
required:
14853+
- value
14854+
type: object
1483714855
literal:
1483814856
description: |-
1483914857
Literal adds hard-coded value to each span.
@@ -14869,10 +14887,23 @@ spec:
1486914887
- Literal
1487014888
- Environment
1487114889
- RequestHeader
14890+
- Formatter
1487214891
type: string
1487314892
required:
1487414893
- type
1487514894
type: object
14895+
x-kubernetes-validations:
14896+
- message: formatter cannot be null when using Formatter
14897+
type.
14898+
rule: self.type != 'Formatter' || has(self.formatter)
14899+
- message: requestHeader cannot be null when using RequestHeader
14900+
type.
14901+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
14902+
- message: environment cannot be null when using Environment
14903+
type.
14904+
rule: self.type != 'Environment' || has(self.environment)
14905+
- message: literal cannot be null when using Literal type.
14906+
rule: self.type != 'Literal' || has(self.literal)
1487614907
description: |-
1487714908
CustomTags defines the custom tags to add to each span.
1487814909
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
@@ -2308,6 +2308,8 @@ spec:
23082308
properties:
23092309
customTags:
23102310
additionalProperties:
2311+
description: CustomTag defines a custom tag to add to each
2312+
span.
23112313
properties:
23122314
environment:
23132315
description: |-
@@ -2325,6 +2327,22 @@ spec:
23252327
required:
23262328
- name
23272329
type: object
2330+
formatter:
2331+
description: |-
2332+
Formatter adds value using formatter to each span.
2333+
It's required when the type is "Formatter".
2334+
properties:
2335+
value:
2336+
description: |-
2337+
Values defines the formatter value to use,
2338+
same formatter as HTTP access logging
2339+
(e.g. %REQUESTED_SERVER_NAME%).
2340+
Unknown specifier values are replaced
2341+
with the empty string.
2342+
type: string
2343+
required:
2344+
- value
2345+
type: object
23282346
literal:
23292347
description: |-
23302348
Literal adds hard-coded value to each span.
@@ -2360,10 +2378,23 @@ spec:
23602378
- Literal
23612379
- Environment
23622380
- RequestHeader
2381+
- Formatter
23632382
type: string
23642383
required:
23652384
- type
23662385
type: object
2386+
x-kubernetes-validations:
2387+
- message: formatter cannot be null when using Formatter
2388+
type.
2389+
rule: self.type != 'Formatter' || has(self.formatter)
2390+
- message: requestHeader cannot be null when using RequestHeader
2391+
type.
2392+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
2393+
- message: environment cannot be null when using Environment
2394+
type.
2395+
rule: self.type != 'Environment' || has(self.environment)
2396+
- message: literal cannot be null when using Literal type.
2397+
rule: self.type != 'Literal' || has(self.literal)
23672398
description: |-
23682399
CustomTags defines the custom tags to add to each span.
23692400
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
@@ -14816,6 +14816,8 @@ spec:
1481614816
properties:
1481714817
customTags:
1481814818
additionalProperties:
14819+
description: CustomTag defines a custom tag to add to each
14820+
span.
1481914821
properties:
1482014822
environment:
1482114823
description: |-
@@ -14833,6 +14835,22 @@ spec:
1483314835
required:
1483414836
- name
1483514837
type: object
14838+
formatter:
14839+
description: |-
14840+
Formatter adds value using formatter to each span.
14841+
It's required when the type is "Formatter".
14842+
properties:
14843+
value:
14844+
description: |-
14845+
Values defines the formatter value to use,
14846+
same formatter as HTTP access logging
14847+
(e.g. %REQUESTED_SERVER_NAME%).
14848+
Unknown specifier values are replaced
14849+
with the empty string.
14850+
type: string
14851+
required:
14852+
- value
14853+
type: object
1483614854
literal:
1483714855
description: |-
1483814856
Literal adds hard-coded value to each span.
@@ -14868,10 +14886,23 @@ spec:
1486814886
- Literal
1486914887
- Environment
1487014888
- RequestHeader
14889+
- Formatter
1487114890
type: string
1487214891
required:
1487314892
- type
1487414893
type: object
14894+
x-kubernetes-validations:
14895+
- message: formatter cannot be null when using Formatter
14896+
type.
14897+
rule: self.type != 'Formatter' || has(self.formatter)
14898+
- message: requestHeader cannot be null when using RequestHeader
14899+
type.
14900+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
14901+
- message: environment cannot be null when using Environment
14902+
type.
14903+
rule: self.type != 'Environment' || has(self.environment)
14904+
- message: literal cannot be null when using Literal type.
14905+
rule: self.type != 'Literal' || has(self.literal)
1487514906
description: |-
1487614907
CustomTags defines the custom tags to add to each span.
1487714908
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
@@ -1098,7 +1098,7 @@ _Appears in:_
10981098

10991099

11001100

1101-
1101+
CustomTag defines a custom tag to add to each span.
11021102

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

11141115

11151116
#### CustomTagType
@@ -1126,6 +1127,7 @@ _Appears in:_
11261127
| `Literal` | CustomTagTypeLiteral adds hard-coded value to each span.<br /> |
11271128
| `Environment` | CustomTagTypeEnvironment adds value from environment variable to each span.<br /> |
11281129
| `RequestHeader` | CustomTagTypeRequestHeader adds value from request header to each span.<br /> |
1130+
| `Formatter` | CustomTagTypeFormatter adds value using formatter to each span.<br /> |
11291131

11301132

11311133
#### DNS
@@ -2147,6 +2149,20 @@ _Appears in:_
21472149
| --- | --- | --- | --- | --- |
21482150

21492151

2152+
#### FormatterCustomTag
2153+
2154+
2155+
2156+
2157+
2158+
_Appears in:_
2159+
- [CustomTag](#customtag)
2160+
2161+
| Field | Type | Required | Default | Description |
2162+
| --- | --- | --- | --- | --- |
2163+
| `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. |
2164+
2165+
21502166
#### GRPCActiveHealthChecker
21512167

21522168

0 commit comments

Comments
 (0)