From 51196b46379d1a03c619bc8fe3cb347d5e24cc27 Mon Sep 17 00:00:00 2001 From: Alex Marston Date: Mon, 24 Jun 2024 17:51:08 +0100 Subject: [PATCH] api: Adding Zipkin Tracing support (#3630) * api: Adding Zipkin Tracing support Signed-off-by: Alex Marston * rollback /internal changes Signed-off-by: Alex Marston * nest zipkin configuration under TracingProvider struct Signed-off-by: Alex Marston * rollback internal testdata changes Signed-off-by: Alex Marston * rollback site changes Signed-off-by: Alex Marston * Change ZipkinConfiguration to a pointer. Co-authored-by: zirain Signed-off-by: Alex Marston * update deepcopy Signed-off-by: Alex Marston * update description for TraceId128Bit field Signed-off-by: Alex Marston * update site docs Signed-off-by: Alex Marston * rename Zipkin config struct Signed-off-by: Alex Marston * update api Signed-off-by: Alex Marston * pointers for optional fields Signed-off-by: Alex Marston * remove CollectorHostname Signed-off-by: Alex Marston * TraceID128Bit -> Enable128BitTraceID Signed-off-by: Alex Marston --------- Signed-off-by: Alex Marston Signed-off-by: Alex Marston Co-authored-by: zirain --- api/v1alpha1/tracing_types.go | 21 +++++++++++-- api/v1alpha1/zz_generated.deepcopy.go | 30 +++++++++++++++++++ .../gateway.envoyproxy.io_envoyproxies.yaml | 25 ++++++++++++---- site/content/en/latest/api/extension_types.md | 21 +++++++++++-- site/content/zh/latest/api/extension_types.md | 21 +++++++++++-- 5 files changed, 105 insertions(+), 13 deletions(-) diff --git a/api/v1alpha1/tracing_types.go b/api/v1alpha1/tracing_types.go index 1b8b55edc47..b7be478de15 100644 --- a/api/v1alpha1/tracing_types.go +++ b/api/v1alpha1/tracing_types.go @@ -18,7 +18,6 @@ type ProxyTracing struct { // If provider is kubernetes, pod name and namespace are added by default. CustomTags map[string]CustomTag `json:"customTags,omitempty"` // Provider defines the tracing provider. - // Only OpenTelemetry is supported currently. Provider TracingProvider `json:"provider"` } @@ -26,6 +25,7 @@ type TracingProviderType string const ( TracingProviderTypeOpenTelemetry TracingProviderType = "OpenTelemetry" + TracingProviderTypeZipkin TracingProviderType = "Zipkin" ) // TracingProvider defines the tracing provider configuration. @@ -33,8 +33,7 @@ const ( // +kubebuilder:validation:XValidation:message="host or backendRefs needs to be set",rule="has(self.host) || self.backendRefs.size() > 0" type TracingProvider struct { // Type defines the tracing provider type. - // EG currently only supports OpenTelemetry. - // +kubebuilder:validation:Enum=OpenTelemetry + // +kubebuilder:validation:Enum=OpenTelemetry;Zipkin // +kubebuilder:default=OpenTelemetry Type TracingProviderType `json:"type"` // Host define the provider service hostname. @@ -58,6 +57,9 @@ type TracingProvider struct { // +kubebuilder:validation:XValidation:message="only support Service kind.",rule="self.all(f, f.kind == 'Service')" // +kubebuilder:validation:XValidation:message="BackendRefs only supports Core group.",rule="self.all(f, f.group == '')" BackendRefs []BackendRef `json:"backendRefs,omitempty"` + // Zipkin defines the Zipkin tracing provider configuration + // +optional + Zipkin *ZipkinTracingProvider `json:"zipkin,omitempty"` } type CustomTagType string @@ -114,3 +116,16 @@ type RequestHeaderCustomTag struct { // +optional DefaultValue *string `json:"defaultValue,omitempty"` } + +// ZipkinTracingProvider defines the Zipkin tracing provider configuration. +type ZipkinTracingProvider struct { + // Enable128BitTraceID determines whether a 128bit trace id will be used + // when creating a new trace instance. If set to false, a 64bit trace + // id will be used. + // +optional + Enable128BitTraceID *bool `json:"enable128BitTraceId,omitempty"` + // DisableSharedSpanContext determines whether the default Envoy behaviour of + // client and server spans sharing the same span context should be disabled. + // +optional + DisableSharedSpanContext *bool `json:"disableSharedSpanContext,omitempty"` +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 1c3ae25c430..e1442dd636a 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -4725,6 +4725,11 @@ func (in *TracingProvider) DeepCopyInto(out *TracingProvider) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.Zipkin != nil { + in, out := &in.Zipkin, &out.Zipkin + *out = new(ZipkinTracingProvider) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TracingProvider. @@ -4877,3 +4882,28 @@ func (in *XForwardedForSettings) DeepCopy() *XForwardedForSettings { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ZipkinTracingProvider) DeepCopyInto(out *ZipkinTracingProvider) { + *out = *in + if in.Enable128BitTraceID != nil { + in, out := &in.Enable128BitTraceID, &out.Enable128BitTraceID + *out = new(bool) + **out = **in + } + if in.DisableSharedSpanContext != nil { + in, out := &in.DisableSharedSpanContext, &out.DisableSharedSpanContext + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZipkinTracingProvider. +func (in *ZipkinTracingProvider) DeepCopy() *ZipkinTracingProvider { + if in == nil { + return nil + } + out := new(ZipkinTracingProvider) + in.DeepCopyInto(out) + return out +} diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml index 2da9760560f..f40ff9b0e96 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml @@ -10864,9 +10864,7 @@ spec: If provider is kubernetes, pod name and namespace are added by default. type: object provider: - description: |- - Provider defines the tracing provider. - Only OpenTelemetry is supported currently. + description: Provider defines the tracing provider. properties: backendRefs: description: |- @@ -10972,12 +10970,27 @@ spec: type: integer type: default: OpenTelemetry - description: |- - Type defines the tracing provider type. - EG currently only supports OpenTelemetry. + description: Type defines the tracing provider type. enum: - OpenTelemetry + - Zipkin type: string + zipkin: + description: Zipkin defines the Zipkin tracing provider + configuration + properties: + disableSharedSpanContext: + description: |- + DisableSharedSpanContext determines whether the default Envoy behaviour of + client and server spans sharing the same span context should be disabled. + type: boolean + enable128BitTraceId: + description: |- + Enable128BitTraceID determines whether a 128bit trace id will be used + when creating a new trace instance. If set to false, a 64bit trace + id will be used. + type: boolean + type: object required: - type type: object diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index 57b24c2b5b9..258d99f27fe 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -2910,7 +2910,7 @@ _Appears in:_ | --- | --- | --- | --- | | `samplingRate` | _integer_ | false | SamplingRate controls the rate at which traffic will be
selected for tracing if no prior sampling decision has been made.
Defaults to 100, valid values [0-100]. 100 indicates 100% sampling. | | `customTags` | _object (keys:string, values:[CustomTag](#customtag))_ | true | CustomTags defines the custom tags to add to each span.
If provider is kubernetes, pod name and namespace are added by default. | -| `provider` | _[TracingProvider](#tracingprovider)_ | true | Provider defines the tracing provider.
Only OpenTelemetry is supported currently. | +| `provider` | _[TracingProvider](#tracingprovider)_ | true | Provider defines the tracing provider. | #### RateLimit @@ -3564,10 +3564,11 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | -| `type` | _[TracingProviderType](#tracingprovidertype)_ | true | Type defines the tracing provider type.
EG currently only supports OpenTelemetry. | +| `type` | _[TracingProviderType](#tracingprovidertype)_ | true | Type defines the tracing provider type. | | `host` | _string_ | false | Host define the provider service hostname.
Deprecated: Use BackendRefs instead. | | `port` | _integer_ | false | Port defines the port the provider service is exposed on.
Deprecated: Use BackendRefs instead. | | `backendRefs` | _[BackendRef](#backendref) array_ | false | BackendRefs references a Kubernetes object that represents the
backend server to which the trace will be sent.
Only Service kind is supported for now. | +| `zipkin` | _[ZipkinTracingProvider](#zipkintracingprovider)_ | false | Zipkin defines the Zipkin tracing provider configuration | #### TracingProviderType @@ -3583,6 +3584,7 @@ _Appears in:_ | ----- | ----------- | | `OpenTelemetry` | | | `OpenTelemetry` | | +| `Zipkin` | | #### TriggerEnum @@ -3795,3 +3797,18 @@ _Appears in:_ | `numTrustedHops` | _integer_ | false | NumTrustedHops controls the number of additional ingress proxy hops from the right side of XFF HTTP
headers to trust when determining the origin client's IP address.
Refer to https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-forwarded-for
for more details. | +#### ZipkinTracingProvider + + + +ZipkinTracingProvider defines the Zipkin tracing provider configuration. + +_Appears in:_ +- [TracingProvider](#tracingprovider) + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `enable128BitTraceId` | _boolean_ | false | Enable128BitTraceID determines whether a 128bit trace id will be used
when creating a new trace instance. If set to false, a 64bit trace
id will be used. | +| `disableSharedSpanContext` | _boolean_ | false | DisableSharedSpanContext determines whether the default Envoy behaviour of
client and server spans sharing the same span context should be disabled. | + + diff --git a/site/content/zh/latest/api/extension_types.md b/site/content/zh/latest/api/extension_types.md index 57b24c2b5b9..258d99f27fe 100644 --- a/site/content/zh/latest/api/extension_types.md +++ b/site/content/zh/latest/api/extension_types.md @@ -2910,7 +2910,7 @@ _Appears in:_ | --- | --- | --- | --- | | `samplingRate` | _integer_ | false | SamplingRate controls the rate at which traffic will be
selected for tracing if no prior sampling decision has been made.
Defaults to 100, valid values [0-100]. 100 indicates 100% sampling. | | `customTags` | _object (keys:string, values:[CustomTag](#customtag))_ | true | CustomTags defines the custom tags to add to each span.
If provider is kubernetes, pod name and namespace are added by default. | -| `provider` | _[TracingProvider](#tracingprovider)_ | true | Provider defines the tracing provider.
Only OpenTelemetry is supported currently. | +| `provider` | _[TracingProvider](#tracingprovider)_ | true | Provider defines the tracing provider. | #### RateLimit @@ -3564,10 +3564,11 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | -| `type` | _[TracingProviderType](#tracingprovidertype)_ | true | Type defines the tracing provider type.
EG currently only supports OpenTelemetry. | +| `type` | _[TracingProviderType](#tracingprovidertype)_ | true | Type defines the tracing provider type. | | `host` | _string_ | false | Host define the provider service hostname.
Deprecated: Use BackendRefs instead. | | `port` | _integer_ | false | Port defines the port the provider service is exposed on.
Deprecated: Use BackendRefs instead. | | `backendRefs` | _[BackendRef](#backendref) array_ | false | BackendRefs references a Kubernetes object that represents the
backend server to which the trace will be sent.
Only Service kind is supported for now. | +| `zipkin` | _[ZipkinTracingProvider](#zipkintracingprovider)_ | false | Zipkin defines the Zipkin tracing provider configuration | #### TracingProviderType @@ -3583,6 +3584,7 @@ _Appears in:_ | ----- | ----------- | | `OpenTelemetry` | | | `OpenTelemetry` | | +| `Zipkin` | | #### TriggerEnum @@ -3795,3 +3797,18 @@ _Appears in:_ | `numTrustedHops` | _integer_ | false | NumTrustedHops controls the number of additional ingress proxy hops from the right side of XFF HTTP
headers to trust when determining the origin client's IP address.
Refer to https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-forwarded-for
for more details. | +#### ZipkinTracingProvider + + + +ZipkinTracingProvider defines the Zipkin tracing provider configuration. + +_Appears in:_ +- [TracingProvider](#tracingprovider) + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `enable128BitTraceId` | _boolean_ | false | Enable128BitTraceID determines whether a 128bit trace id will be used
when creating a new trace instance. If set to false, a 64bit trace
id will be used. | +| `disableSharedSpanContext` | _boolean_ | false | DisableSharedSpanContext determines whether the default Envoy behaviour of
client and server spans sharing the same span context should be disabled. | + +