Skip to content

Commit

Permalink
feat(crd): provide more detailed configuration settings for exporting…
Browse files Browse the repository at this point in the history
… telemetry
  • Loading branch information
basti1302 committed Aug 23, 2024
1 parent b542534 commit 8949946
Show file tree
Hide file tree
Showing 17 changed files with 739 additions and 182 deletions.
134 changes: 112 additions & 22 deletions api/dash0monitoring/v1alpha1/dash0monitoring_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,13 @@ const (
FinalizerId = "operator.dash0.com/dash0-monitoring-finalizer"
)

// Dash0MonitoringSpec defines the desired state of the Dash0 monitoring resource.
// Dash0MonitoringSpec describes the details of monitoring a single Kubernetes namespace with Dash0 and sending
// telemetry to an observability backend.
type Dash0MonitoringSpec struct {
// The URL of the observability backend to which telemetry data will be sent. This property is mandatory. The value
// needs to be the OTLP/gRPC endpoint of your Dash0 organization. The correct OTLP/gRPC endpoint can be copied fom
// https://app.dash0.com/settings. The correct endpoint value will always start with `ingress.` and end in
// `dash0.com:4317`.
// The configuration of the observability backend to which telemetry data will be sent. This property is mandatory.
//
// +kubebuilder:validation:Mandatory
Endpoint string `json:"endpoint"`

// The Dash0 authorization token. This property is optional, but either this property or the SecretRef property has
// to be provided. If both are provided, the AuthorizationToken will be used and SecretRef will be ignored. The
// authorization token for your Dash0 organization can be copied from https://app.dash0.com/settings.
//
// +kubebuilder:validation:Optional
AuthorizationToken string `json:"authorizationToken"`

// A reference to a Kubernetes secret containing the Dash0 authorization token. This property is optional, and is
// ignored if the AuthorizationToken property is set. The authorization token for your Dash0 organization
// can be copied from https://app.dash0.com/settings.
//
// +kubebuilder:validation:Optional
SecretRef string `json:"secretRef"`
// +kubebuilder:validation:Required
Export `json:"export"`

// Global opt-out for workload instrumentation for the target namespace. There are three possible settings: `all`,
// `created-and-updated` and `none`. By default, the setting `all` is assumed.
Expand Down Expand Up @@ -69,10 +53,116 @@ type Dash0MonitoringSpec struct {
// More fine-grained per-workload control over instrumentation is available by setting the label
// dash0.com/enable=false on individual workloads.
//
// +kubebuilder:validation:Optional
// +kubebuilder:default=all
InstrumentWorkloads InstrumentWorkloadsMode `json:"instrumentWorkloads,omitempty"`
}

// Export describes the observability backend to which telemetry data will be sent. This can either be Dash0 or another
// OTLP-compatible backend.
//
// +kubebuilder:validation:MinProperties=1
// +kubebuilder:validation:MaxProperties=1
type Export struct {
// The configuration of the Dash0 ingress endpoint to which telemetry data will be sent.
//
// +kubebuilder:validation:Optional
Dash0 *Dash0Configuration `json:"dash0,omitempty"`

// The settings for an exporter to send telemetry to an arbitrary OTLP-compatible receiver via HTTP.
//
// +kubebuilder:validation:Optional
Http *HttpConfiguration `json:"http,omitempty"`

// The settings for an exporter to send telemetry to an arbitrary OTLP-compatible receiver via gRPC.
//
// +kubebuilder:validation:Optional
Grpc *GrpcConfiguration `json:"grpc,omitempty"`
}

// Dash0Configuration describes to which Dash0 ingress endpoint telemetry data will be sent.
type Dash0Configuration struct {
// The URL of the Dash0 ingress endpoint to which telemetry data will be sent. This property is mandatory. The value needs to be the OTLP/gRPC endpoint of your Dash0 organization. The correct OTLP/gRPC endpoint can be copied fom https://app.dash0.com/settings. The correct endpoint value will always start with `ingress.` and end in `dash0.com:4317`.
//
// +kubebuilder:validation:Required
Endpoint string `json:"endpoint"`

// The name of the Dash0 dataset to which telemetry data will be sent. This property is optional. If omitted, the default dataset of your Dash0 organization will be used.
//
// +kubebuilder:default=default
Dataset string `json:"dataset,omitempty"`

// Mandatory authorization settings for sending data to Dash0.
//
// +kubebuilder:validation:Required
Authorization Authorization `json:"authorization"`
}

// Authorization contains the authorization settings for Dash0.
//
// +kubebuilder:validation:MinProperties=1
// +kubebuilder:validation:MaxProperties=1
type Authorization struct {
// The Dash0 authorization token. This property is optional, but either this property or the SecretRef property has to be provided. If both are provided, the AuthorizationToken will be used and SecretRef will be ignored. The authorization token for your Dash0 organization can be copied from https://app.dash0.com/settings.
//
// +kubebuilder:validation:Optional
Token *string `json:"token"` // either token or secret ref, with token taking precedence

// A reference to a Kubernetes secret containing the Dash0 authorization token. This property is optional, and is ignored if the AuthorizationToken property is set. The authorization token for your Dash0 organization can be copied from https://app.dash0.com/settings.
//
// +kubebuilder:validation:Optional
SecretRef *string `json:"secretRef"`
}

// HttpConfiguration describe the settings for an exporter to send telemetry to an arbitrary OTLP-compatible receiver
// via HTTP.
type HttpConfiguration struct {
// The URL of the OTLP-compatible receiver to which telemetry data will be sent. This property is mandatory.
//
// +kubebuilder:validation:Required
Url string `json:"url"`

// Additional headers to be sent with each HTTP request, for example for authorization. This property is optional.
//
// +kubebuilder:validation:Optional
Headers []Header `json:"headers,omitempty"`

// The encoding of the OTLP data when sent via HTTP. Can be either protobuf or json, defaults to protobuf.
//
// +kubebuilder:default=protobuf
Encoding OtlpEncoding `json:"encoding,omitempty"`
}

// GrpcConfiguration descibe the settings for an exporter to send telemetry to an arbitrary OTLP-compatible receiver
// via gRPC.
type GrpcConfiguration struct {
// The URL of the OTLP-compatible receiver to which telemetry data will be sent. This property is mandatory.
//
// +kubebuilder:validation:Required
Url string `json:"url"`

// Additional headers to be sent with each gRPC request, for example for authorization. This property is optional.
//
// +kubebuilder:validation:Optional
Headers []Header `json:"headers,omitempty"`
}

// OtlpEncoding describes the encoding of the OTLP data when sent via HTTP.
//
// +kubebuilder:validation:Enum=protobuf;json
type OtlpEncoding string

const (
Protobuf OtlpEncoding = "protobuf"
Json OtlpEncoding = "json"
)

type Header struct {
// +kubebuilder:validation:Required
Key string `json:"key"`
// +kubebuilder:validation:Required
Value string `json:"value"`
}

// InstrumentWorkloadsMode describes when exactly workloads will be instrumented. Only one of the following modes
// may be specified. If none of the following policies is specified, the default one is All. See
// Dash0MonitoringSpec#InstrumentWorkloads for more details.
Expand Down
129 changes: 128 additions & 1 deletion api/dash0monitoring/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 8949946

Please sign in to comment.