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(exporters): working loki exporter #41

Merged
merged 15 commits into from
Mar 26, 2024
Merged
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'

- name: Check diff
run: make check-diff
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'

- name: Lint
run: make lint
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'

- name: Cache licenses
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:

env:
GO_VERSION: '1.21.5'
GO_VERSION: '1.22.1'
KUBECTL_VERSION: 'v1.24.1'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
7 changes: 5 additions & 2 deletions api/telemetry/v1alpha1/collector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import (

// CollectorSpec defines the desired state of Collector
type CollectorSpec struct {
TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"`
ControlNamespace string `json:"controlNamespace"`
TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"`
// Namespace where OTel collector DaemonSet is deployed
ControlNamespace string `json:"controlNamespace"`
// Enables debug logging for the collector
Debug bool `json:"debug,omitempty"`
}

// CollectorStatus defines the observed state of Collector
Expand Down
30 changes: 21 additions & 9 deletions api/telemetry/v1alpha1/oteloutput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@ type OtelOutputSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of OtelOutput. Edit oteloutput_types.go to remove/update
OTLP OTLPgrpc `json:"otlp,omitempty"`
OTLP *OTLP `json:"otlp,omitempty"`
Loki *Loki `json:"loki,omitempty"`
}

// OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
type OTLPgrpc struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
TimeoutSettings `json:",inline" yaml:",inline"`
ClientConfig `json:",inline" yaml:",inline"`
type OTLP struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
TimeoutSettings `json:",inline" yaml:",inline"`
GRPCClientConfig `json:",inline" yaml:",inline"`
}

type Loki struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
HTTPClientConfig `json:",inline" yaml:",inline"`
}

// OtelOutputStatus defines the observed state of OtelOutput
Expand All @@ -44,8 +51,9 @@ type OtelOutputStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:categories=telemetry-all

// OtelOutput is the Schema for the oteloutputs API
type OtelOutput struct {
Expand All @@ -56,7 +64,7 @@ type OtelOutput struct {
Status OtelOutputStatus `json:"status,omitempty" `
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// OtelOutputList contains a list of OtelOutput
type OtelOutputList struct {
Expand All @@ -68,3 +76,7 @@ type OtelOutputList struct {
func init() {
SchemeBuilder.Register(&OtelOutput{}, &OtelOutputList{})
}

func (o *OtelOutput) NamespacedName() NamespacedName {
return NamespacedName{Namespace: o.Namespace, Name: o.Name}
}
72 changes: 70 additions & 2 deletions api/telemetry/v1alpha1/otlp_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"time"

"go.opentelemetry.io/collector/config/configcompression"
"go.opentelemetry.io/collector/config/configopaque"
)

type TimeoutSettings struct {
Expand Down Expand Up @@ -69,14 +70,14 @@ type KeepaliveClientConfig struct {
}

// ClientConfig defines common settings for a gRPC client configuration.
type ClientConfig struct {
type GRPCClientConfig struct {
// The target to which the exporter is going to send traces or metrics,
// using the gRPC protocol. The valid syntax is described at
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
Endpoint string `json:"endpoint" yaml:"endpoint"`

// The compression key for supported compression types within collector.
Compression configcompression.CompressionType `json:"compression,omitempty" yaml:"compression,omitempty"`
Compression configcompression.Type `json:"compression,omitempty" yaml:"compression,omitempty"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting TLSClientSetting `json:"tls,omitempty" yaml:"tls,omitempty"`
Expand Down Expand Up @@ -172,3 +173,70 @@ type TLSSetting struct {
// If not set, it will never be reloaded (optional)
ReloadInterval time.Duration `json:"reload_interval,omitempty" yaml:"reload_interval,omitempty"`
}

// ClientConfig defines settings for creating an HTTP client.
type HTTPClientConfig struct {
// The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`

// ProxyURL setting for the collector
ProxyURL string `json:"proxy_url,omitempty" yaml:"proxy_url,omitempty"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting TLSClientSetting `json:"tls,omitempty" yaml:"tls,omitempty"`

// ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize.
ReadBufferSize int `json:"read_buffer_size,omitempty" yaml:"read_buffer_size,omitempty"`

// WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize.
WriteBufferSize int `json:"write_buffer_size,omitempty" yaml:"write_buffer_size,omitempty"`

// Timeout parameter configures `http.Client.Timeout`.
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`

// Additional headers attached to each HTTP request sent by the client.
// Existing header values are overwritten if collision happens.
// Header values are opaque since they may be sensitive.
Headers map[string]configopaque.String `json:"headers,omitempty" yaml:"headers,omitempty"`

// Auth configuration for outgoing HTTP calls.
Auth string `json:"auth,omitempty" yaml:"auth,omitempty"` //TODO this is a reference *configauth.Authentication

// The compression key for supported compression types within collector.
Compression configcompression.Type `json:"compression,omitempty" yaml:"compression,omitempty"`

// MaxIdleConns is used to set a limit to the maximum idle HTTP connections the client can keep open.
// There's an already set value, and we want to override it only if an explicit value provided
MaxIdleConns *int `json:"max_idle_conns,omitempty" yaml:"max_idle_conns,omitempty"`

// MaxIdleConnsPerHost is used to set a limit to the maximum idle HTTP connections the host can keep open.
// There's an already set value, and we want to override it only if an explicit value provided
MaxIdleConnsPerHost *int `json:"max_idle_conns_per_host,omitempty" yaml:"max_idle_conns_per_host,omitempty"`

// MaxConnsPerHost limits the total number of connections per host, including connections in the dialing,
// active, and idle states.
// There's an already set value, and we want to override it only if an explicit value provided
MaxConnsPerHost *int `json:"max_conns_per_host,omitempty" yaml:"max_conns_per_host,omitempty"`

// IdleConnTimeout is the maximum amount of time a connection will remain open before closing itself.
// There's an already set value, and we want to override it only if an explicit value provided
IdleConnTimeout *time.Duration `json:"idle_conn_timeout,omitempty" yaml:"idle_conn_timeout,omitempty"`

// DisableKeepAlives, if true, disables HTTP keep-alives and will only use the connection to the server
// for a single HTTP request.
//
// WARNING: enabling this option can result in significant overhead establishing a new HTTP(S)
// connection for every request. Before enabling this option please consider whether changes
// to idle connection settings can achieve your goal.
DisableKeepAlives bool `json:"disable_keep_alives,omitempty" yaml:"disable_keep_alives,omitempty"`

// This is needed in case you run into
// https://github.com/golang/go/issues/59690
// https://github.com/golang/go/issues/36026
// HTTP2ReadIdleTimeout if the connection has been idle for the configured value send a ping frame for health check
// 0s means no health check will be performed.
HTTP2ReadIdleTimeout time.Duration `json:"http2_read_idle_timeout,omitempty" yaml:"http2_read_idle_timeout,omitempty"`
// HTTP2PingTimeout if there's no response to the ping within the configured value, the connection will be closed.
// If not set or set to 0, it defaults to 15s.
HTTP2PingTimeout time.Duration `json:"http2_ping_timeout,omitempty" yaml:"http2_ping_timeout,omitempty"`
}
Loading
Loading