From 4069d016c59d9027df0906dd945170beabd43830 Mon Sep 17 00:00:00 2001 From: Raj Nishtala Date: Thu, 19 Dec 2024 10:24:36 -0500 Subject: [PATCH 1/2] feat: Add validation for the attributes processor --- .changelog/1721.added.txt | 1 + pkg/extension/opampextension/components.go | 2 ++ pkg/extension/opampextension/go.mod | 1 + pkg/extension/opampextension/go.sum | 2 ++ 4 files changed, 6 insertions(+) create mode 100644 .changelog/1721.added.txt diff --git a/.changelog/1721.added.txt b/.changelog/1721.added.txt new file mode 100644 index 0000000000..3e9c3c6278 --- /dev/null +++ b/.changelog/1721.added.txt @@ -0,0 +1 @@ +feat: Add validation for the attributes processor \ No newline at end of file diff --git a/pkg/extension/opampextension/components.go b/pkg/extension/opampextension/components.go index b109b4f714..bcb377b240 100644 --- a/pkg/extension/opampextension/components.go +++ b/pkg/extension/opampextension/components.go @@ -21,6 +21,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/sumologicextension" + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor" @@ -88,6 +89,7 @@ func Components() ( errs = multierr.Append(errs, err) processors, err := processor.MakeFactoryMap( + attributesprocessor.NewFactory(), batchprocessor.NewFactory(), memorylimiterprocessor.NewFactory(), resourcedetectionprocessor.NewFactory(), diff --git a/pkg/extension/opampextension/go.mod b/pkg/extension/opampextension/go.mod index 0a7dc85bf4..3c9366a9a7 100644 --- a/pkg/extension/opampextension/go.mod +++ b/pkg/extension/opampextension/go.mod @@ -17,6 +17,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.114.0 github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.114.0 github.com/open-telemetry/opentelemetry-collector-contrib/extension/sumologicextension v0.114.0 + github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.114.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.114.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.114.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.114.0 diff --git a/pkg/extension/opampextension/go.sum b/pkg/extension/opampextension/go.sum index 262d06aa11..cf40f3f60a 100644 --- a/pkg/extension/opampextension/go.sum +++ b/pkg/extension/opampextension/go.sum @@ -553,6 +553,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.114.0/go.mod h1:t5uoTcckI8kQeW1sZl8A+1UebVJPe47Qi3WQeNZu6w4= github.com/open-telemetry/opentelemetry-collector-contrib/pkg/winperfcounters v0.114.0 h1:1xAInvRymxpsuIWz/plGH98eWRhmLVgUHqleBCEeoJM= github.com/open-telemetry/opentelemetry-collector-contrib/pkg/winperfcounters v0.114.0/go.mod h1:3PSKkD/USW8EXij1UTwoRwDFIl0D0V5td9U3n0YEKTo= +github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.114.0 h1:fltPkjMuiVTtIVwoWUzbL0ad2CTCJsWfnCSDJQ9hSxU= +github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.114.0/go.mod h1:HcG364Is9u2EDqOUtQX0RwnbHtQqSh5+x2FdcYC+F1M= github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.114.0 h1:QBR07Gaw6ePkufQ/AhHgBv4OlwzXlULTdiUnaKIlvLk= github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.114.0/go.mod h1:coY0CV/sNj1hltRXKZr2gnrLvr7xUbnW+GhpCQpGR/Y= github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.114.0 h1:ttRj/3GIpg+vUTeBI+EBeeWdNuvBT3S/ayoqpvA9B9s= From e6aea1dbaea2c1c90f1eae66e8559e3d8fc77442 Mon Sep 17 00:00:00 2001 From: Raj Nishtala Date: Thu, 19 Dec 2024 10:49:06 -0500 Subject: [PATCH 2/2] Add test to validate the attributes processor --- .../opampextension/opamp_agent_test.go | 1 + .../opamp.d/opamp-attributes-processor.yaml | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 pkg/extension/opampextension/testdata/opamp.d/opamp-attributes-processor.yaml diff --git a/pkg/extension/opampextension/opamp_agent_test.go b/pkg/extension/opampextension/opamp_agent_test.go index 9a2e8b4ac7..346b6f87e0 100644 --- a/pkg/extension/opampextension/opamp_agent_test.go +++ b/pkg/extension/opampextension/opamp_agent_test.go @@ -71,6 +71,7 @@ func TestApplyRemoteConfig(t *testing.T) { {"ApplyKafkaMetricsConfig", "testdata/opamp.d/opamp-kafkametrics-config.yaml", false, ""}, {"ApplyElasticsearchConfig", "testdata/opamp.d/opamp-elastic-config.yaml", false, ""}, {"ApplyMysqlConfig", "testdata/opamp.d/opamp-mysql-config.yaml", false, ""}, + {"ApplyattributesprocessorConfig", "testdata/opamp.d/opamp-attributes-processor.yaml", false, ""}, {"ApplyPostgresqlConfig", "testdata/opamp.d/opamp-postgresql-config.yaml", false, ""}, {"ApplyRabbitmqConfig", "testdata/opamp.d/opamp-rabbitmq-config.yaml", false, ""}, {"ApplyRedisConfig", "testdata/opamp.d/opamp-redis-config.yaml", false, ""}, diff --git a/pkg/extension/opampextension/testdata/opamp.d/opamp-attributes-processor.yaml b/pkg/extension/opampextension/testdata/opamp.d/opamp-attributes-processor.yaml new file mode 100644 index 0000000000..5bdf8cc184 --- /dev/null +++ b/pkg/extension/opampextension/testdata/opamp.d/opamp-attributes-processor.yaml @@ -0,0 +1,45 @@ +receivers: + mysql: + endpoint: localhost:3306 + username: otel + password: test + database: otel + collection_interval: 10s + initial_delay: 1s + statement_events: + digest_text_limit: 120 + time_limit: 24h + limit: 250 +exporters: + sumologic: +processors: + attributes/example: + actions: + - key: db.table + action: delete + - key: redacted_span + value: true + action: upsert + - key: copy_key + from_attribute: key_original + action: update + - key: account_id + value: 2245 + action: insert + - key: account_password + action: delete + - key: account_email + action: hash + - key: http.status_code + action: convert + converted_type: int + +service: + pipelines: + metrics/mysql/09c98ea4-6686-4ab9-b3cd-f04070906441: + processors: + - attributes/example + receivers: + - mysql + exporters: + - sumologic