Skip to content

Commit fc2bdf4

Browse files
authored
Add support for a supplemental YAML configuration for the CloudWatchAgent (#241)
1 parent c277a41 commit fc2bdf4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+14760
-8091
lines changed

apis/v1alpha1/amazoncloudwatchagent_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ type AmazonCloudWatchAgentSpec struct {
167167
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
168168
// +required
169169
Config string `json:"config,omitempty"`
170+
// Config is the raw YAML to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
171+
// +optional
172+
OtelConfig string `json:"otelConfig,omitempty"`
170173
// VolumeMounts represents the mount points to use in the underlying collector deployment(s)
171174
// +optional
172175
// +listType=atomic

apis/v1alpha2/amazoncloudwatchagent_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ type AmazonCloudWatchAgentSpec struct {
9292
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
9393
// +required
9494
Config string `json:"config,omitempty"`
95+
// Config is the raw YAML to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
96+
// +optional
97+
OtelConfig string `json:"otelConfig,omitempty"`
9598
// VolumeMounts represents the mount points to use in the underlying collector deployment(s)
9699
// +optional
97100
// +listType=atomic

config/crd/bases/cloudwatch.aws.amazon.com_amazoncloudwatchagents.yaml

Lines changed: 3259 additions & 3197 deletions
Large diffs are not rendered by default.

config/crd/bases/cloudwatch.aws.amazon.com_dcgmexporters.yaml

Lines changed: 1342 additions & 1332 deletions
Large diffs are not rendered by default.

config/crd/bases/cloudwatch.aws.amazon.com_instrumentations.yaml

Lines changed: 485 additions & 430 deletions
Large diffs are not rendered by default.

config/crd/bases/cloudwatch.aws.amazon.com_neuronmonitors.yaml

Lines changed: 1449 additions & 1426 deletions
Large diffs are not rendered by default.

docs/api.md

Lines changed: 6376 additions & 1646 deletions
Large diffs are not rendered by default.

internal/config/main.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
)
1313

1414
const (
15-
defaultCollectorConfigMapEntry = "cwagentconfig.json"
15+
defaultCollectorConfigMapEntry = "cwagentconfig.json"
16+
defaultOtelCollectorConfigMapEntry = "cwagentotelconfig.yaml"
1617
)
1718

1819
// Config holds the static configuration for this operator.
@@ -21,6 +22,7 @@ type Config struct {
2122
autoInstrumentationPythonImage string
2223
collectorImage string
2324
collectorConfigMapEntry string
25+
otelCollectorConfigMapEntry string
2426
autoInstrumentationDotNetImage string
2527
autoInstrumentationGoImage string
2628
autoInstrumentationApacheHttpdImage string
@@ -36,9 +38,10 @@ type Config struct {
3638
func New(opts ...Option) Config {
3739
// initialize with the default values
3840
o := options{
39-
collectorConfigMapEntry: defaultCollectorConfigMapEntry,
40-
logger: logf.Log.WithName("config"),
41-
version: version.Get(),
41+
collectorConfigMapEntry: defaultCollectorConfigMapEntry,
42+
otelCollectorConfigMapEntry: defaultOtelCollectorConfigMapEntry,
43+
logger: logf.Log.WithName("config"),
44+
version: version.Get(),
4245
}
4346
for _, opt := range opts {
4447
opt(&o)
@@ -47,6 +50,7 @@ func New(opts ...Option) Config {
4750
return Config{
4851
collectorImage: o.collectorImage,
4952
collectorConfigMapEntry: o.collectorConfigMapEntry,
53+
otelCollectorConfigMapEntry: o.otelCollectorConfigMapEntry,
5054
logger: o.logger,
5155
autoInstrumentationJavaImage: o.autoInstrumentationJavaImage,
5256
autoInstrumentationNodeJSImage: o.autoInstrumentationNodeJSImage,
@@ -66,11 +70,16 @@ func (c *Config) CollectorImage() string {
6670
return c.collectorImage
6771
}
6872

69-
// CollectorConfigMapEntry represents the configuration file name for the collector. Immutable.
73+
// CollectorConfigMapEntry represents the configuration JSON file name for the collector. Immutable.
7074
func (c *Config) CollectorConfigMapEntry() string {
7175
return c.collectorConfigMapEntry
7276
}
7377

78+
// OtelCollectorConfigMapEntry represents the configuration YAML file name for the collector. Immutable.
79+
func (c *Config) OtelCollectorConfigMapEntry() string {
80+
return c.otelCollectorConfigMapEntry
81+
}
82+
7483
// AutoInstrumentationJavaImage returns OpenTelemetry Java auto-instrumentation container image.
7584
func (c *Config) AutoInstrumentationJavaImage() string {
7685
return c.autoInstrumentationJavaImage

internal/config/main_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ func TestNewConfig(t *testing.T) {
1515
// prepare
1616
cfg := config.New(
1717
config.WithCollectorImage("some-image"),
18-
config.WithCollectorConfigMapEntry("some-config.yaml"),
18+
config.WithCollectorConfigMapEntry("some-config.json"),
19+
config.WithOtelCollectorConfigMapEntry("some-otel-config.yaml"),
1920
)
2021

2122
// test
2223
assert.Equal(t, "some-image", cfg.CollectorImage())
23-
assert.Equal(t, "some-config.yaml", cfg.CollectorConfigMapEntry())
24+
assert.Equal(t, "some-config.json", cfg.CollectorConfigMapEntry())
25+
assert.Equal(t, "some-otel-config.yaml", cfg.OtelCollectorConfigMapEntry())
2426
}

internal/config/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type options struct {
2727
autoInstrumentationNginxImage string
2828
collectorImage string
2929
collectorConfigMapEntry string
30+
otelCollectorConfigMapEntry string
3031
dcgmExporterImage string
3132
neuronMonitorImage string
3233
labelsFilter []string
@@ -42,6 +43,11 @@ func WithCollectorConfigMapEntry(s string) Option {
4243
o.collectorConfigMapEntry = s
4344
}
4445
}
46+
func WithOtelCollectorConfigMapEntry(s string) Option {
47+
return func(o *options) {
48+
o.otelCollectorConfigMapEntry = s
49+
}
50+
}
4551
func WithLogger(logger logr.Logger) Option {
4652
return func(o *options) {
4753
o.logger = logger

0 commit comments

Comments
 (0)