diff --git a/apis/v1alpha2/observabilitypolicy_types.go b/apis/v1alpha2/observabilitypolicy_types.go index 05bd55557..e431b9ec8 100644 --- a/apis/v1alpha2/observabilitypolicy_types.go +++ b/apis/v1alpha2/observabilitypolicy_types.go @@ -3,6 +3,8 @@ package v1alpha2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + + ngfAPIv1alpha1 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" ) // +genclient @@ -100,7 +102,7 @@ type Tracing struct { // +listType=map // +listMapKey=key // +kubebuilder:validation:MaxItems=64 - SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"` + SpanAttributes []ngfAPIv1alpha1.SpanAttribute `json:"spanAttributes,omitempty"` } // TraceStrategy defines the tracing strategy. diff --git a/apis/v1alpha2/shared_types.go b/apis/v1alpha2/shared_types.go deleted file mode 100644 index 660db423f..000000000 --- a/apis/v1alpha2/shared_types.go +++ /dev/null @@ -1,28 +0,0 @@ -package v1alpha2 - -// Duration is a string value representing a duration in time. -// Duration can be specified in milliseconds (ms), seconds (s), minutes (m), hours (h). -// A value without a suffix is seconds. -// Examples: 120s, 50ms, 5m, 1h. -// -// +kubebuilder:validation:Pattern=`^[0-9]{1,4}(ms|s|m|h)?$` -type Duration string - -// SpanAttribute is a key value pair to be added to a tracing span. -type SpanAttribute struct { - // Key is the key for a span attribute. - // Format: must have all '"' escaped and must not contain any '$' or end with an unescaped '\' - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=255 - // +kubebuilder:validation:Pattern=`^([^"$\\]|\\[^$])*$` - Key string `json:"key"` - - // Value is the value for a span attribute. - // Format: must have all '"' escaped and must not contain any '$' or end with an unescaped '\' - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=255 - // +kubebuilder:validation:Pattern=`^([^"$\\]|\\[^$])*$` - Value string `json:"value"` -} diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go index cad2f3726..2435365a7 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1alpha2/zz_generated.deepcopy.go @@ -5,6 +5,7 @@ package v1alpha2 import ( + "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" "k8s.io/apimachinery/pkg/runtime" apisv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) @@ -93,21 +94,6 @@ func (in *ObservabilityPolicySpec) DeepCopy() *ObservabilityPolicySpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SpanAttribute) DeepCopyInto(out *SpanAttribute) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpanAttribute. -func (in *SpanAttribute) DeepCopy() *SpanAttribute { - if in == nil { - return nil - } - out := new(SpanAttribute) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Tracing) DeepCopyInto(out *Tracing) { *out = *in @@ -128,7 +114,7 @@ func (in *Tracing) DeepCopyInto(out *Tracing) { } if in.SpanAttributes != nil { in, out := &in.SpanAttributes, &out.SpanAttributes - *out = make([]SpanAttribute, len(*in)) + *out = make([]v1alpha1.SpanAttribute, len(*in)) copy(*out, *in) } } diff --git a/internal/mode/static/nginx/config/policies/observability/generator_test.go b/internal/mode/static/nginx/config/policies/observability/generator_test.go index 13bab7a80..33552850e 100644 --- a/internal/mode/static/nginx/config/policies/observability/generator_test.go +++ b/internal/mode/static/nginx/config/policies/observability/generator_test.go @@ -162,7 +162,7 @@ func TestGenerate(t *testing.T) { policy: &ngfAPIv1alpha2.ObservabilityPolicy{ Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ Tracing: &ngfAPIv1alpha2.Tracing{ - SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{ + SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{ {Key: "test-key", Value: "test-value"}, }, }, @@ -212,7 +212,7 @@ func TestGenerate(t *testing.T) { Strategy: ngfAPIv1alpha2.TraceStrategyRatio, Context: context, SpanName: spanName, - SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{ + SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{ {Key: "test-key", Value: "test-value"}, }, }, diff --git a/internal/mode/static/nginx/config/policies/observability/validator_test.go b/internal/mode/static/nginx/config/policies/observability/validator_test.go index a8577e489..0272bf6a3 100644 --- a/internal/mode/static/nginx/config/policies/observability/validator_test.go +++ b/internal/mode/static/nginx/config/policies/observability/validator_test.go @@ -8,6 +8,7 @@ import ( gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" + ngfAPIv1alpha1 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" ngfAPIv1alpha2 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha2" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" @@ -38,7 +39,7 @@ func createValidPolicy() *ngfAPIv1alpha2.ObservabilityPolicy { Strategy: ngfAPIv1alpha2.TraceStrategyRatio, Context: helpers.GetPointer(ngfAPIv1alpha2.TraceContextExtract), SpanName: helpers.GetPointer("spanName"), - SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{ + SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{ {Key: "key", Value: "value"}, }, }, diff --git a/site/content/reference/api.md b/site/content/reference/api.md index b80136afa..77eafa4ac 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -1829,7 +1829,8 @@ and the status of the SnippetsFilter with respect to each controller.
(Appears on: Telemetry, -Tracing) +Tracing, +Tracing)
SpanAttribute is a key value pair to be added to a tracing span.
@@ -2419,15 +2420,6 @@ sigs.k8s.io/gateway-api/apis/v1alpha2.PolicyStatus -string
alias)¶
--
Duration is a string value representing a duration in time. -Duration can be specified in milliseconds (ms), seconds (s), minutes (m), hours (h). -A value without a suffix is seconds. -Examples: 120s, 50ms, 5m, 1h.
--(Appears on: -Tracing) -
--
SpanAttribute is a key value pair to be added to a tracing span.
- -Field | -Description | -
---|---|
-key - -string - - |
-
- Key is the key for a span attribute. -Format: must have all ‘“’ escaped and must not contain any ‘$’ or end with an unescaped ‘\’ - |
-
-value - -string - - |
-
- Value is the value for a span attribute. -Format: must have all ‘“’ escaped and must not contain any ‘$’ or end with an unescaped ‘\’ - |
-
string
alias)¶
spanAttributes