@@ -11,22 +11,27 @@ import corev1 "k8s.io/api/core/v1"
1111type InstrumentationSpec struct {
1212 // Image name to use for collector containers. When omitted, the value
1313 // comes from an operator environment variable.
14+ // ---
1415 // +optional
1516 Image string `json:"image,omitempty"`
1617
1718 // Resources holds the resource requirements for the collector container.
19+ // ---
1820 // +optional
1921 Resources corev1.ResourceRequirements `json:"resources,omitempty"`
2022
2123 // Config is the place for users to configure exporters and provide files.
24+ // ---
2225 // +optional
2326 Config * InstrumentationConfigSpec `json:"config,omitempty"`
2427
2528 // Logs is the place for users to configure the log collection.
29+ // ---
2630 // +optional
2731 Logs * InstrumentationLogsSpec `json:"logs,omitempty"`
2832
2933 // Metrics is the place for users to configure metrics collection.
34+ // ---
3035 // +optional
3136 Metrics * InstrumentationMetricsSpec `json:"metrics,omitempty"`
3237}
@@ -46,6 +51,7 @@ type InstrumentationConfigSpec struct {
4651
4752 // Exporters allows users to configure OpenTelemetry exporters that exist
4853 // in the collector image.
54+ // ---
4955 // +kubebuilder:pruning:PreserveUnknownFields
5056 // +kubebuilder:validation:Schemaless
5157 // +kubebuilder:validation:Type=object
@@ -98,30 +104,41 @@ type InstrumentationLogsSpec struct {
98104type InstrumentationMetricsSpec struct {
99105 // Where users can turn off built-in metrics and also provide their own
100106 // custom queries.
107+ // ---
101108 // +optional
102109 CustomQueries * InstrumentationCustomQueriesSpec `json:"customQueries,omitempty"`
103110}
104111
105112type InstrumentationCustomQueriesSpec struct {
106113 // User defined queries and metrics.
114+ // ---
107115 // +optional
108116 Add []InstrumentationCustomQueries `json:"add,omitempty"`
109117
110118 // A list of built-in queries that should be removed. If all queries for a
111119 // given SQL statement are removed, the SQL statement will no longer be run.
112- //
120+ // ---
113121 // +optional
114122 Remove []string `json:"remove,omitempty"`
115123}
116124
117125type InstrumentationCustomQueries struct {
118- // The name of this batch of queries.
126+ // The name of this batch of queries, which will be used in naming the OTel
127+ // SqlQuery receiver.
128+ // ---
129+ // OTel restricts component names from having whitespace, control characters,
130+ // or symbols.
131+ // https://github.com/open-telemetry/opentelemetry-collector/blob/main/component/identifiable.go#L23-L26
132+ // +kubebuilder:validation:Pattern=`^[^\pZ\pC\pS]+$`
133+ //
134+ // Set a max length to keep rule costs low.
135+ // +kubebuilder:validation:MaxLength=20
119136 //
120137 // +required
121138 Name string `json:"name"`
122139
123140 // A ConfigMap holding the yaml file that contains the queries.
124- //
141+ // ---
125142 // +required
126143 Queries ConfigMapKeyRef `json:"queries"`
127144
@@ -147,7 +164,7 @@ type InstrumentationCustomQueries struct {
147164// ---
148165// Configuration for the OpenTelemetry Batch Processor
149166// https://pkg.go.dev/go.opentelemetry.io/collector/processor/batchprocessor#section-readme
150- //
167+ // ---
151168// The batch processor stops batching when *either* of these is zero, but that is confusing.
152169// Make the user set both so it is evident there is *no* motivation to create any batch.
153170// +kubebuilder:validation:XValidation:rule=`(has(self.minRecords) && self.minRecords == 0) == (has(self.maxDelay) && self.maxDelay == duration('0'))`,message=`to disable batching, both minRecords and maxDelay must be zero`
0 commit comments