From 4d59b488952ce5477e8f4710322dc09768ea58a5 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Fri, 13 Dec 2024 21:45:03 +0200 Subject: [PATCH 1/4] ci: run make generate for collectors and verify workdir clean --- .github/workflows/verify-collector-ocb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-collector-ocb.yml b/.github/workflows/verify-collector-ocb.yml index e283b9072..5a57d201c 100644 --- a/.github/workflows/verify-collector-ocb.yml +++ b/.github/workflows/verify-collector-ocb.yml @@ -15,7 +15,7 @@ jobs: go-version: "1.23.0" - name: Generate collector with ocb working-directory: ./collector - run: "make genodigoscol" + run: "make genodigoscol generate" - name: Verify Generate working-directory: ./collector run: | From fba0051c2dc123be9936562323f9d438a5c5ec84 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Fri, 13 Dec 2024 21:49:57 +0200 Subject: [PATCH 2/4] fix: make generate for odigosconditionalattributes processor --- ...ts_test.go => generated_component_test.go} | 2 +- .../internal/metadata/generated_status.go | 15 +++++++ .../generated_component_test.go | 43 +++++++++++++++++++ .../generated_package_test.go | 5 ++- .../internal/metadata/generated_status.go | 15 +++++++ 5 files changed, 77 insertions(+), 3 deletions(-) rename collector/processors/odigosconditionalattributes/{generated_components_test.go => generated_component_test.go} (97%) create mode 100644 collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go create mode 100644 collector/processors/odigossqldboperationprocessor/internal/metadata/generated_status.go diff --git a/collector/processors/odigosconditionalattributes/generated_components_test.go b/collector/processors/odigosconditionalattributes/generated_component_test.go similarity index 97% rename from collector/processors/odigosconditionalattributes/generated_components_test.go rename to collector/processors/odigosconditionalattributes/generated_component_test.go index 31d0ada92..f2741d240 100644 --- a/collector/processors/odigosconditionalattributes/generated_components_test.go +++ b/collector/processors/odigosconditionalattributes/generated_component_test.go @@ -21,7 +21,7 @@ import ( ) func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "odigosconditionalattributes", NewFactory().Type().String()) + require.Equal(t, "odigosconditionalattributesprocessor", NewFactory().Type().String()) } func TestComponentConfigStruct(t *testing.T) { diff --git a/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go b/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go new file mode 100644 index 000000000..ac3cdf597 --- /dev/null +++ b/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go @@ -0,0 +1,15 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("odigosconditionalattributesprocessor") +) + +const ( + TracesStability = component.StabilityLevelBeta +) diff --git a/collector/processors/odigossqldboperationprocessor/generated_component_test.go b/collector/processors/odigossqldboperationprocessor/generated_component_test.go index ac5209816..2db71183e 100644 --- a/collector/processors/odigossqldboperationprocessor/generated_component_test.go +++ b/collector/processors/odigossqldboperationprocessor/generated_component_test.go @@ -1,3 +1,5 @@ +// Code generated by mdatagen. DO NOT EDIT. + package odigossqldboperationprocessor import ( @@ -11,6 +13,8 @@ import ( "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/processortest" @@ -62,6 +66,22 @@ func TestComponentLifecycle(t *testing.T) { require.NoError(t, err) require.NotPanics(t, func() { switch test.name { + case "logs": + e, ok := c.(processor.Logs) + require.True(t, ok) + logs := generateLifecycleTestLogs() + if !e.Capabilities().MutatesData { + logs.MarkReadOnly() + } + err = e.ConsumeLogs(context.Background(), logs) + case "metrics": + e, ok := c.(processor.Metrics) + require.True(t, ok) + metrics := generateLifecycleTestMetrics() + if !e.Capabilities().MutatesData { + metrics.MarkReadOnly() + } + err = e.ConsumeMetrics(context.Background(), metrics) case "traces": e, ok := c.(processor.Traces) require.True(t, ok) @@ -79,6 +99,29 @@ func TestComponentLifecycle(t *testing.T) { } } +func generateLifecycleTestLogs() plog.Logs { + logs := plog.NewLogs() + rl := logs.ResourceLogs().AppendEmpty() + rl.Resource().Attributes().PutStr("resource", "R1") + l := rl.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty() + l.Body().SetStr("test log message") + l.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return logs +} + +func generateLifecycleTestMetrics() pmetric.Metrics { + metrics := pmetric.NewMetrics() + rm := metrics.ResourceMetrics().AppendEmpty() + rm.Resource().Attributes().PutStr("resource", "R1") + m := rm.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty() + m.SetName("test_metric") + dp := m.SetEmptyGauge().DataPoints().AppendEmpty() + dp.Attributes().PutStr("test_attr", "value_1") + dp.SetIntValue(123) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return metrics +} + func generateLifecycleTestTraces() ptrace.Traces { traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() diff --git a/collector/processors/odigossqldboperationprocessor/generated_package_test.go b/collector/processors/odigossqldboperationprocessor/generated_package_test.go index aa0da6e50..d756e533d 100644 --- a/collector/processors/odigossqldboperationprocessor/generated_package_test.go +++ b/collector/processors/odigossqldboperationprocessor/generated_package_test.go @@ -1,9 +1,10 @@ +// Code generated by mdatagen. DO NOT EDIT. + package odigossqldboperationprocessor import ( - "testing" - "go.uber.org/goleak" + "testing" ) func TestMain(m *testing.M) { diff --git a/collector/processors/odigossqldboperationprocessor/internal/metadata/generated_status.go b/collector/processors/odigossqldboperationprocessor/internal/metadata/generated_status.go new file mode 100644 index 000000000..6b8f2fbf9 --- /dev/null +++ b/collector/processors/odigossqldboperationprocessor/internal/metadata/generated_status.go @@ -0,0 +1,15 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("odigossqldboperationprocessor") +) + +const ( + TracesStability = component.StabilityLevelBeta +) From ce115f8b64476024f1c9ee7c04e66cb8a9d539b7 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Fri, 13 Dec 2024 21:53:49 +0200 Subject: [PATCH 3/4] fix: add generate to ci message --- .github/workflows/verify-collector-ocb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-collector-ocb.yml b/.github/workflows/verify-collector-ocb.yml index 5a57d201c..177a286ea 100644 --- a/.github/workflows/verify-collector-ocb.yml +++ b/.github/workflows/verify-collector-ocb.yml @@ -21,6 +21,6 @@ jobs: run: | if [[ $(git diff --exit-code) ]]; then git diff - echo "odigos collector distribution module is not in sync with builder config. Please run 'make genodigoscol' in 'collector' directory and commit the changes." + echo "odigos collector distribution module is not in sync with builder config. Please run 'make genodigoscol generate' in 'collector' directory and commit the changes." exit 1 fi From fee837b2868e179d1146c535e12c3bf156579f69 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Fri, 13 Dec 2024 22:51:14 +0200 Subject: [PATCH 4/4] fix: metadata type for tests --- .../odigosconditionalattributes/generated_component_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- collector/processors/odigosconditionalattributes/metadata.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/collector/processors/odigosconditionalattributes/generated_component_test.go b/collector/processors/odigosconditionalattributes/generated_component_test.go index f2741d240..31d0ada92 100644 --- a/collector/processors/odigosconditionalattributes/generated_component_test.go +++ b/collector/processors/odigosconditionalattributes/generated_component_test.go @@ -21,7 +21,7 @@ import ( ) func TestComponentFactoryType(t *testing.T) { - require.Equal(t, "odigosconditionalattributesprocessor", NewFactory().Type().String()) + require.Equal(t, "odigosconditionalattributes", NewFactory().Type().String()) } func TestComponentConfigStruct(t *testing.T) { diff --git a/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go b/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go index ac3cdf597..9d969876b 100644 --- a/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go +++ b/collector/processors/odigosconditionalattributes/internal/metadata/generated_status.go @@ -7,7 +7,7 @@ import ( ) var ( - Type = component.MustNewType("odigosconditionalattributesprocessor") + Type = component.MustNewType("odigosconditionalattributes") ) const ( diff --git a/collector/processors/odigosconditionalattributes/metadata.yaml b/collector/processors/odigosconditionalattributes/metadata.yaml index 0595d4bb6..f38e2f9d2 100644 --- a/collector/processors/odigosconditionalattributes/metadata.yaml +++ b/collector/processors/odigosconditionalattributes/metadata.yaml @@ -1,4 +1,4 @@ -type: odigosconditionalattributesprocessor +type: odigosconditionalattributes status: class: processor stability: