Skip to content

Commit

Permalink
api: Model OpenTelelemetry Sinks as a BackendRef (envoyproxy#3067)
Browse files Browse the repository at this point in the history
* api: Model OpenTelelemetry Sinks as a BackendRef

Signed-off-by: zirain <[email protected]>

* update

Signed-off-by: zirain <[email protected]>

* fix gen

Signed-off-by: zirain <[email protected]>

---------

Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain authored Apr 2, 2024
1 parent 91c18bc commit 06e4f39
Show file tree
Hide file tree
Showing 8 changed files with 590 additions and 22 deletions.
14 changes: 13 additions & 1 deletion api/v1alpha1/accesslogging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

type ProxyAccessLog struct {
// Disable disables access logging for managed proxies if set to true.
Disable bool `json:"disable,omitempty"`
Expand Down Expand Up @@ -92,16 +94,26 @@ type FileEnvoyProxyAccessLog struct {
Path string `json:"path,omitempty"`
}

// TODO: consider reuse ExtensionService?
// OpenTelemetryEnvoyProxyAccessLog defines the OpenTelemetry access log sink.
//
// +kubebuilder:validation:XValidation:message="BackendRef only support Service Kind.",rule="!has(self.backendRef) || !has(self.backendRef.kind) || self.backendRef.kind == 'Service'"
type OpenTelemetryEnvoyProxyAccessLog struct {
// Host define the extension service hostname.
// Deprecated: Use BackendRef instead.
Host string `json:"host"`
// Port defines the port the extension service is exposed on.
// Deprecated: Use BackendRef instead.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=4317
Port int32 `json:"port,omitempty"`
// BackendRef references a Kubernetes object that represents the
// backend server to which the accesslog will be sent.
// Only service Kind is supported for now.
//
// +optional
BackendRef *gwapiv1.BackendObjectReference `json:"backendRef,omitempty"`
// Resources is a set of labels that describe the source of a log entry, including envoy node info.
// It's recommended to follow [semantic conventions](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/).
// +optional
Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/envoyproxy_metric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

type MetricSinkType string

const (
Expand Down Expand Up @@ -47,16 +49,27 @@ type ProxyMetricSink struct {
OpenTelemetry *ProxyOpenTelemetrySink `json:"openTelemetry,omitempty"`
}

// ProxyOpenTelemetrySink defines the configuration for OpenTelemetry sink.
//
// +kubebuilder:validation:XValidation:message="BackendRef only support Service Kind.",rule="!has(self.backendRef) || !has(self.backendRef.kind) || self.backendRef.kind == 'Service'"
type ProxyOpenTelemetrySink struct {
// Host define the service hostname.
// Deprecated: Use BackendRef instead.
Host string `json:"host"`
// Port defines the port the service is exposed on.
// Deprecated: Use BackendRef instead.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
// +kubebuilder:default=4317
Port int32 `json:"port,omitempty"`
// BackendRef references a Kubernetes object that represents the
// backend server to which the metric will be sent.
// Only service Kind is supported for now.
//
// +optional
BackendRef *gwapiv1.BackendObjectReference `json:"backendRef,omitempty"`

// TODO: add support for customizing OpenTelemetry sink in https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto#envoy-v3-api-msg-extensions-stat-sinks-open-telemetry-v3-sinkconfig
}
Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/tracing_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

type ProxyTracing struct {
// SamplingRate controls the rate at which traffic will be
// selected for tracing if no prior sampling decision has been made.
Expand All @@ -28,20 +30,31 @@ const (
TracingProviderTypeOpenTelemetry TracingProviderType = "OpenTelemetry"
)

// TracingProvider defines the tracing provider configuration.
//
// +kubebuilder:validation:XValidation:message="BackendRef only support Service Kind.",rule="!has(self.backendRef) || !has(self.backendRef.kind) || self.backendRef.kind == 'Service'"
type TracingProvider struct {
// Type defines the tracing provider type.
// EG currently only supports OpenTelemetry.
// +kubebuilder:validation:Enum=OpenTelemetry
// +kubebuilder:default=OpenTelemetry
Type TracingProviderType `json:"type"`
// Host define the provider service hostname.
// Deprecated: Use BackendRef instead.
Host string `json:"host"`
// Port defines the port the provider service is exposed on.
// Deprecated: Use BackendRef instead.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=4317
Port int32 `json:"port,omitempty"`
// BackendRef references a Kubernetes object that represents the
// backend server to which the accesslog will be sent.
// Only service Kind is supported for now.
//
// +optional
BackendRef *gwapiv1.BackendObjectReference `json:"backendRef"`
}

type CustomTagType string
Expand Down
19 changes: 17 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 06e4f39

Please sign in to comment.