Skip to content

Commit

Permalink
update tests for changed config
Browse files Browse the repository at this point in the history
Signed-off-by: Kristof Gyuracz <[email protected]>
  • Loading branch information
kristofgyuracz committed Apr 22, 2024
1 parent e19ff29 commit ee94100
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,49 @@ exporters:
endpoint: receiver-collector.example-tenant-ns.svc.cluster.local:4317
tls:
insecure: true
prometheus/message_metrics_exporter:
endpoint: 0.0.0.0:9999

processors:
attributes/exporter_name_loki-test-output:
actions:
- action: insert
key: exporter
value: loki/collector_loki-test-output
attributes/exporter_name_otlp-test-output:
actions:
- action: insert
key: exporter
value: otlp/collector_otlp-test-output
attributes/exporter_name_otlp-test-output-2:
actions:
- action: insert
key: exporter
value: otlp/collector_otlp-test-output-2
attributes/loki_exporter_loki-test-output:
actions:
- action: insert
key: loki.tenant
from_attribute: tenant_name
from_attribute: tenant
- action: insert
key: loki.attribute.labels
value: tenant_name
value: tenant
attributes/subscription_subscription-example-1:
actions:
- action: insert
key: subscription_name
key: subscription
value: subscription-example-1
attributes/subscription_subscription-example-2:
actions:
- action: insert
key: subscription_name
key: subscription
value: subscription-example-2
attributes/tenant_example-tenant:
actions:
- action: insert
key: tenant_name
key: tenant
value: example-tenant
deltatocumulative: {}
k8sattributes:
auth_type: serviceAccount
extract:
Expand Down Expand Up @@ -125,6 +144,24 @@ processors:
limit_percentage: 75
spike_limit_percentage: 25
connectors:
count/output_metrics:
logs:
otelcollector_output_log_count:
description: The number of logs sent out from each exporter.
attributes:
- key: tenant
default_value: no_tenant
- key: subscription
default_value: no_subscription
- key: exporter
default_value: no_exporter
count/tenant_metrics:
logs:
otelcollector_tenant_log_count:
description: The number of logs from each tenant pipeline.
attributes:
- key: tenant
default_value: no_tenant
routing/subscription_example-tenant-ns_subscription-example-1_outputs:
table:
- statement: route()
Expand Down Expand Up @@ -173,3 +210,11 @@ service:
receivers: [routing/tenant_example-tenant_subscriptions]
processors: [memory_limiter, attributes/subscription_subscription-example-2]
exporters: [routing/subscription_example-tenant-ns_subscription-example-2_outputs]
metrics/output:
receivers: [count/output_metrics]
processors: [deltatocumulative]
exporters: [prometheus/message_metrics_exporter]
metrics/tenant:
receivers: [count/tenant_metrics]
processors: [deltatocumulative]
exporters: [prometheus/message_metrics_exporter]
21 changes: 11 additions & 10 deletions internal/controller/telemetry/otel_conf_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"go.opentelemetry.io/collector/config/configauth"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configtls"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -113,27 +112,27 @@ type PrometheusExporterConfig struct {

type HTTPServerConfig struct {
// Endpoint configures the listening address for the server.
Endpoint string `yaml:"endpoint"`
Endpoint string `yaml:"endpoint,omitempty"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting *configtls.ServerConfig `yaml:"tls"`
TLSSetting *TLSServerConfig `yaml:"tls,omitempty"`

// CORS configures the server for HTTP cross-origin resource sharing (CORS).
CORS *CORSConfig `yaml:"cors"`
CORS *CORSConfig `yaml:"cors,omitempty"`

// Auth for this receiver
Auth *configauth.Authentication `yaml:"auth"`
Auth *configauth.Authentication `yaml:"auth,omitempty"`

// MaxRequestBodySize sets the maximum request body size in bytes
MaxRequestBodySize int64 `yaml:"max_request_body_size"`
MaxRequestBodySize int64 `yaml:"max_request_body_size,omitempty"`

// IncludeMetadata propagates the client metadata from the incoming requests to the downstream consumers
// Experimental: *NOTE* this option is subject to change or removal in the future.
IncludeMetadata bool `yaml:"include_metadata"`
IncludeMetadata bool `yaml:"include_metadata,omitempty"`

// Additional headers attached to each HTTP response sent to the client.
// Header values are opaque since they may be sensitive.
ResponseHeaders map[string]configopaque.String `yaml:"response_headers"`
ResponseHeaders map[string]configopaque.String `yaml:"response_headers,omitempty"`
}

type TLSServerConfig struct {
Expand Down Expand Up @@ -435,13 +434,15 @@ func (cfgInput *OtelColConfigInput) generateProcessorMemoryLimiter() map[string]
memoryLimiter["spike_limit_percentage"] = cfgInput.MemoryLimiter.MemorySpikePercentage
}
return memoryLimiter
}

func generateCountConnectors() map[string]any {
countConnectors := make(map[string]any)

countConnectors["count/tenant_metrics"] = map[string]any{
"logs": map[string]CountConnectorMetricInfo{
"otelcollector_tenant_log_count": {
Description: "The number of logs from each environment.",
Description: "The number of logs from each tenant pipeline.",
Attributes: []CountConnectorAttributeConfig{{
Key: "tenant",
DefaultValue: "no_tenant",
Expand All @@ -453,7 +454,7 @@ func generateCountConnectors() map[string]any {
countConnectors["count/output_metrics"] = map[string]any{
"logs": map[string]CountConnectorMetricInfo{
"otelcollector_output_log_count": {
Description: "The number of logs from each environment.",
Description: "The number of logs sent out from each exporter.",
Attributes: []CountConnectorAttributeConfig{{
Key: "tenant",
DefaultValue: "no_tenant",
Expand Down

0 comments on commit ee94100

Please sign in to comment.