Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,41 @@ func (t *Translator) buildTrafficFeatures(policy *egv1a1.BackendTrafficPolicy) (
RequestBuffer: rb,
Compression: cp,
HTTPUpgrade: httpUpgrade,
Telemetry: policy.Spec.Telemetry,
Telemetry: buildBackendTelemetry(policy.Spec.Telemetry),
}, errs
}

func buildBackendTelemetry(telemetry *egv1a1.BackendTelemetry) *ir.BackendTelemetry {
if telemetry == nil {
return nil
}
return &ir.BackendTelemetry{
Tracing: buildBackendTracing(telemetry.Tracing),
Metrics: buildBackendMetrics(telemetry.Metrics),
}
}

func buildBackendTracing(tracing *egv1a1.Tracing) *ir.BackendTracing {
if tracing == nil {
return nil
}
return &ir.BackendTracing{
SamplingFraction: tracing.SamplingFraction,
CustomTags: ir.CustomTagMapToSlice(tracing.CustomTags),
Tags: ir.MapToSlice(tracing.Tags),
SpanName: tracing.SpanName,
}
}

func buildBackendMetrics(metrics *egv1a1.BackendMetrics) *ir.BackendMetrics {
if metrics == nil {
return nil
}
return &ir.BackendMetrics{
RouteStatName: metrics.RouteStatName,
}
}

func (t *Translator) translateBackendTrafficPolicyForGateway(
policy *egv1a1.BackendTrafficPolicy, target gwapiv1.LocalPolicyTargetReferenceWithSectionName,
gateway *GatewayContext, xdsIR resource.XdsIRMap,
Expand Down
18 changes: 9 additions & 9 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func buildListenerMetadata(listener *ListenerContext, gateway *GatewayContext) *
Kind: gateway.GetObjectKind().GroupVersionKind().Kind,
Name: gateway.GetName(),
Namespace: gateway.GetNamespace(),
Annotations: filterEGPrefix(gateway.GetAnnotations()),
Annotations: ir.MapToSlice(filterEGPrefix(gateway.GetAnnotations())),
SectionName: string(listener.Name),
}
}
Expand Down Expand Up @@ -585,7 +585,7 @@ func (t *Translator) processAccessLog(envoyproxy *egv1a1.EnvoyProxy, resources *

if len(accessLog.Sinks) == 0 {
al := &ir.JSONAccessLog{
JSON: format.JSON,
JSON: ir.MapToSlice(format.JSON),
CELMatches: validExprs,
LogType: accessLogType,
Path: "/dev/stdout",
Expand All @@ -611,7 +611,7 @@ func (t *Translator) processAccessLog(envoyproxy *egv1a1.EnvoyProxy, resources *
} else {
// Default to JSON format if type is nil or JSON
al := &ir.JSONAccessLog{
JSON: format.JSON,
JSON: ir.MapToSlice(format.JSON),
Path: sink.File.Path,
CELMatches: validExprs,
LogType: accessLogType,
Expand Down Expand Up @@ -668,7 +668,7 @@ func (t *Translator) processAccessLog(envoyproxy *egv1a1.EnvoyProxy, resources *
al.Text = format.Text
} else {
// Default to JSON format if type is nil or JSON
al.Attributes = format.JSON
al.Attributes = ir.MapToSlice(format.JSON)
}

irAccessLog.ALS = append(irAccessLog.ALS, al)
Expand All @@ -691,7 +691,7 @@ func (t *Translator) processAccessLog(envoyproxy *egv1a1.EnvoyProxy, resources *

al := &ir.OpenTelemetryAccessLog{
CELMatches: validExprs,
ResourceAttributes: sink.OpenTelemetry.GetResourceAttributes(),
ResourceAttributes: ir.MapToSlice(sink.OpenTelemetry.GetResourceAttributes()),
Headers: sink.OpenTelemetry.Headers,
Authority: getAuthorityFromDestination(ds),
Destination: ir.RouteDestination{
Expand Down Expand Up @@ -720,7 +720,7 @@ func (t *Translator) processAccessLog(envoyproxy *egv1a1.EnvoyProxy, resources *
al.Text = format.Text
}
if format.Type == nil || *format.Type == egv1a1.ProxyAccessLogFormatTypeJSON {
al.Attributes = format.JSON
al.Attributes = ir.MapToSlice(format.JSON)
}

irAccessLog.OpenTelemetry = append(irAccessLog.OpenTelemetry, al)
Expand Down Expand Up @@ -782,9 +782,9 @@ func (t *Translator) processTracing(gw *gwapiv1.Gateway, envoyproxy *egv1a1.Envo
Authority: authority,
ServiceName: serviceName,
SamplingRate: proxySamplingRate(tracing),
CustomTags: tracing.CustomTags,
Tags: tracing.Tags,
ResourceAttributes: getOpenTelemetryTracingResourceAttributes(&tracing.Provider),
CustomTags: ir.CustomTagMapToSlice(tracing.CustomTags),
Tags: ir.MapToSlice(tracing.Tags),
ResourceAttributes: ir.MapToSlice(getOpenTelemetryTracingResourceAttributes(&tracing.Provider)),
Destination: ir.RouteDestination{
Name: destName,
Settings: ds,
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ func TestProcessAccessLog(t *testing.T) {
expected: &ir.AccessLog{
JSON: []*ir.JSONAccessLog{
{
JSON: map[string]string{"start_time": "%START_TIME%"},
JSON: []ir.MapEntry{{Key: "start_time", Value: "%START_TIME%"}},
Path: "/dev/stdout",
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ func buildResourceMetadata(resource client.Object, sectionName *gwapiv1.SectionN
Kind: resource.GetObjectKind().GroupVersionKind().Kind,
Name: resource.GetName(),
Namespace: resource.GetNamespace(),
Annotations: filterEGPrefix(resource.GetAnnotations()),
Annotations: ir.MapToSlice(filterEGPrefix(resource.GetAnnotations())),
}
if sectionName != nil {
metadata.SectionName = string(*sectionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ xdsIR:
name: accesslog_otel_0_0/backend/-1
protocol: GRPC
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
globalResources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ xdsIR:
name: accesslog_otel_0_1/backend/-1
protocol: GRPC
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
traffic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,19 @@ xdsIR:
telemetry:
tracing:
customTags:
env1:
- key: env1
value:
environment:
defaultValue: '-'
name: env1
type: Environment
literal1:
- key: literal1
value:
literal:
value: value1
type: Literal
req1:
- key: req1
value:
requestHeader:
defaultValue: '-'
name: X-Request-Id
Expand All @@ -250,9 +253,12 @@ xdsIR:
denominator: 100
numerator: 1
tags:
env1: '%ENVIRONMENT(ENVOY_POD_NAME)%'
literal1: literal_value_1
req1: '%REQUEST_HEADER(X-Request-Id)%'
- key: env1
value: '%ENVIRONMENT(ENVOY_POD_NAME)%'
- key: literal1
value: literal_value_1
- key: req1
value: '%REQUEST_HEADER(X-Request-Id)%'
readyListener:
address: 0.0.0.0
ipFamily: IPv4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ xdsIR:
accessLog:
als:
- attributes:
attr1: val1
attr2: val2
- key: attr1
value: val1
- key: attr2
value: val2
destination:
metadata:
kind: EnvoyProxy
Expand Down Expand Up @@ -181,8 +183,10 @@ xdsIR:
name: accesslog
type: HTTP
- attributes:
attr1: val1
attr2: val2
- key: attr1
value: val1
- key: attr2
value: val2
destination:
metadata:
kind: EnvoyProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ xdsIR:
name: accesslog_otel_0_1/backend/-1
protocol: GRPC
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ xdsIR:
accessLog:
json:
- json:
duration: '%DURATION%'
protocol: '%PROTOCOL%'
- key: duration
value: '%DURATION%'
- key: protocol
value: '%PROTOCOL%'
path: /dev/stdout
globalResources:
proxyServiceCluster:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ xdsIR:
accessLog:
openTelemetry:
- attributes:
method: '%REQ(:METHOD)%'
response_code: '%RESPONSE_CODE%'
start_time: '%START_TIME%'
- key: method
value: '%REQ(:METHOD)%'
- key: response_code
value: '%RESPONSE_CODE%'
- key: start_time
value: '%START_TIME%'
authority: otel-collector.monitoring.svc.cluster.local
destination:
metadata:
Expand All @@ -109,7 +112,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: '%REQ(:METHOD)% %REQ(:PATH)% %PROTOCOL% %RESPONSE_CODE%'
globalResources:
proxyServiceCluster:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ xdsIR:
accessLog:
openTelemetry:
- attributes:
response_code_details: '%RESPONSE_CODE_DETAILS%'
upstream_cluster: '%UPSTREAM_CLUSTER%'
upstream_host: '%UPSTREAM_HOST%'
- key: response_code_details
value: '%RESPONSE_CODE_DETAILS%'
- key: upstream_cluster
value: '%UPSTREAM_CLUSTER%'
- key: upstream_host
value: '%UPSTREAM_HOST%'
authority: otel-collector.monitoring.svc.cluster.local
destination:
metadata:
Expand All @@ -109,7 +112,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: '%REQ(:METHOD)% %REQ(:PATH)% %PROTOCOL% %RESPONSE_CODE%'
globalResources:
proxyServiceCluster:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ xdsIR:
weight: 1
logType: Route
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
this is a route log
- authority: otel-collector.monitoring.svc.cluster.local
Expand All @@ -471,7 +472,8 @@ xdsIR:
weight: 1
logType: Listener
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
this is a listener log
- authority: otel-collector.monitoring.svc.cluster.local
Expand All @@ -490,7 +492,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
this is a Global log
text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
traffic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
globalResources:
proxyServiceCluster:
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ xdsIR:
protocol: GRPC
weight: 1
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
text:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ xdsIR:
name: otel-collector/envoy-gateway-ca
sni: otel-collector.example.com
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE%
globalResources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ xdsIR:
sni: otel-collector.example.com
useSystemTrustStore: true
resourceAttributes:
k8s.cluster.name: cluster-1
- key: k8s.cluster.name
value: cluster-1
text: |
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE%
globalResources:
Expand Down
Loading