diff --git a/cmd/mdatagen/templates/component_test.go.tmpl b/cmd/mdatagen/templates/component_test.go.tmpl index 0aa122a1c022..0625d2831e50 100644 --- a/cmd/mdatagen/templates/component_test.go.tmpl +++ b/cmd/mdatagen/templates/component_test.go.tmpl @@ -9,6 +9,9 @@ package {{ .Package }} import ( "context" "testing" +{{- if or isExporter isProcessor }} + "time" +{{- end }} "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -36,9 +39,12 @@ import ( "go.opentelemetry.io/collector/connector/connectortest" {{ end }} "go.opentelemetry.io/collector/confmap/confmaptest" -{{ if or (isExporter) (isProcessor) }} - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" -{{ end }} +{{- if or isExporter isProcessor }} + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" +{{- end }} ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -111,19 +117,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -202,19 +208,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -449,4 +455,41 @@ func TestComponentLifecycle(t *testing.T) { }) } } -{{ end }} \ No newline at end of file +{{ end }} + +{{ if or isExporter isProcessor -}} +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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} +{{- end }} diff --git a/cmd/otelcontribcol/exporters_test.go b/cmd/otelcontribcol/exporters_test.go index 85c98ed8665a..6355a1e4d328 100644 --- a/cmd/otelcontribcol/exporters_test.go +++ b/cmd/otelcontribcol/exporters_test.go @@ -9,6 +9,7 @@ import ( "path/filepath" "runtime" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -20,6 +21,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/exporter/otlpexporter" "go.opentelemetry.io/collector/exporter/otlphttpexporter" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" @@ -62,7 +67,6 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/tencentcloudlogserviceexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" ) func TestDefaultExporters(t *testing.T) { @@ -631,19 +635,19 @@ func verifyExporterLifecycle(t *testing.T, factory exporter.Factory, getConfigFn assert.NotPanics(t, func() { switch e := exp.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(ctx, logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(ctx, metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -658,6 +662,41 @@ func verifyExporterLifecycle(t *testing.T, factory exporter.Factory, getConfigFn } } +func generateTestLogs() 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 generateTestMetrics() 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.Gauge().DataPoints().AppendEmpty() + dp.Attributes().PutStr("test_attr", "value_1") + dp.SetIntValue(123) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return metrics +} + +func generateTestTraces() ptrace.Traces { + traces := ptrace.NewTraces() + rs := traces.ResourceSpans().AppendEmpty() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} + // verifyExporterShutdown is used to test if an exporter type can be shutdown without being started first. func verifyExporterShutdown(tb testing.TB, factory exporter.Factory, getConfigFn getExporterConfigFn) { ctx := context.Background() diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index c1a2fb6e1b7e..92c149bb6153 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -83,7 +83,6 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/dbstorage v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.95.0 @@ -210,6 +209,7 @@ require ( go.opentelemetry.io/collector/extension/ballastextension v0.95.0 go.opentelemetry.io/collector/extension/zpagesextension v0.95.0 go.opentelemetry.io/collector/otelcol v0.95.0 + go.opentelemetry.io/collector/pdata v1.2.0 go.opentelemetry.io/collector/processor v0.95.0 go.opentelemetry.io/collector/processor/batchprocessor v0.95.0 go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.95.0 @@ -536,6 +536,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd v0.95.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.95.0 // indirect @@ -665,7 +666,6 @@ require ( go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.95.0 // indirect go.opentelemetry.io/collector/extension/auth v0.95.0 // indirect go.opentelemetry.io/collector/featuregate v1.2.0 // indirect - go.opentelemetry.io/collector/pdata v1.2.0 // indirect go.opentelemetry.io/collector/semconv v0.95.0 // indirect go.opentelemetry.io/collector/service v0.95.0 // indirect go.opentelemetry.io/contrib/config v0.3.0 // indirect diff --git a/exporter/alertmanagerexporter/generated_component_test.go b/exporter/alertmanagerexporter/generated_component_test.go index dd33c783234d..3defc4a30408 100644 --- a/exporter/alertmanagerexporter/generated_component_test.go +++ b/exporter/alertmanagerexporter/generated_component_test.go @@ -5,6 +5,7 @@ package alertmanagerexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/alertmanagerexporter/go.mod b/exporter/alertmanagerexporter/go.mod index f2fd97ebc547..9816e4be33e3 100644 --- a/exporter/alertmanagerexporter/go.mod +++ b/exporter/alertmanagerexporter/go.mod @@ -5,7 +5,6 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.2.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/prometheus/common v0.46.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 @@ -83,11 +82,3 @@ retract ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/alibabacloudlogserviceexporter/generated_component_test.go b/exporter/alibabacloudlogserviceexporter/generated_component_test.go index dd18c25f2ef1..1a5b93c18252 100644 --- a/exporter/alibabacloudlogserviceexporter/generated_component_test.go +++ b/exporter/alibabacloudlogserviceexporter/generated_component_test.go @@ -5,6 +5,7 @@ package alibabacloudlogserviceexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -108,3 +111,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/awscloudwatchlogsexporter/generated_component_test.go b/exporter/awscloudwatchlogsexporter/generated_component_test.go index 9151822f1465..8883dfc2a9a7 100644 --- a/exporter/awscloudwatchlogsexporter/generated_component_test.go +++ b/exporter/awscloudwatchlogsexporter/generated_component_test.go @@ -5,6 +5,7 @@ package awscloudwatchlogsexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/awscloudwatchlogsexporter/go.mod b/exporter/awscloudwatchlogsexporter/go.mod index d490ea1466e7..03d2f92cac83 100644 --- a/exporter/awscloudwatchlogsexporter/go.mod +++ b/exporter/awscloudwatchlogsexporter/go.mod @@ -8,7 +8,6 @@ require ( github.com/google/uuid v1.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/configretry v0.95.0 @@ -68,16 +67,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/a replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => ../../internal/aws/cwlogs -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - retract ( v0.76.2 v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest diff --git a/exporter/awsemfexporter/generated_component_test.go b/exporter/awsemfexporter/generated_component_test.go index fbfc5f7fff25..ea35dc47fd25 100644 --- a/exporter/awsemfexporter/generated_component_test.go +++ b/exporter/awsemfexporter/generated_component_test.go @@ -5,6 +5,7 @@ package awsemfexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/awskinesisexporter/generated_component_test.go b/exporter/awskinesisexporter/generated_component_test.go index 07a63b08cf28..f3fd1c3523d9 100644 --- a/exporter/awskinesisexporter/generated_component_test.go +++ b/exporter/awskinesisexporter/generated_component_test.go @@ -5,6 +5,7 @@ package awskinesisexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -84,19 +87,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -111,3 +114,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/awskinesisexporter/go.mod b/exporter/awskinesisexporter/go.mod index 4504b9709e70..3158ff539081 100644 --- a/exporter/awskinesisexporter/go.mod +++ b/exporter/awskinesisexporter/go.mod @@ -12,7 +12,6 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/google/uuid v1.6.0 github.com/jaegertracing/jaeger v1.54.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.95.0 github.com/stretchr/testify v1.8.4 @@ -58,6 +57,7 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/openzipkin/zipkin-go v0.4.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.18.0 // indirect diff --git a/exporter/awss3exporter/generated_component_test.go b/exporter/awss3exporter/generated_component_test.go index b9cf5058a1ed..2038e507ad2c 100644 --- a/exporter/awss3exporter/generated_component_test.go +++ b/exporter/awss3exporter/generated_component_test.go @@ -5,6 +5,7 @@ package awss3exporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/awss3exporter/go.mod b/exporter/awss3exporter/go.mod index 0241556c2946..242c23b59561 100644 --- a/exporter/awss3exporter/go.mod +++ b/exporter/awss3exporter/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/aws/aws-sdk-go v1.50.27 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/confmap v0.95.0 @@ -90,6 +89,7 @@ require ( go.opentelemetry.io/otel/sdk v1.23.1 // indirect go.opentelemetry.io/otel/sdk/metric v1.23.1 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect + golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect @@ -101,15 +101,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - retract ( v0.76.2 v0.76.1 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/awsxrayexporter/generated_component_test.go b/exporter/awsxrayexporter/generated_component_test.go index 584949e3f904..a7b07becf657 100644 --- a/exporter/awsxrayexporter/generated_component_test.go +++ b/exporter/awsxrayexporter/generated_component_test.go @@ -5,6 +5,7 @@ package awsxrayexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/azuredataexplorerexporter/generated_component_test.go b/exporter/azuredataexplorerexporter/generated_component_test.go index ad0fdf341179..54491c52a47b 100644 --- a/exporter/azuredataexplorerexporter/generated_component_test.go +++ b/exporter/azuredataexplorerexporter/generated_component_test.go @@ -5,6 +5,7 @@ package azuredataexplorerexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -84,19 +87,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -111,3 +114,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/azuremonitorexporter/generated_component_test.go b/exporter/azuremonitorexporter/generated_component_test.go index 75881fcdef0f..7de2a3a29bcf 100644 --- a/exporter/azuremonitorexporter/generated_component_test.go +++ b/exporter/azuremonitorexporter/generated_component_test.go @@ -5,6 +5,7 @@ package azuremonitorexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/cassandraexporter/generated_component_test.go b/exporter/cassandraexporter/generated_component_test.go index 8e29af758db9..5a85da121b38 100644 --- a/exporter/cassandraexporter/generated_component_test.go +++ b/exporter/cassandraexporter/generated_component_test.go @@ -5,6 +5,7 @@ package cassandraexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -77,19 +80,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -104,3 +107,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/clickhouseexporter/generated_component_test.go b/exporter/clickhouseexporter/generated_component_test.go index 2884cf1302f4..2bdf05a34cd6 100644 --- a/exporter/clickhouseexporter/generated_component_test.go +++ b/exporter/clickhouseexporter/generated_component_test.go @@ -5,6 +5,7 @@ package clickhouseexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -84,19 +87,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -111,3 +114,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/coralogixexporter/generated_component_test.go b/exporter/coralogixexporter/generated_component_test.go index 6ea095941f58..3011168bdf30 100644 --- a/exporter/coralogixexporter/generated_component_test.go +++ b/exporter/coralogixexporter/generated_component_test.go @@ -5,6 +5,7 @@ package coralogixexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/coralogixexporter/go.mod b/exporter/coralogixexporter/go.mod index 79feb655e2cf..05ce6f323c2d 100644 --- a/exporter/coralogixexporter/go.mod +++ b/exporter/coralogixexporter/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/configcompression v0.95.0 @@ -85,11 +84,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/datadogexporter/generated_component_test.go b/exporter/datadogexporter/generated_component_test.go index c0e112ff059c..5442ceff503e 100644 --- a/exporter/datadogexporter/generated_component_test.go +++ b/exporter/datadogexporter/generated_component_test.go @@ -5,6 +5,7 @@ package datadogexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/datasetexporter/generated_component_test.go b/exporter/datasetexporter/generated_component_test.go index d5e269fea684..9c6c1d23449c 100644 --- a/exporter/datasetexporter/generated_component_test.go +++ b/exporter/datasetexporter/generated_component_test.go @@ -5,6 +5,7 @@ package datasetexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -77,19 +80,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -104,3 +107,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/dynatraceexporter/generated_component_test.go b/exporter/dynatraceexporter/generated_component_test.go index 08ed45e16a38..676d2c1b20d8 100644 --- a/exporter/dynatraceexporter/generated_component_test.go +++ b/exporter/dynatraceexporter/generated_component_test.go @@ -5,6 +5,7 @@ package dynatraceexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/dynatraceexporter/go.mod b/exporter/dynatraceexporter/go.mod index 20fb44db5ec3..db873283241a 100644 --- a/exporter/dynatraceexporter/go.mod +++ b/exporter/dynatraceexporter/go.mod @@ -6,7 +6,6 @@ go 1.21 require ( github.com/dynatrace-oss/dynatrace-metric-utils-go v0.5.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 diff --git a/exporter/elasticsearchexporter/generated_component_test.go b/exporter/elasticsearchexporter/generated_component_test.go index ecd2594bfa0e..502a2e8c0be6 100644 --- a/exporter/elasticsearchexporter/generated_component_test.go +++ b/exporter/elasticsearchexporter/generated_component_test.go @@ -5,6 +5,7 @@ package elasticsearchexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -74,19 +77,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -101,3 +104,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/fileexporter/generated_component_test.go b/exporter/fileexporter/generated_component_test.go index 53e25c36a807..9277900911c8 100644 --- a/exporter/fileexporter/generated_component_test.go +++ b/exporter/fileexporter/generated_component_test.go @@ -5,6 +5,7 @@ package fileexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/honeycombmarkerexporter/generated_component_test.go b/exporter/honeycombmarkerexporter/generated_component_test.go index 381375b5bedc..6ffcfac1cd69 100644 --- a/exporter/honeycombmarkerexporter/generated_component_test.go +++ b/exporter/honeycombmarkerexporter/generated_component_test.go @@ -5,6 +5,7 @@ package honeycombmarkerexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/honeycombmarkerexporter/go.mod b/exporter/honeycombmarkerexporter/go.mod index ffc445e17d31..b912d953c112 100644 --- a/exporter/honeycombmarkerexporter/go.mod +++ b/exporter/honeycombmarkerexporter/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/honeyc go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.95.0 github.com/stretchr/testify v1.8.4 @@ -49,6 +48,7 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect diff --git a/exporter/influxdbexporter/generated_component_test.go b/exporter/influxdbexporter/generated_component_test.go index a5036c37bb61..62abd6499797 100644 --- a/exporter/influxdbexporter/generated_component_test.go +++ b/exporter/influxdbexporter/generated_component_test.go @@ -5,6 +5,7 @@ package influxdbexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/influxdbexporter/go.mod b/exporter/influxdbexporter/go.mod index fac7137321d3..c32f8d1a4c38 100644 --- a/exporter/influxdbexporter/go.mod +++ b/exporter/influxdbexporter/go.mod @@ -7,7 +7,6 @@ require ( github.com/influxdata/influxdb-observability/common v0.5.8 github.com/influxdata/influxdb-observability/otel2influx v0.5.8 github.com/influxdata/line-protocol/v2 v2.2.1 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/confighttp v0.95.0 @@ -16,6 +15,7 @@ require ( go.opentelemetry.io/collector/confmap v0.95.0 go.opentelemetry.io/collector/consumer v0.95.0 go.opentelemetry.io/collector/exporter v0.95.0 + go.opentelemetry.io/collector/pdata v1.2.0 go.opentelemetry.io/otel/metric v1.23.1 go.opentelemetry.io/otel/trace v1.23.1 go.uber.org/goleak v1.3.0 @@ -62,7 +62,6 @@ require ( go.opentelemetry.io/collector/extension v0.95.0 // indirect go.opentelemetry.io/collector/extension/auth v0.95.0 // indirect go.opentelemetry.io/collector/featuregate v1.2.0 // indirect - go.opentelemetry.io/collector/pdata v1.2.0 // indirect go.opentelemetry.io/collector/receiver v0.95.0 // indirect go.opentelemetry.io/collector/semconv v0.95.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect @@ -85,11 +84,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/instanaexporter/generated_component_test.go b/exporter/instanaexporter/generated_component_test.go index 6e39520796e1..121013fb1532 100644 --- a/exporter/instanaexporter/generated_component_test.go +++ b/exporter/instanaexporter/generated_component_test.go @@ -5,6 +5,7 @@ package instanaexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/kineticaexporter/generated_component_test.go b/exporter/kineticaexporter/generated_component_test.go index db225e8076af..93bbd9ca8f25 100644 --- a/exporter/kineticaexporter/generated_component_test.go +++ b/exporter/kineticaexporter/generated_component_test.go @@ -5,6 +5,7 @@ package kineticaexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -84,19 +87,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -111,3 +114,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/kineticaexporter/go.mod b/exporter/kineticaexporter/go.mod index c40bce685b33..7fe0fd5942b4 100644 --- a/exporter/kineticaexporter/go.mod +++ b/exporter/kineticaexporter/go.mod @@ -21,8 +21,6 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect ) -require github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 - require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -80,11 +78,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/loadbalancingexporter/generated_component_test.go b/exporter/loadbalancingexporter/generated_component_test.go index e99a1fec7f4d..dc4ecd558d06 100644 --- a/exporter/loadbalancingexporter/generated_component_test.go +++ b/exporter/loadbalancingexporter/generated_component_test.go @@ -5,6 +5,7 @@ package loadbalancingexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/loadbalancingexporter/go.mod b/exporter/loadbalancingexporter/go.mod index 6be684c4c308..d80e76ed8a8a 100644 --- a/exporter/loadbalancingexporter/go.mod +++ b/exporter/loadbalancingexporter/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadba go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal v0.95.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 @@ -123,6 +122,7 @@ require ( go.opentelemetry.io/otel/sdk v1.23.1 // indirect go.opentelemetry.io/otel/sdk/metric v1.23.1 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect + golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sys v0.17.0 // indirect @@ -155,11 +155,3 @@ retract ( // ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules replace cloud.google.com/go v0.65.0 => cloud.google.com/go v0.110.10 - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/logicmonitorexporter/generated_component_test.go b/exporter/logicmonitorexporter/generated_component_test.go index 00c045f96213..e27b6e3be245 100644 --- a/exporter/logicmonitorexporter/generated_component_test.go +++ b/exporter/logicmonitorexporter/generated_component_test.go @@ -5,6 +5,7 @@ package logicmonitorexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -74,19 +77,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -99,3 +102,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/logzioexporter/generated_component_test.go b/exporter/logzioexporter/generated_component_test.go index dc8b7e033279..5e6941274724 100644 --- a/exporter/logzioexporter/generated_component_test.go +++ b/exporter/logzioexporter/generated_component_test.go @@ -5,6 +5,7 @@ package logzioexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -74,19 +77,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -99,3 +102,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/lokiexporter/generated_component_test.go b/exporter/lokiexporter/generated_component_test.go index 777710966172..d094edd09911 100644 --- a/exporter/lokiexporter/generated_component_test.go +++ b/exporter/lokiexporter/generated_component_test.go @@ -5,6 +5,7 @@ package lokiexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/lokiexporter/go.mod b/exporter/lokiexporter/go.mod index 9bb5ee0564a3..444c70be9e7e 100644 --- a/exporter/lokiexporter/go.mod +++ b/exporter/lokiexporter/go.mod @@ -7,7 +7,6 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golang/snappy v0.0.4 github.com/grafana/loki/pkg/push v0.0.0-20231127162423-bd505f8e2d37 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/loki v0.95.0 github.com/prometheus/common v0.46.0 github.com/stretchr/testify v1.8.4 @@ -53,6 +52,7 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.95.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect diff --git a/exporter/mezmoexporter/generated_component_test.go b/exporter/mezmoexporter/generated_component_test.go index e1d848453e13..bc77b0ba8bdd 100644 --- a/exporter/mezmoexporter/generated_component_test.go +++ b/exporter/mezmoexporter/generated_component_test.go @@ -5,6 +5,7 @@ package mezmoexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/mezmoexporter/go.mod b/exporter/mezmoexporter/go.mod index aa232c5df159..789a944894af 100644 --- a/exporter/mezmoexporter/go.mod +++ b/exporter/mezmoexporter/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.2.1 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.92.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/confighttp v0.95.0 @@ -80,11 +79,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/opencensusexporter/generated_component_test.go b/exporter/opencensusexporter/generated_component_test.go index cd30b4f5876f..e6aa4400df8d 100644 --- a/exporter/opencensusexporter/generated_component_test.go +++ b/exporter/opencensusexporter/generated_component_test.go @@ -5,6 +5,7 @@ package opencensusexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -74,19 +77,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -99,3 +102,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/opensearchexporter/generated_component_test.go b/exporter/opensearchexporter/generated_component_test.go index 872678389a65..ff7a13e93ffd 100644 --- a/exporter/opensearchexporter/generated_component_test.go +++ b/exporter/opensearchexporter/generated_component_test.go @@ -5,6 +5,7 @@ package opensearchexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -74,19 +77,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -99,3 +102,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/opensearchexporter/go.mod b/exporter/opensearchexporter/go.mod index 0e028bba7fd7..750addc91121 100644 --- a/exporter/opensearchexporter/go.mod +++ b/exporter/opensearchexporter/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opense go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.95.0 github.com/opensearch-project/opensearch-go/v2 v2.3.0 github.com/stretchr/testify v1.8.4 @@ -84,7 +83,3 @@ require ( replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest diff --git a/exporter/prometheusremotewriteexporter/generated_component_test.go b/exporter/prometheusremotewriteexporter/generated_component_test.go index 6e6ecfaf7b31..4abffc24d7ab 100644 --- a/exporter/prometheusremotewriteexporter/generated_component_test.go +++ b/exporter/prometheusremotewriteexporter/generated_component_test.go @@ -5,6 +5,7 @@ package prometheusremotewriteexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/pulsarexporter/generated_component_test.go b/exporter/pulsarexporter/generated_component_test.go index 875b93412b18..3a30df440ad3 100644 --- a/exporter/pulsarexporter/generated_component_test.go +++ b/exporter/pulsarexporter/generated_component_test.go @@ -5,6 +5,7 @@ package pulsarexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -84,19 +87,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -111,3 +114,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/sapmexporter/generated_component_test.go b/exporter/sapmexporter/generated_component_test.go index 45c1bc886ed4..ba80c3c6be7f 100644 --- a/exporter/sapmexporter/generated_component_test.go +++ b/exporter/sapmexporter/generated_component_test.go @@ -5,6 +5,7 @@ package sapmexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/sapmexporter/go.mod b/exporter/sapmexporter/go.mod index 3a2c99c16521..dbeb97d6ca44 100644 --- a/exporter/sapmexporter/go.mod +++ b/exporter/sapmexporter/go.mod @@ -6,7 +6,6 @@ require ( github.com/cenkalti/backoff/v4 v4.2.1 github.com/jaegertracing/jaeger v1.54.0 github.com/klauspost/compress v1.17.6 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchperresourceattr v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.95.0 @@ -45,6 +44,7 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect diff --git a/exporter/sentryexporter/generated_component_test.go b/exporter/sentryexporter/generated_component_test.go index ad0130d06052..85fd8555573f 100644 --- a/exporter/sentryexporter/generated_component_test.go +++ b/exporter/sentryexporter/generated_component_test.go @@ -5,6 +5,7 @@ package sentryexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -92,3 +95,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/signalfxexporter/generated_component_test.go b/exporter/signalfxexporter/generated_component_test.go index d9bea9b45c54..736570b9ce2d 100644 --- a/exporter/signalfxexporter/generated_component_test.go +++ b/exporter/signalfxexporter/generated_component_test.go @@ -5,6 +5,7 @@ package signalfxexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/skywalkingexporter/generated_component_test.go b/exporter/skywalkingexporter/generated_component_test.go index 9fa2c39c6375..40ca6f3f8429 100644 --- a/exporter/skywalkingexporter/generated_component_test.go +++ b/exporter/skywalkingexporter/generated_component_test.go @@ -5,6 +5,7 @@ package skywalkingexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -77,19 +80,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -104,3 +107,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/splunkhecexporter/generated_component_test.go b/exporter/splunkhecexporter/generated_component_test.go index b6431b687068..82910c3327b1 100644 --- a/exporter/splunkhecexporter/generated_component_test.go +++ b/exporter/splunkhecexporter/generated_component_test.go @@ -5,6 +5,7 @@ package splunkhecexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -81,19 +84,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -106,3 +109,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/sumologicexporter/generated_component_test.go b/exporter/sumologicexporter/generated_component_test.go index fad215a00c06..1ac9bd34461d 100644 --- a/exporter/sumologicexporter/generated_component_test.go +++ b/exporter/sumologicexporter/generated_component_test.go @@ -5,6 +5,7 @@ package sumologicexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -77,19 +80,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -104,3 +107,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/sumologicexporter/go.mod b/exporter/sumologicexporter/go.mod index d2812da5767c..bbb4ad03e074 100644 --- a/exporter/sumologicexporter/go.mod +++ b/exporter/sumologicexporter/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sumolo go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/confighttp v0.95.0 @@ -78,11 +77,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/syslogexporter/generated_component_test.go b/exporter/syslogexporter/generated_component_test.go index 6628d4fb8309..07f4f466a715 100644 --- a/exporter/syslogexporter/generated_component_test.go +++ b/exporter/syslogexporter/generated_component_test.go @@ -5,6 +5,7 @@ package syslogexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -70,19 +73,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -97,3 +100,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/syslogexporter/go.mod b/exporter/syslogexporter/go.mod index c387ede1438f..520e2669977d 100644 --- a/exporter/syslogexporter/go.mod +++ b/exporter/syslogexporter/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslog go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/configretry v0.95.0 @@ -64,11 +63,3 @@ require ( google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/exporter/tencentcloudlogserviceexporter/generated_component_test.go b/exporter/tencentcloudlogserviceexporter/generated_component_test.go index f295e29ddeaa..4967a45b06ae 100644 --- a/exporter/tencentcloudlogserviceexporter/generated_component_test.go +++ b/exporter/tencentcloudlogserviceexporter/generated_component_test.go @@ -5,6 +5,7 @@ package tencentcloudlogserviceexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -70,19 +73,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -97,3 +100,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/zipkinexporter/generated_component_test.go b/exporter/zipkinexporter/generated_component_test.go index 6ea0689f46e0..f101c9eb8c55 100644 --- a/exporter/zipkinexporter/generated_component_test.go +++ b/exporter/zipkinexporter/generated_component_test.go @@ -5,6 +5,7 @@ package zipkinexporter import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -14,8 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -67,19 +70,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case exporter.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case exporter.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case exporter.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -94,3 +97,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/exporter/zipkinexporter/go.mod b/exporter/zipkinexporter/go.mod index 82844481be1d..1690f5bcd38c 100644 --- a/exporter/zipkinexporter/go.mod +++ b/exporter/zipkinexporter/go.mod @@ -5,7 +5,6 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.2.1 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.95.0 github.com/openzipkin/zipkin-go v0.4.2 @@ -49,6 +48,7 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect diff --git a/processor/attributesprocessor/generated_component_test.go b/processor/attributesprocessor/generated_component_test.go index 62a5682fe600..4a7a3157d39c 100644 --- a/processor/attributesprocessor/generated_component_test.go +++ b/processor/attributesprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package attributesprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/cumulativetodeltaprocessor/generated_component_test.go b/processor/cumulativetodeltaprocessor/generated_component_test.go index 2aa48fe2cd24..c98b6372ce58 100644 --- a/processor/cumulativetodeltaprocessor/generated_component_test.go +++ b/processor/cumulativetodeltaprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package cumulativetodeltaprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/cumulativetodeltaprocessor/go.mod b/processor/cumulativetodeltaprocessor/go.mod index 9a1dba4fe0dd..4fb85a0d092b 100644 --- a/processor/cumulativetodeltaprocessor/go.mod +++ b/processor/cumulativetodeltaprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumul go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.95.0 github.com/stretchr/testify v1.8.4 diff --git a/processor/deltatorateprocessor/generated_component_test.go b/processor/deltatorateprocessor/generated_component_test.go index 77033d728b4c..c4b4cc98cea9 100644 --- a/processor/deltatorateprocessor/generated_component_test.go +++ b/processor/deltatorateprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package deltatorateprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/deltatorateprocessor/go.mod b/processor/deltatorateprocessor/go.mod index 7be6aa8f4ac0..d1e0fcf26e29 100644 --- a/processor/deltatorateprocessor/go.mod +++ b/processor/deltatorateprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/delta go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/confmap v0.95.0 @@ -60,11 +59,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/filterprocessor/generated_component_test.go b/processor/filterprocessor/generated_component_test.go index e543e7fe9864..a1c10681ab19 100644 --- a/processor/filterprocessor/generated_component_test.go +++ b/processor/filterprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package filterprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/groupbyattrsprocessor/generated_component_test.go b/processor/groupbyattrsprocessor/generated_component_test.go index 1bc6a07df1a7..92cdc7be38ed 100644 --- a/processor/groupbyattrsprocessor/generated_component_test.go +++ b/processor/groupbyattrsprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package groupbyattrsprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/groupbyattrsprocessor/go.mod b/processor/groupbyattrsprocessor/go.mod index 62e856e59398..5b15bde47c2f 100644 --- a/processor/groupbyattrsprocessor/go.mod +++ b/processor/groupbyattrsprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/group go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 @@ -63,9 +62,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/groupbytraceprocessor/generated_component_test.go b/processor/groupbytraceprocessor/generated_component_test.go index ce92838a2c07..2b535231b2bd 100644 --- a/processor/groupbytraceprocessor/generated_component_test.go +++ b/processor/groupbytraceprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package groupbytraceprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/groupbytraceprocessor/go.mod b/processor/groupbytraceprocessor/go.mod index 3407fa2e6cde..a6c80e31d6a1 100644 --- a/processor/groupbytraceprocessor/go.mod +++ b/processor/groupbytraceprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/group go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal v0.95.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 @@ -63,11 +62,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal diff --git a/processor/intervalprocessor/generated_component_test.go b/processor/intervalprocessor/generated_component_test.go index 55e89c63bcaa..44ad268c708b 100644 --- a/processor/intervalprocessor/generated_component_test.go +++ b/processor/intervalprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package intervalprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/intervalprocessor/go.mod b/processor/intervalprocessor/go.mod index 91a20a83db50..54210d1d6a5b 100644 --- a/processor/intervalprocessor/go.mod +++ b/processor/intervalprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/inter go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/confmap v0.95.0 @@ -53,11 +52,3 @@ require ( google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/k8sattributesprocessor/generated_component_test.go b/processor/k8sattributesprocessor/generated_component_test.go index f0a0c25e19a8..a51c48a2b09f 100644 --- a/processor/k8sattributesprocessor/generated_component_test.go +++ b/processor/k8sattributesprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package k8sattributesprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/k8sattributesprocessor/go.mod b/processor/k8sattributesprocessor/go.mod index f11c0ac6b55a..4c2bae587d04 100644 --- a/processor/k8sattributesprocessor/go.mod +++ b/processor/k8sattributesprocessor/go.mod @@ -5,7 +5,6 @@ go 1.21 require ( github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8stest v0.95.0 github.com/stretchr/testify v1.8.4 @@ -83,6 +82,7 @@ require ( github.com/prometheus/common v0.46.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rs/cors v1.10.1 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/pflag v1.0.5 // indirect go.opentelemetry.io/collector/config/configauth v0.95.0 // indirect go.opentelemetry.io/collector/config/configcompression v0.95.0 // indirect @@ -139,11 +139,3 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8ste // ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules replace cloud.google.com/go v0.54.0 => cloud.google.com/go v0.110.10 - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/k8sattributesprocessor/go.sum b/processor/k8sattributesprocessor/go.sum index ecee8338a46e..850f57c446d7 100644 --- a/processor/k8sattributesprocessor/go.sum +++ b/processor/k8sattributesprocessor/go.sum @@ -1588,6 +1588,7 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/processor/logstransformprocessor/generated_component_test.go b/processor/logstransformprocessor/generated_component_test.go index 1d501d91b8b0..a41f784c0c97 100644 --- a/processor/logstransformprocessor/generated_component_test.go +++ b/processor/logstransformprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package logstransformprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/metricsgenerationprocessor/generated_component_test.go b/processor/metricsgenerationprocessor/generated_component_test.go index 8a181b4e6698..9082da7a3e9c 100644 --- a/processor/metricsgenerationprocessor/generated_component_test.go +++ b/processor/metricsgenerationprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package metricsgenerationprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/metricsgenerationprocessor/go.mod b/processor/metricsgenerationprocessor/go.mod index 9487908734a1..85ab9614c213 100644 --- a/processor/metricsgenerationprocessor/go.mod +++ b/processor/metricsgenerationprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/metri go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/confmap v0.95.0 @@ -60,11 +59,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/metricstransformprocessor/generated_component_test.go b/processor/metricstransformprocessor/generated_component_test.go index 94671ff4cadb..a0c7dda382c1 100644 --- a/processor/metricstransformprocessor/generated_component_test.go +++ b/processor/metricstransformprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package metricstransformprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/metricstransformprocessor/go.mod b/processor/metricstransformprocessor/go.mod index 9275284cf362..a6b31168ca6d 100644 --- a/processor/metricstransformprocessor/go.mod +++ b/processor/metricstransformprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/metri go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.95.0 github.com/stretchr/testify v1.8.4 @@ -69,5 +68,3 @@ retract ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal diff --git a/processor/probabilisticsamplerprocessor/generated_component_test.go b/processor/probabilisticsamplerprocessor/generated_component_test.go index 95cd7b34399e..dd0db722638b 100644 --- a/processor/probabilisticsamplerprocessor/generated_component_test.go +++ b/processor/probabilisticsamplerprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package probabilisticsamplerprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -75,19 +78,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -100,3 +103,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/redactionprocessor/generated_component_test.go b/processor/redactionprocessor/generated_component_test.go index cdbdd0240117..577f1e79b0b0 100644 --- a/processor/redactionprocessor/generated_component_test.go +++ b/processor/redactionprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package redactionprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/redactionprocessor/go.mod b/processor/redactionprocessor/go.mod index 11eb814dd3ee..b6b085a5efd6 100644 --- a/processor/redactionprocessor/go.mod +++ b/processor/redactionprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/redac go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/confmap v0.95.0 @@ -60,11 +59,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden diff --git a/processor/remotetapprocessor/generated_component_test.go b/processor/remotetapprocessor/generated_component_test.go index ba943ba66e8d..8db97638541f 100644 --- a/processor/remotetapprocessor/generated_component_test.go +++ b/processor/remotetapprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package remotetapprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/remotetapprocessor/go.mod b/processor/remotetapprocessor/go.mod index d40951de8ed6..0a4e4c250a52 100644 --- a/processor/remotetapprocessor/go.mod +++ b/processor/remotetapprocessor/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 @@ -75,12 +74,4 @@ require ( replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent => ../../internal/sharedcomponent -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common diff --git a/processor/resourcedetectionprocessor/generated_component_test.go b/processor/resourcedetectionprocessor/generated_component_test.go index 0856768bb12d..9e7bca7be8d7 100644 --- a/processor/resourcedetectionprocessor/generated_component_test.go +++ b/processor/resourcedetectionprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package resourcedetectionprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index 9dc64a85145f..b75dc2ee8d02 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -10,7 +10,6 @@ require ( github.com/hashicorp/consul/api v1.27.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/metadataproviders v0.95.0 github.com/shirou/gopsutil/v3 v3.24.1 @@ -88,6 +87,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -104,6 +104,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/rs/cors v1.10.1 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect @@ -160,13 +161,5 @@ retract ( replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig => ../../internal/k8sconfig -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - // openshift removed all tags from their repo, use the pseudoversion from the release-3.9 branch HEAD replace github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37 diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index 539bd926f1c2..d204d44b2880 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -443,6 +443,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -655,6 +656,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/processor/resourceprocessor/generated_component_test.go b/processor/resourceprocessor/generated_component_test.go index 3245c91c3eb1..8cd8d082c8fe 100644 --- a/processor/resourceprocessor/generated_component_test.go +++ b/processor/resourceprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package resourceprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/routingprocessor/generated_component_test.go b/processor/routingprocessor/generated_component_test.go index 7c7f7d1d9b01..c93711928d18 100644 --- a/processor/routingprocessor/generated_component_test.go +++ b/processor/routingprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package routingprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/routingprocessor/go.mod b/processor/routingprocessor/go.mod index 8f114c666c3f..d995c4f48690 100644 --- a/processor/routingprocessor/go.mod +++ b/processor/routingprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/routi go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.95.0 @@ -52,6 +51,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mostynb/go-grpc-compression v1.2.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect diff --git a/processor/schemaprocessor/generated_component_test.go b/processor/schemaprocessor/generated_component_test.go index 3943f49464b4..1ce899af54b8 100644 --- a/processor/schemaprocessor/generated_component_test.go +++ b/processor/schemaprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package schemaprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/schemaprocessor/go.mod b/processor/schemaprocessor/go.mod index 523eb9df0c1c..edde0a049a85 100644 --- a/processor/schemaprocessor/go.mod +++ b/processor/schemaprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/schem go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/config/confighttp v0.95.0 @@ -77,11 +76,3 @@ retract ( v0.76.1 v0.65.0 ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil diff --git a/processor/spanprocessor/generated_component_test.go b/processor/spanprocessor/generated_component_test.go index cc4514b6ab2b..9f2311327725 100644 --- a/processor/spanprocessor/generated_component_test.go +++ b/processor/spanprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package spanprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/sumologicprocessor/generated_component_test.go b/processor/sumologicprocessor/generated_component_test.go index 8542cb7fd838..fa2878ed9971 100644 --- a/processor/sumologicprocessor/generated_component_test.go +++ b/processor/sumologicprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package sumologicprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/sumologicprocessor/go.mod b/processor/sumologicprocessor/go.mod index 732cb720ac0c..ba6491b4eb74 100644 --- a/processor/sumologicprocessor/go.mod +++ b/processor/sumologicprocessor/go.mod @@ -3,7 +3,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/processor/sumol go 1.21 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector/component v0.95.0 go.opentelemetry.io/collector/confmap v0.95.0 @@ -88,6 +87,7 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.23.1 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect go.uber.org/multierr v1.11.0 // indirect + golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect @@ -98,11 +98,3 @@ require ( google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil => ../../pkg/pdatautil - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest => ../../pkg/pdatatest - -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden - -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal => ../../internal/coreinternal diff --git a/processor/tailsamplingprocessor/generated_component_test.go b/processor/tailsamplingprocessor/generated_component_test.go index db4d577b3811..61ee654fc870 100644 --- a/processor/tailsamplingprocessor/generated_component_test.go +++ b/processor/tailsamplingprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package tailsamplingprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -68,19 +71,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -93,3 +96,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/transformprocessor/generated_component_test.go b/processor/transformprocessor/generated_component_test.go index 7733983b756d..13dc81eddae2 100644 --- a/processor/transformprocessor/generated_component_test.go +++ b/processor/transformprocessor/generated_component_test.go @@ -5,6 +5,7 @@ package transformprocessor import ( "context" "testing" + "time" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" @@ -15,8 +16,10 @@ import ( "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/confmap/confmaptest" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // assertNoErrorHost implements a component.Host that asserts that there were no errors. @@ -82,19 +85,19 @@ func TestComponentLifecycle(t *testing.T) { require.NotPanics(t, func() { switch e := c.(type) { case processor.Logs: - logs := testdata.GenerateLogsManyLogRecordsSameResource(2) + logs := generateLifecycleTestLogs() if !e.Capabilities().MutatesData { logs.MarkReadOnly() } err = e.ConsumeLogs(context.Background(), logs) case processor.Metrics: - metrics := testdata.GenerateMetricsTwoMetrics() + metrics := generateLifecycleTestMetrics() if !e.Capabilities().MutatesData { metrics.MarkReadOnly() } err = e.ConsumeMetrics(context.Background(), metrics) case processor.Traces: - traces := testdata.GenerateTracesTwoSpansSameResource() + traces := generateLifecycleTestTraces() if !e.Capabilities().MutatesData { traces.MarkReadOnly() } @@ -107,3 +110,38 @@ 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() + rs.Resource().Attributes().PutStr("resource", "R1") + span := rs.ScopeSpans().AppendEmpty().Spans().AppendEmpty() + span.Attributes().PutStr("test_attr", "value_1") + span.SetName("test_span") + span.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now().Add(-1 * time.Second))) + span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.Now())) + return traces +} diff --git a/processor/transformprocessor/go.mod b/processor/transformprocessor/go.mod index f631a0be1332..2c14bb290301 100644 --- a/processor/transformprocessor/go.mod +++ b/processor/transformprocessor/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.95.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.95.0 github.com/stretchr/testify v1.8.4 @@ -44,6 +43,7 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.95.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.18.0 // indirect