Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(crd): more detailed configuration settings for exporting telemetry #112

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 134 additions & 22 deletions api/dash0monitoring/v1alpha1/dash0monitoring_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,16 @@ 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`.
//
// +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.
// The configuration of the observability backend to which telemetry data will be sent. This property is mandatory.
// This can either be Dash0 or another OTLP-compatible backend. You can also combine sending to Dash0 with an
// HTTP exporter to send the same data to two targets simultaneously, or you can combine a gRPC exporter with an
// HTTP exporter. Combining Dash0 with a gRPC exporter is currently not supported.
//
// +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 +56,135 @@ 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. You can also combine Dash0 with an HTTP exporter or an arbitrary gRPC exporter with an HTTP
// exporter. Combining Dash0 with a gRPC exporter is currently not supported.
//
// +kubebuilder:validation:MinProperties=1
// +kubebuilder:validation:MaxProperties=2
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
// dataset "default" 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 token 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 token property is set. The authorization token for your Dash0 organization can be copied from
// https://app.dash0.com/settings.
//
// +kubebuilder:validation:Optional
SecretRef *SecretRef `json:"secretRef"`
}

type SecretRef struct {
// The name of the secret containing the Dash0 authorization token. Defaults to "dash0-authorization-secret".
// +kubebuilder:default=dash0-authorization-secret
Name string `json:"name"`

// The key of the value which contains the Dash0 authorization token. Defaults to "token"
// +kubebuilder:default=token
Key string `json:"key"`
}

// 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
Endpoint string `json:"endpoint"`

// 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 proto or json, defaults to proto.
//
// +kubebuilder:default=proto
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
Endpoint string `json:"endpoint"`

// 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=proto;json
type OtlpEncoding string

const (
Proto OtlpEncoding = "proto"
Json OtlpEncoding = "json"
)

type Header struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
// +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
144 changes: 143 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