Skip to content

Commit

Permalink
Update validation and attribute structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sjberman committed Apr 15, 2024
1 parent 9f285d0 commit 4240149
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 20 deletions.
25 changes: 18 additions & 7 deletions apis/v1alpha1/nginxproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ type Telemetry struct {
//
// +optional
// +kubebuilder:validation:MaxLength=127
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
ServiceName *string `json:"serviceName,omitempty"`

// SpanAttributes are custom key/value attributes that are added to each span.
//
// +optional
// +kubebuilder:validation:MaxProperties=64
SpanAttributes map[string]AttributeValue `json:"spanAttributes,omitempty"`
// +kubebuilder:validation:MaxItems=64
SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
}

// TelemetryExporter specifies OpenTelemetry export parameters.
Expand All @@ -79,13 +80,23 @@ type TelemetryExporter struct {
BatchCount *int32 `json:"batchCount,omitempty"`

// Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
//
// Format: alphanumeric hostname with optional http scheme and optional port.
//nolint:lll
// +kubebuilder:validation:Pattern=`^(?:http?:\/\/)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(?::\d{1,5})?$`
Endpoint string `json:"endpoint"`
}

// AttributeValue is a value paired with a key and attached to a tracing span.
//
// +kubebuilder:validation:MaxLength=255
type AttributeValue 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.
//
// +kubebuilder:validation:MaxLength=255
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
Key string `json:"key"`

// Value is the value for a span attribute.
//
// +kubebuilder:validation:MaxLength=255
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
Value string `json:"value"`
}
21 changes: 17 additions & 4 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

33 changes: 24 additions & 9 deletions config/crd/bases/gateway.nginx.org_nginxproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ spec:
minimum: 0
type: integer
endpoint:
description: Endpoint is the address of OTLP/gRPC endpoint
that will accept telemetry data.
description: |-
Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
Format: alphanumeric hostname with optional http scheme and optional port.
pattern: ^(?:http?:\/\/)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(?::\d{1,5})?$
type: string
interval:
Expand All @@ -87,17 +88,31 @@ spec:
Default is 'ngf:<gateway-namespace>:<gateway-name>'. If a value is provided by the user,
then the default becomes a prefix to that value.
maxLength: 127
pattern: ^[a-zA-Z0-9_-]+$
type: string
spanAttributes:
additionalProperties:
description: AttributeValue is a value paired with a key and
attached to a tracing span.
maxLength: 255
type: string
description: SpanAttributes are custom key/value attributes that
are added to each span.
maxProperties: 64
type: object
items:
description: SpanAttribute is a key value pair to be added to
a tracing span.
properties:
key:
description: Key is the key for a span attribute.
maxLength: 255
pattern: ^[a-zA-Z0-9_-]+$
type: string
value:
description: Value is the value for a span attribute.
maxLength: 255
pattern: ^[a-zA-Z0-9_-]+$
type: string
required:
- key
- value
type: object
maxItems: 64
type: array
type: object
type: object
required:
Expand Down

0 comments on commit 4240149

Please sign in to comment.