Skip to content

Commit b76ee09

Browse files
committed
api: support Formatter trace tag
Signed-off-by: zirain <[email protected]>
1 parent 7fb3254 commit b76ee09

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
@@ -14743,6 +14743,8 @@ spec:
1474314743
properties:
1474414744
customTags:
1474514745
additionalProperties:
14746+
description: CustomTag defines a custom tag to add to each
14747+
span.
1474614748
properties:
1474714749
environment:
1474814750
description: |-
@@ -14760,6 +14762,22 @@ spec:
1476014762
required:
1476114763
- name
1476214764
type: object
14765+
formatter:
14766+
description: |-
14767+
Formatter adds value using formatter to each span.
14768+
It's required when the type is "Formatter".
14769+
properties:
14770+
value:
14771+
description: |-
14772+
Values defines the formatter value to use,
14773+
same formatter as HTTP access logging
14774+
(e.g. %REQUESTED_SERVER_NAME%).
14775+
Unknown specifier values are replaced
14776+
with the empty string.
14777+
type: string
14778+
required:
14779+
- value
14780+
type: object
1476314781
literal:
1476414782
description: |-
1476514783
Literal adds hard-coded value to each span.
@@ -14795,10 +14813,23 @@ spec:
1479514813
- Literal
1479614814
- Environment
1479714815
- RequestHeader
14816+
- Formatter
1479814817
type: string
1479914818
required:
1480014819
- type
1480114820
type: object
14821+
x-kubernetes-validations:
14822+
- message: formatter cannot be null when using Formatter
14823+
type.
14824+
rule: self.type != 'Formatter' || has(self.formatter)
14825+
- message: requestHeader cannot be null when using RequestHeader
14826+
type.
14827+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
14828+
- message: environment cannot be null when using Environment
14829+
type.
14830+
rule: self.type != 'Environment' || has(self.environment)
14831+
- message: literal cannot be null when using Literal type.
14832+
rule: self.type != 'Literal' || has(self.literal)
1480214833
description: |-
1480314834
CustomTags defines the custom tags to add to each span.
1480414835
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
@@ -14742,6 +14742,8 @@ spec:
1474214742
properties:
1474314743
customTags:
1474414744
additionalProperties:
14745+
description: CustomTag defines a custom tag to add to each
14746+
span.
1474514747
properties:
1474614748
environment:
1474714749
description: |-
@@ -14759,6 +14761,22 @@ spec:
1475914761
required:
1476014762
- name
1476114763
type: object
14764+
formatter:
14765+
description: |-
14766+
Formatter adds value using formatter to each span.
14767+
It's required when the type is "Formatter".
14768+
properties:
14769+
value:
14770+
description: |-
14771+
Values defines the formatter value to use,
14772+
same formatter as HTTP access logging
14773+
(e.g. %REQUESTED_SERVER_NAME%).
14774+
Unknown specifier values are replaced
14775+
with the empty string.
14776+
type: string
14777+
required:
14778+
- value
14779+
type: object
1476214780
literal:
1476314781
description: |-
1476414782
Literal adds hard-coded value to each span.
@@ -14794,10 +14812,23 @@ spec:
1479414812
- Literal
1479514813
- Environment
1479614814
- RequestHeader
14815+
- Formatter
1479714816
type: string
1479814817
required:
1479914818
- type
1480014819
type: object
14820+
x-kubernetes-validations:
14821+
- message: formatter cannot be null when using Formatter
14822+
type.
14823+
rule: self.type != 'Formatter' || has(self.formatter)
14824+
- message: requestHeader cannot be null when using RequestHeader
14825+
type.
14826+
rule: self.type != 'RequestHeader' || has(self.requestHeader)
14827+
- message: environment cannot be null when using Environment
14828+
type.
14829+
rule: self.type != 'Environment' || has(self.environment)
14830+
- message: literal cannot be null when using Literal type.
14831+
rule: self.type != 'Literal' || has(self.literal)
1480114832
description: |-
1480214833
CustomTags defines the custom tags to add to each span.
1480314834
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
@@ -1096,7 +1096,7 @@ _Appears in:_
10961096

10971097

10981098

1099-
1099+
CustomTag defines a custom tag to add to each span.
11001100

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

11121113

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

11281130

11291131
#### DNS
@@ -2145,6 +2147,20 @@ _Appears in:_
21452147
| --- | --- | --- | --- | --- |
21462148

21472149

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

21502166

0 commit comments

Comments
 (0)