From be94c019296374d535f6eca041a4b46626b64e70 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 19 Apr 2022 11:16:52 +0200 Subject: [PATCH] refactor: use module per signal type Mitigates https://github.com/open-telemetry/opentelemetry-collector/pull/5168 Signed-off-by: Dominik Rosiek --- .../sumologicexporter/carbon_formatter.go | 23 +-- .../carbon_formatter_test.go | 21 +-- pkg/exporter/sumologicexporter/exporter.go | 25 +-- .../sumologicexporter/exporter_test.go | 146 +++++++++--------- pkg/exporter/sumologicexporter/fields.go | 8 +- pkg/exporter/sumologicexporter/fields_test.go | 6 +- pkg/exporter/sumologicexporter/filter.go | 14 +- pkg/exporter/sumologicexporter/filter_test.go | 6 +- pkg/exporter/sumologicexporter/go.mod | 20 ++- pkg/exporter/sumologicexporter/go.sum | 48 +++--- .../sumologicexporter/graphite_formatter.go | 23 +-- .../sumologicexporter/prometheus_formatter.go | 69 +++++---- .../prometheus_formatter_test.go | 11 +- pkg/exporter/sumologicexporter/sender.go | 57 +++---- pkg/exporter/sumologicexporter/sender_test.go | 122 ++++++++------- .../sumologicexporter/source_format.go | 6 +- .../sumologicexporter/test_data_test.go | 96 ++++++------ .../sumologicexporter/translate_attributes.go | 12 +- .../translate_attributes_test.go | 52 +++---- .../sumologicexporter/translate_metrics.go | 4 +- .../translate_metrics_test.go | 4 +- pkg/extension/sumologicextension/go.mod | 17 +- pkg/extension/sumologicextension/go.sum | 33 ++-- .../big_endian_converter.go | 18 +-- .../big_endian_converter_test.go | 18 +-- .../cascading_test.go | 61 ++++---- pkg/processor/cascadingfilterprocessor/go.mod | 13 +- pkg/processor/cascadingfilterprocessor/go.sum | 35 ++--- .../idbatcher/id_batcher.go | 14 +- .../idbatcher/id_batcher_test.go | 8 +- .../cascadingfilterprocessor/processor.go | 29 ++-- .../processor_test.go | 43 +++--- .../sampling/always_sample_test.go | 6 +- .../sampling/attrs_filter_test.go | 13 +- .../sampling/drop_trace_factory.go | 4 +- .../sampling/numeric_tag_filter_test.go | 27 ++-- .../sampling/policy.go | 9 +- .../sampling/policy_filter.go | 23 +-- .../sampling/rate_limiting_test.go | 6 +- .../sampling/span_properties_filter_test.go | 15 +- .../sampling/string_tag_filter_test.go | 31 ++-- pkg/processor/k8sprocessor/go.mod | 23 +-- pkg/processor/k8sprocessor/go.sum | 47 +++--- pkg/processor/k8sprocessor/pod_association.go | 8 +- pkg/processor/k8sprocessor/processor.go | 13 +- pkg/processor/k8sprocessor/processor_test.go | 63 ++++---- pkg/processor/metricfrequencyprocessor/go.mod | 13 +- pkg/processor/metricfrequencyprocessor/go.sum | 35 ++--- .../metricfrequencyprocessor/metriccache.go | 11 +- .../metriccache_test.go | 21 +-- .../metricfrequencyprocessor/pdata.go | 13 +- .../metricfrequencyprocessor/processor.go | 8 +- .../processor_test.go | 35 +++-- .../metricfrequencyprocessor/sieve.go | 43 +++--- .../sieve_helper_test.go | 10 +- .../metricfrequencyprocessor/sieve_test.go | 23 +-- .../sourceprocessor/attribute_filler.go | 8 +- pkg/processor/sourceprocessor/go.mod | 13 +- pkg/processor/sourceprocessor/go.sum | 35 ++--- .../sourceprocessor/source_category_filler.go | 10 +- .../source_category_filler_test.go | 14 +- .../sourceprocessor/source_processor.go | 39 ++--- .../sourceprocessor/source_processor_test.go | 48 +++--- .../cloud_namespace_processor.go | 13 +- pkg/processor/sumologicschemaprocessor/go.mod | 15 +- pkg/processor/sumologicschemaprocessor/go.sum | 37 ++--- .../sumologicschemaprocessor/processor.go | 10 +- .../processor_test.go | 124 +++++++-------- pkg/processor/sumologicsyslogprocessor/go.mod | 13 +- pkg/processor/sumologicsyslogprocessor/go.sum | 35 ++--- .../sumologicsyslogprocessor/processor.go | 4 +- .../processor_test.go | 4 +- pkg/receiver/telegrafreceiver/README.md | 4 +- pkg/receiver/telegrafreceiver/converter.go | 56 +++---- .../telegrafreceiver/converter_test.go | 143 ++++++++--------- pkg/receiver/telegrafreceiver/go.mod | 29 ++-- pkg/receiver/telegrafreceiver/go.sum | 70 +++++---- pkg/receiver/telegrafreceiver/metric_opt.go | 43 +++--- pkg/receiver/telegrafreceiver/receiver.go | 8 +- .../telegrafreceiver/receiver_test.go | 8 +- 80 files changed, 1183 insertions(+), 1162 deletions(-) diff --git a/pkg/exporter/sumologicexporter/carbon_formatter.go b/pkg/exporter/sumologicexporter/carbon_formatter.go index 31371b7749..6c0617b6ae 100644 --- a/pkg/exporter/sumologicexporter/carbon_formatter.go +++ b/pkg/exporter/sumologicexporter/carbon_formatter.go @@ -18,14 +18,15 @@ import ( "fmt" "strings" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) // carbon2TagString returns all attributes as space spearated key=value pairs. // In addition, metric name and unit are also included. // In case `metric` or `unit` attributes has been set too, they are prefixed // with underscore `_` to avoid overwriting the metric name and unit. -func carbon2TagString(metric pdata.Metric, attributes pdata.Map) string { +func carbon2TagString(metric pmetric.Metric, attributes pcommon.Map) string { length := attributes.Len() if _, ok := attributes.Get("metric"); ok { @@ -37,7 +38,7 @@ func carbon2TagString(metric pdata.Metric, attributes pdata.Map) string { } returnValue := make([]string, 0, length) - attributes.Range(func(k string, v pdata.AttributeValue) bool { + attributes.Range(func(k string, v pcommon.Value) bool { if k == "name" || k == "unit" { k = fmt.Sprintf("_%s", k) } @@ -65,15 +66,15 @@ func sanitizeCarbonString(text string) string { // carbon2NumberRecord converts NumberDataPoint to carbon2 metric string // with additional information from metricPair. -func carbon2NumberRecord(metric pdata.Metric, attributes pdata.Map, dataPoint pdata.NumberDataPoint) string { +func carbon2NumberRecord(metric pmetric.Metric, attributes pcommon.Map, dataPoint pmetric.NumberDataPoint) string { switch dataPoint.ValueType() { - case pdata.MetricValueTypeDouble: + case pmetric.MetricValueTypeDouble: return fmt.Sprintf("%s %g %d", carbon2TagString(metric, attributes), dataPoint.DoubleVal(), dataPoint.Timestamp()/1e9, ) - case pdata.MetricValueTypeInt: + case pmetric.MetricValueTypeInt: return fmt.Sprintf("%s %d %d", carbon2TagString(metric, attributes), dataPoint.IntVal(), @@ -84,25 +85,25 @@ func carbon2NumberRecord(metric pdata.Metric, attributes pdata.Map, dataPoint pd } // carbon2metric2String converts metric to Carbon2 formatted string. -func carbon2Metric2String(metric pdata.Metric, attributes pdata.Map) string { +func carbon2Metric2String(metric pmetric.Metric, attributes pcommon.Map) string { var nextLines []string switch metric.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: dps := metric.Gauge().DataPoints() nextLines = make([]string, 0, dps.Len()) for i := 0; i < dps.Len(); i++ { nextLines = append(nextLines, carbon2NumberRecord(metric, attributes, dps.At(i))) } - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: dps := metric.Sum().DataPoints() nextLines = make([]string, 0, dps.Len()) for i := 0; i < dps.Len(); i++ { nextLines = append(nextLines, carbon2NumberRecord(metric, attributes, dps.At(i))) } // Skip complex metrics - case pdata.MetricDataTypeHistogram: - case pdata.MetricDataTypeSummary: + case pmetric.MetricDataTypeHistogram: + case pmetric.MetricDataTypeSummary: } return strings.Join(nextLines, "\n") diff --git a/pkg/exporter/sumologicexporter/carbon_formatter_test.go b/pkg/exporter/sumologicexporter/carbon_formatter_test.go index 80a450f6a0..5030e05ec6 100644 --- a/pkg/exporter/sumologicexporter/carbon_formatter_test.go +++ b/pkg/exporter/sumologicexporter/carbon_formatter_test.go @@ -18,7 +18,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestCarbon2TagString(t *testing.T) { @@ -40,9 +41,9 @@ func TestCarbon2TagString(t *testing.T) { } func TestCarbon2InvalidCharacters(t *testing.T) { - metric := pdata.NewMetric() + metric := pmetric.NewMetric() - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("= \n\r", "= \n\r") metric.SetName("= \n\r") @@ -105,49 +106,49 @@ func TestCarbonMetricDataTypeHistogram(t *testing.T) { func TestCarbonMetrics(t *testing.T) { type testCase struct { name string - metricFunc func() (pdata.Metric, pdata.Map) + metricFunc func() (pmetric.Metric, pcommon.Map) expected string } tests := []testCase{ { name: "empty int gauge", - metricFunc: func() (pdata.Metric, pdata.Map) { + metricFunc: func() (pmetric.Metric, pcommon.Map) { return buildExampleIntGaugeMetric(false) }, expected: "", }, { name: "empty double gauge", - metricFunc: func() (pdata.Metric, pdata.Map) { + metricFunc: func() (pmetric.Metric, pcommon.Map) { return buildExampleDoubleGaugeMetric(false) }, expected: "", }, { name: "empty int sum", - metricFunc: func() (pdata.Metric, pdata.Map) { + metricFunc: func() (pmetric.Metric, pcommon.Map) { return buildExampleIntSumMetric(false) }, expected: "", }, { name: "empty double sum", - metricFunc: func() (pdata.Metric, pdata.Map) { + metricFunc: func() (pmetric.Metric, pcommon.Map) { return buildExampleDoubleSumMetric(false) }, expected: "", }, { name: "empty summary", - metricFunc: func() (pdata.Metric, pdata.Map) { + metricFunc: func() (pmetric.Metric, pcommon.Map) { return buildExampleSummaryMetric(false) }, expected: "", }, { name: "empty histogram", - metricFunc: func() (pdata.Metric, pdata.Map) { + metricFunc: func() (pmetric.Metric, pcommon.Map) { return buildExampleHistogramMetric(false) }, expected: "", diff --git a/pkg/exporter/sumologicexporter/exporter.go b/pkg/exporter/sumologicexporter/exporter.go index 4b46b561a9..f77d7fafee 100644 --- a/pkg/exporter/sumologicexporter/exporter.go +++ b/pkg/exporter/sumologicexporter/exporter.go @@ -25,7 +25,10 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/exporter/exporterhelper" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/multierr" "go.uber.org/zap" @@ -181,7 +184,7 @@ func newTracesExporter( // pushLogsData groups data with common metadata and sends them as separate batched requests. // It returns the number of unsent logs and an error which contains a list of dropped records // so they can be handled by OTC retry mechanism -func (se *sumologicexporter) pushLogsData(ctx context.Context, ld pdata.Logs) error { +func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) error { compr, err := se.getCompressor() if err != nil { return consumererror.NewLogs(err, ld) @@ -212,8 +215,8 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld pdata.Logs) er } type droppedResourceRecords struct { - resource pdata.Resource - records []pdata.LogRecord + resource pcommon.Resource + records []plog.LogRecord } var ( errs []error @@ -241,7 +244,7 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld pdata.Logs) er } if len(dropped) > 0 { - ld = pdata.NewLogs() + ld = plog.NewLogs() // Move all dropped records to Logs // NOTE: we only copy resource and log records here. @@ -268,7 +271,7 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld pdata.Logs) er // pushMetricsData groups data with common metadata and send them as separate batched requests // it returns number of unsent metrics and error which contains list of dropped records // so they can be handle by the OTC retry mechanism -func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pdata.Metrics) error { +func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pmetric.Metrics) error { compr, err := se.getCompressor() if err != nil { return consumererror.NewMetrics(err, md) @@ -299,8 +302,8 @@ func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pdata.Metri } type droppedResourceMetrics struct { - resource pdata.Resource - metrics []pdata.Metric + resource pcommon.Resource + metrics []pmetric.Metric } var ( errs []error @@ -340,7 +343,7 @@ func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pdata.Metri } if len(dropped) > 0 { - md = pdata.NewMetrics() + md = pmetric.NewMetrics() // Move all dropped records to Metrics // NOTE: we only copy resource and metrics here. @@ -382,7 +385,7 @@ func (se *sumologicexporter) handleUnauthorizedErrors(ctx context.Context, errs } } -func (se *sumologicexporter) pushTracesData(ctx context.Context, td pdata.Traces) error { +func (se *sumologicexporter) pushTracesData(ctx context.Context, td ptrace.Traces) error { compr, err := se.getCompressor() if err != nil { return consumererror.NewTraces(err, td) @@ -526,6 +529,6 @@ func (se *sumologicexporter) shutdown(context.Context) error { return nil } -func (se *sumologicexporter) dropRoutingAttribute(attr pdata.AttributeMap) { +func (se *sumologicexporter) dropRoutingAttribute(attr pcommon.Map) { attr.Delete(se.config.DropRoutingAttribute) } diff --git a/pkg/exporter/sumologicexporter/exporter_test.go b/pkg/exporter/sumologicexporter/exporter_test.go index 2aa0b6e618..2ad85c6605 100644 --- a/pkg/exporter/sumologicexporter/exporter_test.go +++ b/pkg/exporter/sumologicexporter/exporter_test.go @@ -33,12 +33,14 @@ import ( "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" ) -func LogRecordsToLogs(records []pdata.LogRecord) pdata.Logs { - logs := pdata.NewLogs() +func LogRecordsToLogs(records []plog.LogRecord) plog.Logs { + logs := plog.NewLogs() logsSlice := logs.ResourceLogs().AppendEmpty().InstrumentationLibraryLogs().AppendEmpty().LogRecords() for _, record := range records { record.CopyTo(logsSlice.AppendEmpty()) @@ -149,7 +151,7 @@ func TestLogsResourceAttributesSentAsFields(t *testing.T) { name string configFunc func() *Config callbacks []func(w http.ResponseWriter, req *http.Request) - logsFunc func() pdata.Logs + logsFunc func() plog.Logs }{ { name: "text", @@ -169,13 +171,13 @@ func TestLogsResourceAttributesSentAsFields(t *testing.T) { assert.Equal(t, "res_attr1=1, res_attr2=2", req.Header.Get("X-Sumo-Fields")) }, }, - logsFunc: func() pdata.Logs { - buffer := make([]pdata.LogRecord, 2) - buffer[0] = pdata.NewLogRecord() + logsFunc: func() plog.Logs { + buffer := make([]plog.LogRecord, 2) + buffer[0] = plog.NewLogRecord() buffer[0].Body().SetStringVal("Example log") buffer[0].Attributes().InsertString("key1", "value1") buffer[0].Attributes().InsertString("key2", "value2") - buffer[1] = pdata.NewLogRecord() + buffer[1] = plog.NewLogRecord() buffer[1].Body().SetStringVal("Another example log") buffer[1].Attributes().InsertString("key1", "value1") buffer[1].Attributes().InsertString("key2", "value2") @@ -212,7 +214,7 @@ func TestAllFailed(t *testing.T) { }, }) - logs := pdata.NewLogs() + logs := plog.NewLogs() logsSlice := logs.ResourceLogs().AppendEmpty() logsRecords1 := logsSlice.InstrumentationLibraryLogs().AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -220,7 +222,7 @@ func TestAllFailed(t *testing.T) { logsRecords2 := logsSlice.InstrumentationLibraryLogs().AppendEmpty().LogRecords() logsRecords2.AppendEmpty().Body().SetStringVal("Another example log") - logsExpected := pdata.NewLogs() + logsExpected := plog.NewLogs() logsSlice.CopyTo(logsExpected.ResourceLogs().AppendEmpty()) err := test.exp.pushLogsData(context.Background(), logs) @@ -249,7 +251,7 @@ func TestPartiallyFailed(t *testing.T) { }, }) - logs := pdata.NewLogs() + logs := plog.NewLogs() logsSlice1 := logs.ResourceLogs().AppendEmpty() logsRecords1 := logsSlice1.InstrumentationLibraryLogs().AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -257,7 +259,7 @@ func TestPartiallyFailed(t *testing.T) { logsRecords2 := logsSlice2.InstrumentationLibraryLogs().AppendEmpty().LogRecords() logsRecords2.AppendEmpty().Body().SetStringVal("Another example log") - logsExpected := pdata.NewLogs() + logsExpected := plog.NewLogs() logsSlice2.CopyTo(logsExpected.ResourceLogs().AppendEmpty()) err := test.exp.pushLogsData(context.Background(), logs) @@ -342,7 +344,7 @@ func TestPushFailedBatch(t *testing.T) { } func TestPushOTLPLogsClearTimestamp(t *testing.T) { - createLogs := func() pdata.Logs { + createLogs := func() plog.Logs { exampleLogs := exampleLog() exampleLogs[0].SetTimestamp(12345) logs := LogRecordsToLogs(exampleLogs) @@ -403,7 +405,7 @@ func TestPushOTLPLogsClearTimestamp(t *testing.T) { } func TestPushOTLPLogs_AttributeTranslation(t *testing.T) { - createLogs := func() pdata.Logs { + createLogs := func() plog.Logs { logs := LogRecordsToLogs(exampleLog()) resourceAttrs := logs.ResourceLogs().At(0).Resource().Attributes() resourceAttrs.InsertString("host.name", "harry-potter") @@ -496,7 +498,7 @@ func TestPushOTLPLogs_AttributeTranslation(t *testing.T) { } func TestPushTextLogs_AttributeTranslation(t *testing.T) { - createLogs := func() pdata.Logs { + createLogs := func() plog.Logs { logs := LogRecordsToLogs(exampleLog()) resourceAttrs := logs.ResourceLogs().At(0).Resource().Attributes() resourceAttrs.InsertString("host.name", "harry-potter") @@ -568,7 +570,7 @@ func TestPushTextLogs_AttributeTranslation(t *testing.T) { } func TestPushJSONLogs_AttributeTranslation(t *testing.T) { - createLogs := func() pdata.Logs { + createLogs := func() plog.Logs { logs := LogRecordsToLogs(exampleLog()) resourceAttrs := logs.ResourceLogs().At(0).Resource().Attributes() resourceAttrs.InsertString("host.name", "harry-potter") @@ -578,7 +580,7 @@ func TestPushJSONLogs_AttributeTranslation(t *testing.T) { testcases := []struct { name string - logs pdata.Logs + logs plog.Logs configFunc func() *Config callbacks []func(w http.ResponseWriter, req *http.Request) }{ @@ -651,16 +653,16 @@ func TestPushJSONLogs_AttributeTranslation(t *testing.T) { } func TestPushLogs_DontRemoveSourceAttributes(t *testing.T) { - createLogs := func() pdata.Logs { - logs := pdata.NewLogs() + createLogs := func() plog.Logs { + logs := plog.NewLogs() resourceLogs := logs.ResourceLogs().AppendEmpty() logsSlice := resourceLogs.InstrumentationLibraryLogs().AppendEmpty().LogRecords() - logRecords := make([]pdata.LogRecord, 2) - logRecords[0] = pdata.NewLogRecord() + logRecords := make([]plog.LogRecord, 2) + logRecords[0] = plog.NewLogRecord() logRecords[0].Body().SetStringVal("Example log aaaaaaaaaaaaaaaaaaaaaa 1") logRecords[0].CopyTo(logsSlice.AppendEmpty()) - logRecords[1] = pdata.NewLogRecord() + logRecords[1] = plog.NewLogRecord() logRecords[1].Body().SetStringVal("Example log aaaaaaaaaaaaaaaaaaaaaa 2") logRecords[1].CopyTo(logsSlice.AppendEmpty()) @@ -715,7 +717,7 @@ func TestAllMetricsSuccess(t *testing.T) { testcases := []struct { name string expectedBody string - metricFunc func() (pdata.Metric, pdata.Map) + metricFunc func() (pmetric.Metric, pcommon.Map) }{ { name: "sum", @@ -787,7 +789,7 @@ func TestAllMetricsFailed(t *testing.T) { testcases := []struct { name string callbacks []func(w http.ResponseWriter, req *http.Request) - metricFunc func() pdata.Metrics + metricFunc func() pmetric.Metrics expectedError string }{ { @@ -804,7 +806,7 @@ gauge_metric_name{test="test_value",test2="second_value",remote_name="156955",ur assert.Equal(t, "application/vnd.sumologic.prometheus", req.Header.Get("Content-Type")) }, }, - metricFunc: func() pdata.Metrics { + metricFunc: func() pmetric.Metrics { metricSum, attrs := exampleIntMetric() metricGauge, _ := exampleIntGaugeMetric() metrics := metricAndAttrsToPdataMetrics( @@ -836,7 +838,7 @@ gauge_metric_name{foo="bar",remote_name="156955",url="http://another_url"} 245 1 assert.Equal(t, "application/vnd.sumologic.prometheus", req.Header.Get("Content-Type")) }, }, - metricFunc: func() pdata.Metrics { + metricFunc: func() pmetric.Metrics { metricSum, attrsSum := exampleIntMetric() metricGauge, attrsGauge := exampleIntGaugeMetric() metrics := metricPairToMetrics( @@ -887,16 +889,16 @@ func TestPushMetricsInvalidCompressor(t *testing.T) { func TestLogsJsonFormatMetadataFilter(t *testing.T) { testcases := []struct { name string - logResourceAttributes map[string]pdata.AttributeValue + logResourceAttributes map[string]interface{} cfgFn func(c *Config) handler func(w http.ResponseWriter, req *http.Request) }{ { name: "basic", - logResourceAttributes: map[string]pdata.AttributeValue{ - "_sourceCategory": pdata.NewAttributeValueString("dummy"), - "key1": pdata.NewAttributeValueString("value1"), - "key2": pdata.NewAttributeValueString("value2"), + logResourceAttributes: map[string]interface{}{ + "_sourceCategory": "dummy", + "key1": "value1", + "key2": "value2", }, cfgFn: func(c *Config) { c.LogFormat = JSONFormat @@ -919,12 +921,12 @@ func TestLogsJsonFormatMetadataFilter(t *testing.T) { }, { name: "source related attributes available for templating even without specifying in metadata attributes", - logResourceAttributes: map[string]pdata.AttributeValue{ - "_sourceCategory": pdata.NewAttributeValueString("dummy_category"), - "_sourceHost": pdata.NewAttributeValueString("dummy_host"), - "_sourceName": pdata.NewAttributeValueString("dummy_name"), - "key1": pdata.NewAttributeValueString("value1"), - "key2": pdata.NewAttributeValueString("value2"), + logResourceAttributes: map[string]interface{}{ + "_sourceCategory": "dummy_category", + "_sourceHost": "dummy_host", + "_sourceName": "dummy_name", + "key1": "value1", + "key2": "value2", }, cfgFn: func(c *Config) { c.LogFormat = JSONFormat @@ -959,10 +961,10 @@ func TestLogsJsonFormatMetadataFilter(t *testing.T) { }, { name: "unavailable source metadata rendered as undefined", - logResourceAttributes: map[string]pdata.AttributeValue{ - "_sourceCategory": pdata.NewAttributeValueString("cat"), - "key1": pdata.NewAttributeValueString("value1"), - "key2": pdata.NewAttributeValueString("value2"), + logResourceAttributes: map[string]interface{}{ + "_sourceCategory": "cat", + "key1": "value1", + "key2": "value2", }, cfgFn: func(c *Config) { c.LogFormat = JSONFormat @@ -997,11 +999,11 @@ func TestLogsJsonFormatMetadataFilter(t *testing.T) { }, { name: "empty attribute", - logResourceAttributes: map[string]pdata.AttributeValue{ - "_sourceCategory": pdata.NewAttributeValueString("dummy"), - "key1": pdata.NewAttributeValueString("value1"), - "key2": pdata.NewAttributeValueString("value2"), - "key3": pdata.NewAttributeValueString(""), + logResourceAttributes: map[string]interface{}{ + "_sourceCategory": "dummy", + "key1": "value1", + "key2": "value2", + "key3": "", }, cfgFn: func(c *Config) { c.LogFormat = JSONFormat @@ -1035,7 +1037,7 @@ func TestLogsJsonFormatMetadataFilter(t *testing.T) { logs := LogRecordsToLogs(exampleLog()) logResourceAttrs := logs.ResourceLogs().At(0).Resource().Attributes() - pdata.NewAttributeMapFromMap(tc.logResourceAttributes).CopyTo(logResourceAttrs) + pcommon.NewMapFromRaw(tc.logResourceAttributes).CopyTo(logResourceAttrs) err := test.exp.pushLogsData(context.Background(), logs) assert.NoError(t, err) @@ -1363,7 +1365,7 @@ func TestPushMetrics_MetricsTranslation(t *testing.T) { testcases := []struct { name string cfgFn func() *Config - metricsFn func() pdata.Metrics + metricsFn func() pmetric.Metrics expectedBody string }{ { @@ -1374,17 +1376,17 @@ func TestPushMetrics_MetricsTranslation(t *testing.T) { // cfg.TranslateTelegrafMetrics = true return cfg }, - metricsFn: func() pdata.Metrics { - metrics := pdata.NewMetrics() + metricsFn: func() pmetric.Metrics { + metrics := pmetric.NewMetrics() { m := metrics.ResourceMetrics().AppendEmpty(). InstrumentationLibraryMetrics().AppendEmpty(). Metrics().AppendEmpty() m.SetName("cpu_usage_active") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetDoubleVal(123.456) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 0))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 0))) dp.Attributes().InsertString("test", "test_value") } return metrics @@ -1399,34 +1401,34 @@ func TestPushMetrics_MetricsTranslation(t *testing.T) { // cfg.TranslateTelegrafMetrics = true return cfg }, - metricsFn: func() pdata.Metrics { - metrics := pdata.NewMetrics() + metricsFn: func() pmetric.Metrics { + metrics := pmetric.NewMetrics() scopeMetrics := metrics.ResourceMetrics().AppendEmpty().ScopeMetrics() { m := scopeMetrics.AppendEmpty().Metrics().AppendEmpty() m.SetName("cpu_usage_active") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetDoubleVal(123.456) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 0))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 0))) dp.Attributes().InsertString("test", "test_value") } { m := scopeMetrics.AppendEmpty().Metrics().AppendEmpty() m.SetName("diskio_reads") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetIntVal(123456) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 1000000))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 1000000))) dp.Attributes().InsertString("test", "test_value") } { m := scopeMetrics.AppendEmpty().Metrics().AppendEmpty() m.SetName("dummy_metric") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetIntVal(10) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 2000000))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 2000000))) dp.Attributes().InsertString("test", "test_value") } return metrics @@ -1442,17 +1444,17 @@ dummy_metric{test="test_value"} 10 1605534165002`, cfg.TranslateTelegrafMetrics = false return cfg }, - metricsFn: func() pdata.Metrics { - metrics := pdata.NewMetrics() + metricsFn: func() pmetric.Metrics { + metrics := pmetric.NewMetrics() { m := metrics.ResourceMetrics().AppendEmpty(). InstrumentationLibraryMetrics().AppendEmpty(). Metrics().AppendEmpty() m.SetName("cpu_usage_active") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetDoubleVal(123.456) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 0))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 0))) dp.Attributes().InsertString("test", "test_value") } return metrics @@ -1466,34 +1468,34 @@ dummy_metric{test="test_value"} 10 1605534165002`, cfg.TranslateTelegrafMetrics = false return cfg }, - metricsFn: func() pdata.Metrics { - metrics := pdata.NewMetrics() + metricsFn: func() pmetric.Metrics { + metrics := pmetric.NewMetrics() scopeMetrics := metrics.ResourceMetrics().AppendEmpty().ScopeMetrics() { m := scopeMetrics.AppendEmpty().Metrics().AppendEmpty() m.SetName("cpu_usage_active") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetDoubleVal(123.456) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 0))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 0))) dp.Attributes().InsertString("test", "test_value") } { m := scopeMetrics.AppendEmpty().Metrics().AppendEmpty() m.SetName("diskio_reads") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetIntVal(123456) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 1000000))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 1000000))) dp.Attributes().InsertString("test", "test_value") } { m := scopeMetrics.AppendEmpty().Metrics().AppendEmpty() m.SetName("dummy_metric") - m.SetDataType(pdata.MetricDataTypeGauge) + m.SetDataType(pmetric.MetricDataTypeGauge) dp := m.Gauge().DataPoints().AppendEmpty() dp.SetIntVal(10) - dp.SetTimestamp(pdata.NewTimestampFromTime(time.Unix(1605534165, 2000000))) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(1605534165, 2000000))) dp.Attributes().InsertString("test", "test_value") } return metrics diff --git a/pkg/exporter/sumologicexporter/fields.go b/pkg/exporter/sumologicexporter/fields.go index 1aa38b540e..d612f757c4 100644 --- a/pkg/exporter/sumologicexporter/fields.go +++ b/pkg/exporter/sumologicexporter/fields.go @@ -18,17 +18,17 @@ import ( "strings" "github.com/google/go-cmp/cmp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" "golang.org/x/exp/slices" ) // fields represents metadata type fields struct { - orig pdata.AttributeMap + orig pcommon.Map initialized bool } -func newFields(attrMap pdata.AttributeMap) fields { +func newFields(attrMap pcommon.Map) fields { return fields{ orig: attrMap, initialized: true, @@ -59,7 +59,7 @@ func (f fields) string() string { returnValue := make([]string, 0, f.orig.Len()) - f.orig.Range(func(k string, v pdata.AttributeValue) bool { + f.orig.Range(func(k string, v pcommon.Value) bool { // Don't add source related attributes to fields as they are handled separately // and are added to the payload either as special HTTP headers or as resources // attributes. diff --git a/pkg/exporter/sumologicexporter/fields_test.go b/pkg/exporter/sumologicexporter/fields_test.go index f745e8a9c5..7aedc26cca 100644 --- a/pkg/exporter/sumologicexporter/fields_test.go +++ b/pkg/exporter/sumologicexporter/fields_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) func TestFields(t *testing.T) { @@ -66,7 +66,7 @@ func TestFields(t *testing.T) { } func BenchmarkFields(b *testing.B) { - attrMap := pdata.NewAttributeMap() + attrMap := pcommon.NewMap() flds := map[string]interface{}{ "key1": "value1", "key3": "value3", @@ -82,7 +82,7 @@ func BenchmarkFields(b *testing.B) { case string: attrMap.InsertString(k, v) case map[string]string: - m := pdata.NewAttributeValueMap() + m := pcommon.NewValueMap() mm := m.MapVal().AsRaw() for kk, vv := range v { mm[kk] = vv diff --git a/pkg/exporter/sumologicexporter/filter.go b/pkg/exporter/sumologicexporter/filter.go index 431eeb3694..49b5b97f04 100644 --- a/pkg/exporter/sumologicexporter/filter.go +++ b/pkg/exporter/sumologicexporter/filter.go @@ -17,7 +17,7 @@ package sumologicexporter import ( "regexp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) type filter struct { @@ -42,10 +42,10 @@ func newFilter(flds []string) (filter, error) { } // filterIn returns fields which match at least one of the filter regexes -func (f *filter) filterIn(attributes pdata.AttributeMap) fields { - returnValue := pdata.NewAttributeMap() +func (f *filter) filterIn(attributes pcommon.Map) fields { + returnValue := pcommon.NewMap() - attributes.Range(func(k string, v pdata.AttributeValue) bool { + attributes.Range(func(k string, v pcommon.Value) bool { for _, regex := range f.regexes { if regex.MatchString(k) { returnValue.Insert(k, v) @@ -59,10 +59,10 @@ func (f *filter) filterIn(attributes pdata.AttributeMap) fields { } // filterOut returns fields which don't match any of the filter regexes -func (f *filter) filterOut(attributes pdata.AttributeMap) fields { - returnValue := pdata.NewAttributeMap() +func (f *filter) filterOut(attributes pcommon.Map) fields { + returnValue := pcommon.NewMap() - attributes.Range(func(k string, v pdata.AttributeValue) bool { + attributes.Range(func(k string, v pcommon.Value) bool { for _, regex := range f.regexes { if regex.MatchString(k) { return true diff --git a/pkg/exporter/sumologicexporter/filter_test.go b/pkg/exporter/sumologicexporter/filter_test.go index 0169fd54f4..ef35c861e2 100644 --- a/pkg/exporter/sumologicexporter/filter_test.go +++ b/pkg/exporter/sumologicexporter/filter_test.go @@ -19,11 +19,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) func TestGetMetadata(t *testing.T) { - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("key3", "value3") attributes.InsertString("key1", "value1") attributes.InsertString("key2", "value2") @@ -45,7 +45,7 @@ func TestGetMetadata(t *testing.T) { } func TestFilterOutMetadata(t *testing.T) { - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("key3", "value3") attributes.InsertString("key1", "value1") attributes.InsertString("key2", "value2") diff --git a/pkg/exporter/sumologicexporter/go.mod b/pkg/exporter/sumologicexporter/go.mod index d784f1ebc5..961a124a56 100644 --- a/pkg/exporter/sumologicexporter/go.mod +++ b/pkg/exporter/sumologicexporter/go.mod @@ -8,15 +8,16 @@ require ( github.com/klauspost/compress v1.15.1 github.com/stretchr/testify v1.7.1 go.opencensus.io v0.23.0 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/model v0.49.0 + go.opentelemetry.io/collector/pdata v0.49.0 go.uber.org/multierr v1.8.0 go.uber.org/zap v1.21.0 golang.org/x/exp v0.0.0-20220328175248-053ad81199eb ) require ( - github.com/cenkalti/backoff/v4 v4.1.2 // indirect + github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/go-logr/logr v1.2.3 // indirect @@ -28,22 +29,19 @@ require ( github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rs/cors v1.8.2 // indirect - github.com/spf13/cast v1.4.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect google.golang.org/grpc v1.45.0 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/pkg/exporter/sumologicexporter/go.sum b/pkg/exporter/sumologicexporter/go.sum index 6f4aac3642..a8de5f7535 100644 --- a/pkg/exporter/sumologicexporter/go.sum +++ b/pkg/exporter/sumologicexporter/go.sum @@ -1,7 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -18,16 +17,14 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= -github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -38,7 +35,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -128,8 +124,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -170,9 +166,6 @@ github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -188,21 +181,26 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/model v0.49.0 h1:mbUSNgpaBE3GWmzGsRb5t0xILpXIVYv7scPTTfoMt6c= +go.opentelemetry.io/collector/model v0.49.0/go.mod h1:nOYQv9KoFPs6ihJwOi24qB209EOhS9HkwhGj54YiEAw= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0/go.mod h1:PFmBsWbldL1kiWZk9+0LBZz2brhByaGsvp6pRICMlPE= go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/sdk v1.6.1 h1:ZmcNyMhcuAYIb/Nr6QhBPTMopMTbov/47wHt1gibkoY= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/sdk v1.6.3 h1:prSHYdwCQOX5DrsEzxowH3nLhoAzEBdZhvrR79scfLs= go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -239,8 +237,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -264,13 +262,11 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -295,8 +291,6 @@ google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa h1:I0YcKz0I7OAhddo7ya8kMnvprhcWM045PmkBdMO9zN0= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -306,7 +300,6 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -320,7 +313,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= diff --git a/pkg/exporter/sumologicexporter/graphite_formatter.go b/pkg/exporter/sumologicexporter/graphite_formatter.go index 0dcaddd8cf..119fca5153 100644 --- a/pkg/exporter/sumologicexporter/graphite_formatter.go +++ b/pkg/exporter/sumologicexporter/graphite_formatter.go @@ -20,7 +20,8 @@ import ( "strings" "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) type graphiteFormatter struct { @@ -82,46 +83,46 @@ func (gf *graphiteFormatter) format(f fields, metricName string) string { // numberRecord converts NumberDataPoint to graphite metric string // with additional information from fields -func (gf *graphiteFormatter) numberRecord(fs fields, name string, dataPoint pdata.NumberDataPoint) string { +func (gf *graphiteFormatter) numberRecord(fs fields, name string, dataPoint pmetric.NumberDataPoint) string { switch dataPoint.ValueType() { - case pdata.MetricValueTypeDouble: + case pmetric.MetricValueTypeDouble: return fmt.Sprintf("%s %g %d", gf.format(fs, name), dataPoint.DoubleVal(), - dataPoint.Timestamp()/pdata.Timestamp(time.Second), + dataPoint.Timestamp()/pcommon.Timestamp(time.Second), ) - case pdata.MetricValueTypeInt: + case pmetric.MetricValueTypeInt: return fmt.Sprintf("%s %d %d", gf.format(fs, name), dataPoint.IntVal(), - dataPoint.Timestamp()/pdata.Timestamp(time.Second), + dataPoint.Timestamp()/pcommon.Timestamp(time.Second), ) } return "" } // metric2String returns stringified metricPair -func (gf *graphiteFormatter) metric2String(metric pdata.Metric, attributes pdata.Map) string { +func (gf *graphiteFormatter) metric2String(metric pmetric.Metric, attributes pcommon.Map) string { var nextLines []string fs := newFields(attributes) name := metric.Name() switch metric.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: dps := metric.Gauge().DataPoints() nextLines = make([]string, 0, dps.Len()) for i := 0; i < dps.Len(); i++ { nextLines = append(nextLines, gf.numberRecord(fs, name, dps.At(i))) } - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: dps := metric.Sum().DataPoints() nextLines = make([]string, 0, dps.Len()) for i := 0; i < dps.Len(); i++ { nextLines = append(nextLines, gf.numberRecord(fs, name, dps.At(i))) } // Skip complex metrics - case pdata.MetricDataTypeHistogram: - case pdata.MetricDataTypeSummary: + case pmetric.MetricDataTypeHistogram: + case pmetric.MetricDataTypeSummary: } return strings.Join(nextLines, "\n") diff --git a/pkg/exporter/sumologicexporter/prometheus_formatter.go b/pkg/exporter/sumologicexporter/prometheus_formatter.go index cf287d0b6d..995cdafeba 100644 --- a/pkg/exporter/sumologicexporter/prometheus_formatter.go +++ b/pkg/exporter/sumologicexporter/prometheus_formatter.go @@ -20,12 +20,13 @@ import ( "strings" "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) type dataPoint interface { - Timestamp() pdata.Timestamp - Attributes() pdata.AttributeMap + Timestamp() pcommon.Timestamp + Attributes() pcommon.Map } type prometheusFormatter struct { @@ -56,24 +57,24 @@ func newPrometheusFormatter() (prometheusFormatter, error) { } // PrometheusLabels returns all attributes as sanitized prometheus labels string -func (f *prometheusFormatter) tags2String(attr pdata.AttributeMap, labels pdata.AttributeMap) prometheusTags { +func (f *prometheusFormatter) tags2String(attr pcommon.Map, labels pcommon.Map) prometheusTags { attrsPlusLabelsLen := attr.Len() + labels.Len() if attrsPlusLabelsLen == 0 { return "" } - mergedAttributes := pdata.NewAttributeMap() + mergedAttributes := pcommon.NewMap() mergedAttributes.EnsureCapacity(attrsPlusLabelsLen) attr.CopyTo(mergedAttributes) - labels.Range(func(k string, v pdata.AttributeValue) bool { + labels.Range(func(k string, v pcommon.Value) bool { mergedAttributes.UpsertString(k, v.StringVal()) return true }) length := mergedAttributes.Len() returnValue := make([]string, 0, length) - mergedAttributes.Range(func(k string, v pdata.AttributeValue) bool { + mergedAttributes.Range(func(k string, v pcommon.Value) bool { key := f.sanitizeKeyBytes([]byte(k)) value := f.sanitizeValue(v.AsString()) @@ -160,40 +161,40 @@ func (f *prometheusFormatter) sanitizeValue(s string) string { } // doubleLine builds metric based on the given arguments where value is float64 -func (f *prometheusFormatter) doubleLine(name string, attributes prometheusTags, value float64, timestamp pdata.Timestamp) string { +func (f *prometheusFormatter) doubleLine(name string, attributes prometheusTags, value float64, timestamp pcommon.Timestamp) string { return fmt.Sprintf( "%s%s %g %d", f.sanitizeKeyBytes([]byte(name)), attributes, value, - timestamp/pdata.Timestamp(time.Millisecond), + timestamp/pcommon.Timestamp(time.Millisecond), ) } // intLine builds metric based on the given arguments where value is int64 -func (f *prometheusFormatter) intLine(name string, attributes prometheusTags, value int64, timestamp pdata.Timestamp) string { +func (f *prometheusFormatter) intLine(name string, attributes prometheusTags, value int64, timestamp pcommon.Timestamp) string { return fmt.Sprintf( "%s%s %d %d", f.sanitizeKeyBytes([]byte(name)), attributes, value, - timestamp/pdata.Timestamp(time.Millisecond), + timestamp/pcommon.Timestamp(time.Millisecond), ) } // uintLine builds metric based on the given arguments where value is uint64 -func (f *prometheusFormatter) uintLine(name string, attributes prometheusTags, value uint64, timestamp pdata.Timestamp) string { +func (f *prometheusFormatter) uintLine(name string, attributes prometheusTags, value uint64, timestamp pcommon.Timestamp) string { return fmt.Sprintf( "%s%s %d %d", f.sanitizeKeyBytes([]byte(name)), attributes, value, - timestamp/pdata.Timestamp(time.Millisecond), + timestamp/pcommon.Timestamp(time.Millisecond), ) } // doubleValueLine returns prometheus line with given value -func (f *prometheusFormatter) doubleValueLine(name string, value float64, dp dataPoint, attributes pdata.AttributeMap) string { +func (f *prometheusFormatter) doubleValueLine(name string, value float64, dp dataPoint, attributes pcommon.Map) string { return f.doubleLine( name, f.tags2String(attributes, dp.Attributes()), @@ -203,7 +204,7 @@ func (f *prometheusFormatter) doubleValueLine(name string, value float64, dp dat } // uintValueLine returns prometheus line with given value -func (f *prometheusFormatter) uintValueLine(name string, value uint64, dp dataPoint, attributes pdata.AttributeMap) string { +func (f *prometheusFormatter) uintValueLine(name string, value uint64, dp dataPoint, attributes pcommon.Map) string { return f.uintLine( name, f.tags2String(attributes, dp.Attributes()), @@ -212,17 +213,17 @@ func (f *prometheusFormatter) uintValueLine(name string, value uint64, dp dataPo ) } -// numberDataPointValueLine returns prometheus line with value from pdata.NumberDataPoint -func (f *prometheusFormatter) numberDataPointValueLine(name string, dp pdata.NumberDataPoint, attributes pdata.AttributeMap) string { +// numberDataPointValueLine returns prometheus line with value from pmetric.NumberDataPoint +func (f *prometheusFormatter) numberDataPointValueLine(name string, dp pmetric.NumberDataPoint, attributes pcommon.Map) string { switch dp.ValueType() { - case pdata.MetricValueTypeDouble: + case pmetric.MetricValueTypeDouble: return f.doubleValueLine( name, dp.DoubleVal(), dp, attributes, ) - case pdata.MetricValueTypeInt: + case pmetric.MetricValueTypeInt: return f.intLine( name, f.tags2String(attributes, dp.Attributes()), @@ -243,13 +244,13 @@ func (f *prometheusFormatter) countMetric(name string) string { return fmt.Sprintf("%s_count", name) } -// mergeAttributes gets two pdata.AttributeMaps and returns new which contains values from both of them -func (f *prometheusFormatter) mergeAttributes(attributes pdata.AttributeMap, additionalAttributes pdata.AttributeMap) pdata.AttributeMap { - mergedAttributes := pdata.NewAttributeMap() +// mergeAttributes gets two pcommon.Maps and returns new which contains values from both of them +func (f *prometheusFormatter) mergeAttributes(attributes pcommon.Map, additionalAttributes pcommon.Map) pcommon.Map { + mergedAttributes := pcommon.NewMap() mergedAttributes.EnsureCapacity(attributes.Len() + additionalAttributes.Len()) attributes.CopyTo(mergedAttributes) - additionalAttributes.Range(func(k string, v pdata.AttributeValue) bool { + additionalAttributes.Range(func(k string, v pcommon.Value) bool { mergedAttributes.Upsert(k, v) return true }) @@ -257,7 +258,7 @@ func (f *prometheusFormatter) mergeAttributes(attributes pdata.AttributeMap, add } // doubleGauge2Strings converts DoubleGauge record to a list of strings (one per dataPoint) -func (f *prometheusFormatter) gauge2Strings(metric pdata.Metric, attributes pdata.Map) []string { +func (f *prometheusFormatter) gauge2Strings(metric pmetric.Metric, attributes pcommon.Map) []string { dps := metric.Gauge().DataPoints() lines := make([]string, 0, dps.Len()) @@ -275,7 +276,7 @@ func (f *prometheusFormatter) gauge2Strings(metric pdata.Metric, attributes pdat } // doubleSum2Strings converts Sum record to a list of strings (one per dataPoint) -func (f *prometheusFormatter) sum2Strings(metric pdata.Metric, attributes pdata.Map) []string { +func (f *prometheusFormatter) sum2Strings(metric pmetric.Metric, attributes pcommon.Map) []string { dps := metric.Sum().DataPoints() lines := make([]string, 0, dps.Len()) @@ -294,14 +295,14 @@ func (f *prometheusFormatter) sum2Strings(metric pdata.Metric, attributes pdata. // summary2Strings converts Summary record to a list of strings // n+2 where n is number of quantiles and 2 stands for sum and count metrics per each data point -func (f *prometheusFormatter) summary2Strings(metric pdata.Metric, attributes pdata.Map) []string { +func (f *prometheusFormatter) summary2Strings(metric pmetric.Metric, attributes pcommon.Map) []string { dps := metric.Summary().DataPoints() var lines []string for i := 0; i < dps.Len(); i++ { dp := dps.At(i) qs := dp.QuantileValues() - additionalAttributes := pdata.NewAttributeMap() + additionalAttributes := pcommon.NewMap() for i := 0; i < qs.Len(); i++ { q := qs.At(i) additionalAttributes.UpsertDouble(prometheusQuantileTag, q.Quantile()) @@ -336,7 +337,7 @@ func (f *prometheusFormatter) summary2Strings(metric pdata.Metric, attributes pd // histogram2Strings converts Histogram record to a list of strings, // (n+1) where n is number of bounds plus two for sum and count per each data point -func (f *prometheusFormatter) histogram2Strings(metric pdata.Metric, attributes pdata.Map) []string { +func (f *prometheusFormatter) histogram2Strings(metric pmetric.Metric, attributes pcommon.Map) []string { dps := metric.Histogram().DataPoints() var lines []string @@ -349,7 +350,7 @@ func (f *prometheusFormatter) histogram2Strings(metric pdata.Metric, attributes } var cumulative uint64 - additionalAttributes := pdata.NewAttributeMap() + additionalAttributes := pcommon.NewMap() for i, bound := range explicitBounds { cumulative += dp.BucketCounts()[i] @@ -395,17 +396,17 @@ func (f *prometheusFormatter) histogram2Strings(metric pdata.Metric, attributes } // metric2String returns stringified metricPair -func (f *prometheusFormatter) metric2String(metric pdata.Metric, attributes pdata.Map) string { +func (f *prometheusFormatter) metric2String(metric pmetric.Metric, attributes pcommon.Map) string { var lines []string switch metric.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: lines = f.gauge2Strings(metric, attributes) - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: lines = f.sum2Strings(metric, attributes) - case pdata.MetricDataTypeSummary: + case pmetric.MetricDataTypeSummary: lines = f.summary2Strings(metric, attributes) - case pdata.MetricDataTypeHistogram: + case pmetric.MetricDataTypeHistogram: lines = f.histogram2Strings(metric, attributes) } return strings.Join(lines, "\n") diff --git a/pkg/exporter/sumologicexporter/prometheus_formatter_test.go b/pkg/exporter/sumologicexporter/prometheus_formatter_test.go index c104f92e2f..3b3981b6fa 100644 --- a/pkg/exporter/sumologicexporter/prometheus_formatter_test.go +++ b/pkg/exporter/sumologicexporter/prometheus_formatter_test.go @@ -19,7 +19,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestSanitizeKey(t *testing.T) { @@ -48,7 +49,7 @@ func TestTags2StringNoLabels(t *testing.T) { _, attributes := exampleIntMetric() attributes.Clear() - assert.Equal(t, prometheusTags(""), f.tags2String(attributes, pdata.NewAttributeMap())) + assert.Equal(t, prometheusTags(""), f.tags2String(attributes, pcommon.NewMap())) } func TestTags2String(t *testing.T) { @@ -59,7 +60,7 @@ func TestTags2String(t *testing.T) { assert.Equal( t, prometheusTags(`{test="test_value",test2="second_value"}`), - f.tags2String(attributes, pdata.NewAttributeMap()), + f.tags2String(attributes, pcommon.NewMap()), ) } @@ -69,7 +70,7 @@ func TestTags2StringNoAttributes(t *testing.T) { _, attributes := exampleIntMetric() attributes.Clear() - assert.Equal(t, prometheusTags(""), f.tags2String(pdata.NewAttributeMap(), pdata.NewAttributeMap())) + assert.Equal(t, prometheusTags(""), f.tags2String(pcommon.NewMap(), pcommon.NewMap())) } func TestPrometheusMetricDataTypeIntGauge(t *testing.T) { @@ -159,7 +160,7 @@ histogram_metric_double_test_count{bar="foo",container="sit",branch="main"} 98 1 func TestPrometheusMetrics(t *testing.T) { type testCase struct { name string - metricFunc func(fillData bool) (pdata.Metric, pdata.Map) + metricFunc func(fillData bool) (pmetric.Metric, pcommon.Map) expected string } diff --git a/pkg/exporter/sumologicexporter/sender.go b/pkg/exporter/sumologicexporter/sender.go index a20af4dcef..89c97cf3df 100644 --- a/pkg/exporter/sumologicexporter/sender.go +++ b/pkg/exporter/sumologicexporter/sender.go @@ -26,7 +26,10 @@ import ( "time" "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/multierr" "go.uber.org/zap" @@ -48,8 +51,8 @@ type appendResponse struct { // metricPair represents information required to send one metric to the Sumo Logic type metricPair struct { - attributes pdata.AttributeMap - metric pdata.Metric + attributes pcommon.Map + metric pmetric.Metric } // countingReader keeps number of records related to reader @@ -136,7 +139,7 @@ type sender struct { } const ( - // maxBufferSize defines size of the logBuffer (maximum number of pdata.LogRecord entries) + // maxBufferSize defines size of the logBuffer (maximum number of plog.LogRecord entries) maxBufferSize int = 1024 * 1024 headerContentType string = "Content-Type" @@ -345,21 +348,21 @@ func (s *sender) createRequest(ctx context.Context, pipeline PipelineType, data } // logToText converts LogRecord to a plain text line, returns it and error eventually -func (s *sender) logToText(record pdata.LogRecord) string { +func (s *sender) logToText(record plog.LogRecord) string { return record.Body().AsString() } // logToJSON converts LogRecord to a json line, returns it and error eventually -func (s *sender) logToJSON(record pdata.LogRecord) (string, error) { +func (s *sender) logToJSON(record plog.LogRecord) (string, error) { if s.jsonLogsConfig.AddTimestamp { addJSONTimestamp(record.Attributes(), s.jsonLogsConfig.TimestampKey, record.Timestamp()) } // Only append the body when it's not empty to prevent sending 'null' log. if body := record.Body(); !isEmptyAttributeValue(body) { - if s.jsonLogsConfig.FlattenBody && body.Type() == pdata.AttributeValueTypeMap { + if s.jsonLogsConfig.FlattenBody && body.Type() == pcommon.ValueTypeMap { // Cannot use CopyTo, as it overrides data.orig's values - body.MapVal().Range(func(k string, v pdata.AttributeValue) bool { + body.MapVal().Range(func(k string, v pcommon.Value) bool { record.Attributes().Insert(k, v) return true }) @@ -382,7 +385,7 @@ var timeZeroUTC = time.Unix(0, 0).UTC() // out the logs as JSON. // If the attached timestamp is equal to 0 (millisecond based UNIX timestamp) // then send out current time formatted as milliseconds since January 1, 1970. -func addJSONTimestamp(attrs pdata.AttributeMap, timestampKey string, pt pdata.Timestamp) { +func addJSONTimestamp(attrs pcommon.Map, timestampKey string, pt pcommon.Timestamp) { t := pt.AsTime() if t == timeZeroUTC { attrs.InsertInt(timestampKey, time.Now().UnixMilli()) @@ -391,18 +394,18 @@ func addJSONTimestamp(attrs pdata.AttributeMap, timestampKey string, pt pdata.Ti } } -func isEmptyAttributeValue(att pdata.AttributeValue) bool { +func isEmptyAttributeValue(att pcommon.Value) bool { t := att.Type() - return !(t == pdata.AttributeValueTypeString && len(att.StringVal()) > 0 || - t == pdata.AttributeValueTypeArray && att.SliceVal().Len() > 0 || - t == pdata.AttributeValueTypeMap && att.MapVal().Len() > 0 || - t == pdata.AttributeValueTypeBytes && len(att.BytesVal()) > 0) + return !(t == pcommon.ValueTypeString && len(att.StringVal()) > 0 || + t == pcommon.ValueTypeSlice && att.SliceVal().Len() > 0 || + t == pcommon.ValueTypeMap && att.MapVal().Len() > 0 || + t == pcommon.ValueTypeBytes && len(att.BytesVal()) > 0) } // sendNonOTLPLogs sends log records from the logBuffer formatted according // to configured LogFormat and as the result of execution // returns array of records which has not been sent correctly and error -func (s *sender) sendNonOTLPLogs(ctx context.Context, rl pdata.ResourceLogs, flds fields) ([]pdata.LogRecord, error) { +func (s *sender) sendNonOTLPLogs(ctx context.Context, rl plog.ResourceLogs, flds fields) ([]plog.LogRecord, error) { if s.config.LogFormat == OTLPLogFormat { return nil, fmt.Errorf("Attempting to send OTLP logs as non-OTLP data") } @@ -410,8 +413,8 @@ func (s *sender) sendNonOTLPLogs(ctx context.Context, rl pdata.ResourceLogs, fld var ( body bodyBuilder = newBodyBuilder() errs []error - droppedRecords []pdata.LogRecord - currentRecords []pdata.LogRecord + droppedRecords []plog.LogRecord + currentRecords []plog.LogRecord ) slgs := rl.ScopeLogs() @@ -460,7 +463,7 @@ func (s *sender) sendNonOTLPLogs(ctx context.Context, rl pdata.ResourceLogs, fld return droppedRecords, multierr.Combine(errs...) } -func (s *sender) formatLogLine(lr pdata.LogRecord) (string, error) { +func (s *sender) formatLogLine(lr plog.LogRecord) (string, error) { var formattedLine string var err error @@ -477,7 +480,7 @@ func (s *sender) formatLogLine(lr pdata.LogRecord) (string, error) { } // TODO: add support for HTTP limits -func (s *sender) sendOTLPLogs(ctx context.Context, ld pdata.Logs) error { +func (s *sender) sendOTLPLogs(ctx context.Context, ld plog.Logs) error { rls := ld.ResourceLogs() for i := 0; i < rls.Len(); i++ { rl := rls.At(i) @@ -510,7 +513,7 @@ func (s *sender) sendOTLPLogs(ctx context.Context, ld pdata.Logs) error { } // sendNonOTLPMetrics sends metrics in right format basing on the s.config.MetricFormat -func (s *sender) sendNonOTLPMetrics(ctx context.Context, rm pdata.ResourceMetrics, flds fields) ([]pdata.Metric, error) { +func (s *sender) sendNonOTLPMetrics(ctx context.Context, rm pmetric.ResourceMetrics, flds fields) ([]pmetric.Metric, error) { if s.config.MetricFormat == OTLPMetricFormat { return nil, fmt.Errorf("Attempting to send OTLP metrics as non-OTLP data") } @@ -518,8 +521,8 @@ func (s *sender) sendNonOTLPMetrics(ctx context.Context, rm pdata.ResourceMetric var ( body bodyBuilder = newBodyBuilder() errs []error - droppedRecords []pdata.Metric - currentRecords []pdata.Metric + droppedRecords []pmetric.Metric + currentRecords []pmetric.Metric ) sms := rm.ScopeMetrics() @@ -582,7 +585,7 @@ func (s *sender) sendNonOTLPMetrics(ctx context.Context, rm pdata.ResourceMetric return droppedRecords, multierr.Combine(errs...) } -func (s *sender) sendOTLPMetrics(ctx context.Context, md pdata.Metrics) error { +func (s *sender) sendOTLPMetrics(ctx context.Context, md pmetric.Metrics) error { rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { rm := rms.At(i) @@ -647,7 +650,7 @@ func (s *sender) appendAndSend( } // sendTraces sends traces in right format basing on the s.config.TraceFormat -func (s *sender) sendTraces(ctx context.Context, td pdata.Traces) error { +func (s *sender) sendTraces(ctx context.Context, td ptrace.Traces) error { if s.config.TraceFormat == OTLPTraceFormat { return s.sendOTLPTraces(ctx, td) } @@ -655,7 +658,7 @@ func (s *sender) sendTraces(ctx context.Context, td pdata.Traces) error { } // sendOTLPTraces sends trace records in OTLP format -func (s *sender) sendOTLPTraces(ctx context.Context, td pdata.Traces) error { +func (s *sender) sendOTLPTraces(ctx context.Context, td ptrace.Traces) error { capacity := td.SpanCount() for i := 0; i < td.ResourceSpans().Len(); i++ { s.addSourceResourceAttributes(td.ResourceSpans().At(i).Resource().Attributes()) @@ -783,7 +786,7 @@ func (s *sender) addRequestHeaders(req *http.Request, pipeline PipelineType, fld // * source name // to the provided attribute map using the provided fields as values source and using // the source templates for formatting. -func (s *sender) addSourceRelatedResourceAttributesFromFields(attrs pdata.AttributeMap, flds fields) { +func (s *sender) addSourceRelatedResourceAttributesFromFields(attrs pcommon.Map, flds fields) { if s.sources.host.isSet() { attrs.InsertString(attributeKeySourceHost, s.sources.host.format(flds)) } @@ -804,7 +807,7 @@ func (s *sender) addSourceRelatedResourceAttributesFromFields(attrs pdata.Attrib // When those attributes are already in the attribute map then nothing is // changed since attributes that are provided with data have precedence over // exporter configuration. -func (s *sender) addSourceResourceAttributes(attrs pdata.AttributeMap) { +func (s *sender) addSourceResourceAttributes(attrs pcommon.Map) { if s.sources.host.isSet() { if _, ok := attrs.Get(attributeKeySourceHost); !ok { attrs.InsertString(attributeKeySourceHost, s.sources.host.formatPdataMap(attrs)) diff --git a/pkg/exporter/sumologicexporter/sender_test.go b/pkg/exporter/sumologicexporter/sender_test.go index 639b7ca7c4..c7b358e253 100644 --- a/pkg/exporter/sumologicexporter/sender_test.go +++ b/pkg/exporter/sumologicexporter/sender_test.go @@ -30,7 +30,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/model/otlp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -170,31 +172,31 @@ func extractBody(t *testing.T, req *http.Request) string { return buf.String() } -func exampleLog() []pdata.LogRecord { - buffer := make([]pdata.LogRecord, 1) - buffer[0] = pdata.NewLogRecord() +func exampleLog() []plog.LogRecord { + buffer := make([]plog.LogRecord, 1) + buffer[0] = plog.NewLogRecord() buffer[0].Body().SetStringVal("Example log") return buffer } -func exampleNLogs(n int) []pdata.LogRecord { - buffer := make([]pdata.LogRecord, n) +func exampleNLogs(n int) []plog.LogRecord { + buffer := make([]plog.LogRecord, n) for i := 0; i < n; i++ { - buffer[i] = pdata.NewLogRecord() + buffer[i] = plog.NewLogRecord() buffer[i].Body().SetStringVal("Example log") } return buffer } -func exampleTwoLogs() []pdata.LogRecord { - buffer := make([]pdata.LogRecord, 2) - buffer[0] = pdata.NewLogRecord() +func exampleTwoLogs() []plog.LogRecord { + buffer := make([]plog.LogRecord, 2) + buffer[0] = plog.NewLogRecord() buffer[0].Body().SetStringVal("Example log") buffer[0].Attributes().InsertString("key1", "value1") buffer[0].Attributes().InsertString("key2", "value2") - buffer[1] = pdata.NewLogRecord() + buffer[1] = plog.NewLogRecord() buffer[1].Body().SetStringVal("Another example log") buffer[1].Attributes().InsertString("key1", "value1") buffer[1].Attributes().InsertString("key2", "value2") @@ -231,7 +233,7 @@ func TestSendLogs(t *testing.T) { }, }) - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs() logsRecords1 := slgs.AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -257,7 +259,7 @@ func TestSendLogsWithEmptyField(t *testing.T) { }, }) - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs() logsRecords1 := slgs.AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -285,20 +287,20 @@ func TestSendLogsMultitype(t *testing.T) { }, }) - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs() logsRecords := slgs.AppendEmpty().LogRecords() - attVal := pdata.NewAttributeValueMap() + attVal := pcommon.NewValueMap() attMap := attVal.MapVal() attMap.InsertString("lk1", "lv1") attMap.InsertInt("lk2", 13) logRecord := logsRecords.AppendEmpty() attVal.CopyTo(logRecord.Body()) - attVal = pdata.NewAttributeValueArray() + attVal = pcommon.NewValueSlice() attArr := attVal.SliceVal() - strVal := pdata.NewAttributeValueString("lv2") - intVal := pdata.NewAttributeValueInt(13) + strVal := pcommon.NewValueString("lv2") + intVal := pcommon.NewValueInt(13) strVal.CopyTo(attArr.AppendEmpty()) intVal.CopyTo(attArr.AppendEmpty()) attVal.CopyTo(logsRecords.AppendEmpty().Body()) @@ -325,7 +327,7 @@ func TestSendLogsSplit(t *testing.T) { }) test.s.config.MaxRequestBodySize = 10 - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs() logsRecords1 := slgs.AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -363,7 +365,7 @@ func TestSendLogsSplitFailedOne(t *testing.T) { test.s.config.MaxRequestBodySize = 10 test.s.config.LogFormat = TextFormat - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs() logsRecords1 := slgs.AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -398,7 +400,7 @@ func TestSendLogsSplitFailedAll(t *testing.T) { test.s.config.MaxRequestBodySize = 10 test.s.config.LogFormat = TextFormat - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs() logsRecords1 := slgs.AppendEmpty().LogRecords() logsRecords1.AppendEmpty().Body().SetStringVal("Example log") @@ -417,8 +419,8 @@ func TestSendLogsSplitFailedAll(t *testing.T) { } func TestSendLogsJsonConfig(t *testing.T) { - twoLogsFunc := func() pdata.ResourceLogs { - rls := pdata.NewResourceLogs() + twoLogsFunc := func() plog.ResourceLogs { + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -434,18 +436,18 @@ func TestSendLogsJsonConfig(t *testing.T) { return rls } - twoComplexBodyLogsFunc := func() pdata.ResourceLogs { - rls := pdata.NewResourceLogs() + twoComplexBodyLogsFunc := func() plog.ResourceLogs { + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() - body := pdata.NewAttributeValueMap().MapVal() + body := pcommon.NewValueMap().MapVal() body.InsertString("a", "b") body.InsertBool("c", false) body.InsertInt("d", 20) body.InsertDouble("e", 20.5) - f := pdata.NewAttributeValueArray() + f := pcommon.NewValueSlice() f.SliceVal().EnsureCapacity(4) f.SliceVal().AppendEmpty().SetStringVal("p") f.SliceVal().AppendEmpty().SetBoolVal(true) @@ -453,7 +455,7 @@ func TestSendLogsJsonConfig(t *testing.T) { f.SliceVal().AppendEmpty().SetDoubleVal(19.3) body.Insert("f", f) - g := pdata.NewAttributeValueMap() + g := pcommon.NewValueMap() g.MapVal().InsertString("h", "i") g.MapVal().InsertBool("j", false) g.MapVal().InsertInt("k", 12) @@ -463,7 +465,7 @@ func TestSendLogsJsonConfig(t *testing.T) { log.Attributes().InsertString("m", "n") - pdata.NewAttributeValueMap().CopyTo(log.Body()) + pcommon.NewValueMap().CopyTo(log.Body()) body.CopyTo(log.Body().MapVal()) return rls @@ -473,7 +475,7 @@ func TestSendLogsJsonConfig(t *testing.T) { name string configOpts []func(*Config) bodyRegex string - logsFunc func() pdata.ResourceLogs + logsFunc func() plog.ResourceLogs }{ { name: "default config", @@ -613,7 +615,7 @@ func TestSendLogsJson(t *testing.T) { }) test.s.config.LogFormat = JSONFormat - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -652,10 +654,10 @@ func TestSendLogsJsonMultitype(t *testing.T) { }) test.s.config.LogFormat = JSONFormat - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() - attVal := pdata.NewAttributeValueMap() + attVal := pcommon.NewValueMap() attMap := attVal.MapVal() attMap.InsertString("lk1", "lv1") attMap.InsertInt("lk2", 13) @@ -668,10 +670,10 @@ func TestSendLogsJsonMultitype(t *testing.T) { log = slgs.LogRecords().AppendEmpty() - attVal = pdata.NewAttributeValueArray() + attVal = pcommon.NewValueSlice() attArr := attVal.SliceVal() - strVal := pdata.NewAttributeValueString("lv2") - intVal := pdata.NewAttributeValueInt(13) + strVal := pcommon.NewValueString("lv2") + intVal := pcommon.NewValueInt(13) strVal.CopyTo(attArr.AppendEmpty()) intVal.CopyTo(attArr.AppendEmpty()) @@ -707,7 +709,7 @@ func TestSendLogsJsonSplit(t *testing.T) { test.s.config.LogFormat = JSONFormat test.s.config.MaxRequestBodySize = 10 - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -751,7 +753,7 @@ func TestSendLogsJsonSplitFailedOne(t *testing.T) { test.s.config.LogFormat = JSONFormat test.s.config.MaxRequestBodySize = 10 - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -798,7 +800,7 @@ func TestSendLogsJsonSplitFailedAll(t *testing.T) { test.s.config.LogFormat = JSONFormat test.s.config.MaxRequestBodySize = 10 - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -833,7 +835,7 @@ func TestSendLogsUnexpectedFormat(t *testing.T) { }) test.s.config.LogFormat = "dummy" - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() log.Body().SetStringVal("Example log") @@ -844,7 +846,7 @@ func TestSendLogsUnexpectedFormat(t *testing.T) { ) assert.Error(t, err) assert.Len(t, dropped, 1) - assert.Equal(t, []pdata.LogRecord{log}, dropped) + assert.Equal(t, []plog.LogRecord{log}, dropped) } func TestSendLogsOTLP(t *testing.T) { @@ -874,7 +876,7 @@ func TestSendLogsOTLP(t *testing.T) { test.s.config.LogFormat = "otlp" - l := pdata.NewLogs() + l := plog.NewLogs() ls := l.ResourceLogs().AppendEmpty() logRecords := exampleTwoLogs() @@ -887,8 +889,8 @@ func TestSendLogsOTLP(t *testing.T) { } func TestOverrideSourceName(t *testing.T) { - twoLogsFunc := func() pdata.ResourceLogs { - rls := pdata.NewResourceLogs() + twoLogsFunc := func() plog.ResourceLogs { + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -954,14 +956,14 @@ func TestOverrideSourceName(t *testing.T) { require.Equal(t, l.ResourceLogs().Len(), 1) sourceCategory, ok := l.ResourceLogs().At(0).Resource().Attributes().Get("_sourceName") require.True(t, ok) - require.Equal(t, pdata.AttributeValueTypeString, sourceCategory.Type()) + require.Equal(t, pcommon.ValueTypeString, sourceCategory.Type()) require.Equal(t, "Test source name/test_name", sourceCategory.StringVal()) }, }) test.s.sources.name = getTestSourceFormat(t, "Test source name/%{key1}") - l := pdata.NewLogs() + l := plog.NewLogs() ls := l.ResourceLogs().AppendEmpty() ls.Resource().Attributes().InsertString("key1", "test_name") logRecords := exampleTwoLogs() @@ -973,8 +975,8 @@ func TestOverrideSourceName(t *testing.T) { } func TestOverrideSourceCategory(t *testing.T) { - twoLogsFunc := func() pdata.ResourceLogs { - rls := pdata.NewResourceLogs() + twoLogsFunc := func() plog.ResourceLogs { + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -1037,14 +1039,14 @@ func TestOverrideSourceCategory(t *testing.T) { require.Equal(t, l.ResourceLogs().Len(), 1) sourceCategory, ok := l.ResourceLogs().At(0).Resource().Attributes().Get("_sourceCategory") require.True(t, ok) - require.Equal(t, pdata.AttributeValueTypeString, sourceCategory.Type()) + require.Equal(t, pcommon.ValueTypeString, sourceCategory.Type()) require.Equal(t, "Test source category/test_name", sourceCategory.StringVal()) }, }) test.s.sources.category = getTestSourceFormat(t, "Test source category/%{key1}") - l := pdata.NewLogs() + l := plog.NewLogs() ls := l.ResourceLogs().AppendEmpty() ls.Resource().Attributes().InsertString("key1", "test_name") logRecords := exampleTwoLogs() @@ -1056,8 +1058,8 @@ func TestOverrideSourceCategory(t *testing.T) { } func TestOverrideSourceHost(t *testing.T) { - twoLogsFunc := func() pdata.ResourceLogs { - rls := pdata.NewResourceLogs() + twoLogsFunc := func() plog.ResourceLogs { + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -1120,14 +1122,14 @@ func TestOverrideSourceHost(t *testing.T) { require.Equal(t, l.ResourceLogs().Len(), 1) sourceHost, ok := l.ResourceLogs().At(0).Resource().Attributes().Get("_sourceHost") require.True(t, ok) - require.Equal(t, pdata.AttributeValueTypeString, sourceHost.Type()) + require.Equal(t, pcommon.ValueTypeString, sourceHost.Type()) require.Equal(t, "Test source host/test_name", sourceHost.StringVal()) }, }) test.s.sources.host = getTestSourceFormat(t, "Test source host/%{key1}") - l := pdata.NewLogs() + l := plog.NewLogs() ls := l.ResourceLogs().AppendEmpty() ls.Resource().Attributes().InsertString("key1", "test_name") logRecords := exampleTwoLogs() @@ -1139,8 +1141,8 @@ func TestOverrideSourceHost(t *testing.T) { } func TestLogsDontSendSourceFieldsInXSumoFieldsHeader(t *testing.T) { - twoLogsFunc := func() pdata.ResourceLogs { - rls := pdata.NewResourceLogs() + twoLogsFunc := func() plog.ResourceLogs { + rls := plog.NewResourceLogs() slgs := rls.ScopeLogs().AppendEmpty() log := slgs.LogRecords().AppendEmpty() @@ -1236,7 +1238,7 @@ func TestLogsHandlesReceiverResponses(t *testing.T) { c.LogFormat = JSONFormat }) - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() rls.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStringVal("Example log") var buffer bytes.Buffer @@ -1323,7 +1325,7 @@ func TestInvalidEndpoint(t *testing.T) { test.s.config.HTTPClientSettings.Endpoint = ":" - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() rls.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStringVal("Example log") _, err := test.s.sendNonOTLPLogs(context.Background(), rls, fields{}) @@ -1334,7 +1336,7 @@ func TestInvalidPostRequest(t *testing.T) { test := prepareSenderTest(t, []func(w http.ResponseWriter, req *http.Request){}) test.s.config.HTTPClientSettings.Endpoint = "" - rls := pdata.NewResourceLogs() + rls := plog.NewResourceLogs() rls.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStringVal("Example log") _, err := test.s.sendNonOTLPLogs(context.Background(), rls, fields{}) @@ -1581,7 +1583,7 @@ func TestSendMetricsUnexpectedFormat(t *testing.T) { dropped, err := test.s.sendNonOTLPMetrics(context.Background(), resMetrics, fields{}) assert.EqualError(t, err, "unexpected metric format: invalid") - assert.Equal(t, dropped, []pdata.Metric{metricSum}) + assert.Equal(t, dropped, []pmetric.Metric{metricSum}) } func TestSendCarbon2Metrics(t *testing.T) { diff --git a/pkg/exporter/sumologicexporter/source_format.go b/pkg/exporter/sumologicexporter/source_format.go index d886e81e57..9f4406f38d 100644 --- a/pkg/exporter/sumologicexporter/source_format.go +++ b/pkg/exporter/sumologicexporter/source_format.go @@ -18,7 +18,7 @@ import ( "fmt" "regexp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) type sourceFormats struct { @@ -79,11 +79,11 @@ func (s *sourceFormat) format(f fields) string { } // formatPdataMap converts sourceFormat to string. -// Takes pdata.Map attributes and puts them into template (%s placeholders) +// Takes pcommon.Map attributes and puts them into template (%s placeholders) // in order defined by matches. // // The provided attribute map has to be initialized before calling this func. -func (s *sourceFormat) formatPdataMap(m pdata.Map) string { +func (s *sourceFormat) formatPdataMap(m pcommon.Map) string { labels := make([]interface{}, 0, len(s.matches)) for _, matchset := range s.matches { diff --git a/pkg/exporter/sumologicexporter/test_data_test.go b/pkg/exporter/sumologicexporter/test_data_test.go index 987d658e39..1d8b80d757 100644 --- a/pkg/exporter/sumologicexporter/test_data_test.go +++ b/pkg/exporter/sumologicexporter/test_data_test.go @@ -15,18 +15,20 @@ package sumologicexporter import ( - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) -func exampleIntMetric() (pdata.Metric, pdata.Map) { +func exampleIntMetric() (pmetric.Metric, pcommon.Map) { return buildExampleIntMetric(true) } -func buildExampleIntMetric(fillData bool) (pdata.Metric, pdata.Map) { - metric := pdata.NewMetric() +func buildExampleIntMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + metric := pmetric.NewMetric() metric.SetName("test.metric.data") metric.SetUnit("bytes") - metric.SetDataType(pdata.MetricDataTypeSum) + metric.SetDataType(pmetric.MetricDataTypeSum) if fillData { dp := metric.Sum().DataPoints().AppendEmpty() @@ -34,22 +36,22 @@ func buildExampleIntMetric(fillData bool) (pdata.Metric, pdata.Map) { dp.SetIntVal(14500) } - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("test", "test_value") attributes.InsertString("test2", "second_value") return metric, attributes } -func exampleIntGaugeMetric() (pdata.Metric, pdata.Map) { +func exampleIntGaugeMetric() (pmetric.Metric, pcommon.Map) { return buildExampleIntGaugeMetric(true) } -func buildExampleIntGaugeMetric(fillData bool) (pdata.Metric, pdata.Map) { - attributes := pdata.NewAttributeMap() - metric := pdata.NewMetric() +func buildExampleIntGaugeMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + attributes := pcommon.NewMap() + metric := pmetric.NewMetric() - metric.SetDataType(pdata.MetricDataTypeGauge) + metric.SetDataType(pmetric.MetricDataTypeGauge) metric.SetName("gauge_metric_name") attributes.InsertString("foo", "bar") @@ -71,15 +73,15 @@ func buildExampleIntGaugeMetric(fillData bool) (pdata.Metric, pdata.Map) { return metric, attributes } -func exampleDoubleGaugeMetric() (pdata.Metric, pdata.Map) { +func exampleDoubleGaugeMetric() (pmetric.Metric, pcommon.Map) { return buildExampleDoubleGaugeMetric(true) } -func buildExampleDoubleGaugeMetric(fillData bool) (pdata.Metric, pdata.Map) { - attributes := pdata.NewAttributeMap() - metric := pdata.NewMetric() +func buildExampleDoubleGaugeMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + attributes := pcommon.NewMap() + metric := pmetric.NewMetric() - metric.SetDataType(pdata.MetricDataTypeGauge) + metric.SetDataType(pmetric.MetricDataTypeGauge) metric.SetName("gauge_metric_name_double_test") attributes.InsertString("foo", "bar") @@ -101,15 +103,15 @@ func buildExampleDoubleGaugeMetric(fillData bool) (pdata.Metric, pdata.Map) { return metric, attributes } -func exampleIntSumMetric() (pdata.Metric, pdata.Map) { +func exampleIntSumMetric() (pmetric.Metric, pcommon.Map) { return buildExampleIntSumMetric(true) } -func buildExampleIntSumMetric(fillData bool) (pdata.Metric, pdata.Map) { - attributes := pdata.NewAttributeMap() - metric := pdata.NewMetric() +func buildExampleIntSumMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + attributes := pcommon.NewMap() + metric := pmetric.NewMetric() - metric.SetDataType(pdata.MetricDataTypeSum) + metric.SetDataType(pmetric.MetricDataTypeSum) metric.SetName("sum_metric_int_test") attributes.InsertString("foo", "bar") @@ -131,15 +133,15 @@ func buildExampleIntSumMetric(fillData bool) (pdata.Metric, pdata.Map) { return metric, attributes } -func exampleDoubleSumMetric() (pdata.Metric, pdata.Map) { +func exampleDoubleSumMetric() (pmetric.Metric, pcommon.Map) { return buildExampleDoubleSumMetric(true) } -func buildExampleDoubleSumMetric(fillData bool) (pdata.Metric, pdata.Map) { - attributes := pdata.NewAttributeMap() - metric := pdata.NewMetric() +func buildExampleDoubleSumMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + attributes := pcommon.NewMap() + metric := pmetric.NewMetric() - metric.SetDataType(pdata.MetricDataTypeSum) + metric.SetDataType(pmetric.MetricDataTypeSum) metric.SetName("sum_metric_double_test") attributes.InsertString("foo", "bar") @@ -161,15 +163,15 @@ func buildExampleDoubleSumMetric(fillData bool) (pdata.Metric, pdata.Map) { return metric, attributes } -func exampleSummaryMetric() (pdata.Metric, pdata.Map) { +func exampleSummaryMetric() (pmetric.Metric, pcommon.Map) { return buildExampleSummaryMetric(true) } -func buildExampleSummaryMetric(fillData bool) (pdata.Metric, pdata.Map) { - attributes := pdata.NewAttributeMap() - metric := pdata.NewMetric() +func buildExampleSummaryMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + attributes := pcommon.NewMap() + metric := pmetric.NewMetric() - metric.SetDataType(pdata.MetricDataTypeSummary) + metric.SetDataType(pmetric.MetricDataTypeSummary) metric.SetName("summary_metric_double_test") attributes.InsertString("foo", "bar") @@ -201,15 +203,15 @@ func buildExampleSummaryMetric(fillData bool) (pdata.Metric, pdata.Map) { return metric, attributes } -func exampleHistogramMetric() (pdata.Metric, pdata.Map) { +func exampleHistogramMetric() (pmetric.Metric, pcommon.Map) { return buildExampleHistogramMetric(true) } -func buildExampleHistogramMetric(fillData bool) (pdata.Metric, pdata.Map) { - attributes := pdata.NewAttributeMap() - metric := pdata.NewMetric() +func buildExampleHistogramMetric(fillData bool) (pmetric.Metric, pcommon.Map) { + attributes := pcommon.NewMap() + metric := pmetric.NewMetric() - metric.SetDataType(pdata.MetricDataTypeHistogram) + metric.SetDataType(pmetric.MetricDataTypeHistogram) metric.SetName("histogram_metric_double_test") attributes.InsertString("bar", "foo") @@ -240,8 +242,8 @@ func buildExampleHistogramMetric(fillData bool) (pdata.Metric, pdata.Map) { return metric, attributes } -func metricPairToMetrics(mp ...metricPair) pdata.Metrics { - metrics := pdata.NewMetrics() +func metricPairToMetrics(mp ...metricPair) pmetric.Metrics { + metrics := pmetric.NewMetrics() metrics.ResourceMetrics().EnsureCapacity(len(mp)) for _, record := range mp { rms := metrics.ResourceMetrics().AppendEmpty() @@ -253,8 +255,8 @@ func metricPairToMetrics(mp ...metricPair) pdata.Metrics { return metrics } -func metricAndAttrsToPdataMetrics(attributes pdata.Map, ms ...pdata.Metric) pdata.Metrics { - metrics := pdata.NewMetrics() +func metricAndAttrsToPdataMetrics(attributes pcommon.Map, ms ...pmetric.Metric) pmetric.Metrics { + metrics := pmetric.NewMetrics() metrics.ResourceMetrics().EnsureCapacity(len(ms)) rms := metrics.ResourceMetrics().AppendEmpty() @@ -269,8 +271,8 @@ func metricAndAttrsToPdataMetrics(attributes pdata.Map, ms ...pdata.Metric) pdat return metrics } -func metricAndAttributesToPdataMetrics(metric pdata.Metric, attributes pdata.Map) pdata.Metrics { - metrics := pdata.NewMetrics() +func metricAndAttributesToPdataMetrics(metric pmetric.Metric, attributes pcommon.Map) pmetric.Metrics { + metrics := pmetric.NewMetrics() metrics.ResourceMetrics().EnsureCapacity(attributes.Len()) rms := metrics.ResourceMetrics().AppendEmpty() attributes.CopyTo(rms.Resource().Attributes()) @@ -280,23 +282,23 @@ func metricAndAttributesToPdataMetrics(metric pdata.Metric, attributes pdata.Map } func fieldsFromMap(s map[string]string) fields { - attrMap := pdata.NewAttributeMap() + attrMap := pcommon.NewMap() for k, v := range s { attrMap.InsertString(k, v) } return newFields(attrMap) } -func exampleTrace() pdata.Traces { - td := pdata.NewTraces() +func exampleTrace() ptrace.Traces { + td := ptrace.NewTraces() rs := td.ResourceSpans().AppendEmpty() rs.Resource().Attributes().UpsertString("hostname", "testHost") rs.Resource().Attributes().UpsertString("_sourceHost", "source_host") rs.Resource().Attributes().UpsertString("_sourceName", "source_name") rs.Resource().Attributes().UpsertString("_sourceCategory", "source_category") span := rs.InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty() - span.SetTraceID(pdata.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) - span.SetSpanID(pdata.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73})) + span.SetTraceID(pcommon.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) + span.SetSpanID(pcommon.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73})) span.SetName("testSpan") span.SetStartTimestamp(1544712660000000000) span.SetEndTimestamp(1544712661000000000) diff --git a/pkg/exporter/sumologicexporter/translate_attributes.go b/pkg/exporter/sumologicexporter/translate_attributes.go index 81da9371bc..eed5ac1ec8 100644 --- a/pkg/exporter/sumologicexporter/translate_attributes.go +++ b/pkg/exporter/sumologicexporter/translate_attributes.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) // attributeTranslations maps OpenTelemetry attribute names to Sumo attribute names @@ -46,11 +46,11 @@ var attributeTranslations = map[string]string{ "file.path.resolved": "_sourceName", } -func translateAttributes(attributes pdata.AttributeMap) pdata.AttributeMap { - ret := pdata.NewAttributeMap() +func translateAttributes(attributes pcommon.Map) pcommon.Map { + ret := pcommon.NewMap() ret.EnsureCapacity(attributes.Len()) - attributes.Range(func(otKey string, value pdata.AttributeValue) bool { + attributes.Range(func(otKey string, value pcommon.Value) bool { if sumoKey, ok := attributeTranslations[otKey]; ok { // Only insert if it doesn't exist yet to prevent overwriting. // We have to do it this way since the final return value is not @@ -72,8 +72,8 @@ func translateAttributes(attributes pdata.AttributeMap) pdata.AttributeMap { // translateAttributesInPlace renames attribute keys according to attributeTranslations. // // DEPRECATED: Please use translateAttributes instead. -func translateAttributesInPlace(attributes pdata.AttributeMap) { - attributes.Range(func(otKey string, value pdata.AttributeValue) bool { +func translateAttributesInPlace(attributes pcommon.Map) { + attributes.Range(func(otKey string, value pcommon.Value) bool { if sumoKey, ok := attributeTranslations[otKey]; ok { // do not rename attribute if target name already exists if _, ok := attributes.Get(sumoKey); ok { diff --git a/pkg/exporter/sumologicexporter/translate_attributes_test.go b/pkg/exporter/sumologicexporter/translate_attributes_test.go index 8406ca8e72..af2132ae93 100644 --- a/pkg/exporter/sumologicexporter/translate_attributes_test.go +++ b/pkg/exporter/sumologicexporter/translate_attributes_test.go @@ -19,11 +19,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) func TestTranslateAttributes(t *testing.T) { - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("host.name", "testing-host") attributes.InsertString("host.id", "my-host-id") attributes.InsertString("host.type", "my-host-type") @@ -62,7 +62,7 @@ func TestTranslateAttributes(t *testing.T) { } func TestTranslateAttributesDoesNothingWhenAttributeDoesNotExist(t *testing.T) { - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() require.Equal(t, 0, attributes.Len()) attributes = translateAttributes(attributes) @@ -72,7 +72,7 @@ func TestTranslateAttributesDoesNothingWhenAttributeDoesNotExist(t *testing.T) { } func TestTranslateAttributesLeavesOtherAttributesUnchanged(t *testing.T) { - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("one", "one1") attributes.InsertString("host.name", "host1") attributes.InsertString("three", "three1") @@ -87,7 +87,7 @@ func TestTranslateAttributesLeavesOtherAttributesUnchanged(t *testing.T) { } func TestTranslateAttributesDoesNotOverwriteExistingAttribute(t *testing.T) { - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("host", "host1") attributes.InsertString("host.name", "hostname1") require.Equal(t, 2, attributes.Len()) @@ -100,9 +100,9 @@ func TestTranslateAttributesDoesNotOverwriteExistingAttribute(t *testing.T) { } func TestTranslateAttributesDoesNotOverwriteMultipleExistingAttributes(t *testing.T) { - // Note: Current implementation of pdata.AttributeMap does not allow to insert duplicate keys. + // Note: Current implementation of pcommon.Map does not allow to insert duplicate keys. // See https://cloud-native.slack.com/archives/C01N5UCHTEH/p1624020829067500 - attributes := pdata.NewAttributeMap() + attributes := pcommon.NewMap() attributes.InsertString("host", "host1") attributes.InsertString("host", "host2") require.Equal(t, 1, attributes.Len()) @@ -116,7 +116,7 @@ func TestTranslateAttributesDoesNotOverwriteMultipleExistingAttributes(t *testin assertAttribute(t, attributes, "host.name", "hostname1") } -func assertAttribute(t *testing.T, metadata pdata.AttributeMap, attributeName string, expectedValue string) { +func assertAttribute(t *testing.T, metadata pcommon.Map, attributeName string, expectedValue string) { value, exists := metadata.Get(attributeName) if expectedValue == "" { @@ -159,24 +159,24 @@ func TestTranslateConfigValue(t *testing.T) { } var ( - bench_pdata_attributes = map[string]pdata.AttributeValue{ - "host.name": pdata.NewAttributeValueString("testing-host"), - "host.id": pdata.NewAttributeValueString("my-host-id"), - "host.type": pdata.NewAttributeValueString("my-host-type"), - "k8s.cluster.name": pdata.NewAttributeValueString("testing-cluster"), - "k8s.deployment.name": pdata.NewAttributeValueString("my-deployment-name"), - "k8s.namespace.name": pdata.NewAttributeValueString("my-namespace-name"), - "k8s.service.name": pdata.NewAttributeValueString("my-service-name"), - "cloud.account.id": pdata.NewAttributeValueString("my-account-id"), - "cloud.availability_zone": pdata.NewAttributeValueString("my-zone"), - "cloud.region": pdata.NewAttributeValueString("my-region"), - "abc": pdata.NewAttributeValueString("abc"), - "def": pdata.NewAttributeValueString("def"), - "xyz": pdata.NewAttributeValueString("xyz"), - "jkl": pdata.NewAttributeValueString("jkl"), - "dummy": pdata.NewAttributeValueString("dummy"), + bench_pdata_attributes = map[string]interface{}{ + "host.name": pcommon.NewValueString("testing-host"), + "host.id": pcommon.NewValueString("my-host-id"), + "host.type": pcommon.NewValueString("my-host-type"), + "k8s.cluster.name": pcommon.NewValueString("testing-cluster"), + "k8s.deployment.name": pcommon.NewValueString("my-deployment-name"), + "k8s.namespace.name": pcommon.NewValueString("my-namespace-name"), + "k8s.service.name": pcommon.NewValueString("my-service-name"), + "cloud.account.id": pcommon.NewValueString("my-account-id"), + "cloud.availability_zone": pcommon.NewValueString("my-zone"), + "cloud.region": pcommon.NewValueString("my-region"), + "abc": pcommon.NewValueString("abc"), + "def": pcommon.NewValueString("def"), + "xyz": pcommon.NewValueString("xyz"), + "jkl": pcommon.NewValueString("jkl"), + "dummy": pcommon.NewValueString("dummy"), } - attributes = pdata.NewAttributeMapFromMap(bench_pdata_attributes) + attributes = pcommon.NewMapFromRaw(bench_pdata_attributes) ) func BenchmarkTranslateAttributes(b *testing.B) { @@ -187,7 +187,7 @@ func BenchmarkTranslateAttributes(b *testing.B) { func BenchmarkTranslateAttributesInPlace(b *testing.B) { for i := 0; i < b.N; i++ { - attributes := pdata.NewAttributeMapFromMap(bench_pdata_attributes) + attributes := pcommon.NewMapFromRaw(bench_pdata_attributes) translateAttributesInPlace(attributes) } } diff --git a/pkg/exporter/sumologicexporter/translate_metrics.go b/pkg/exporter/sumologicexporter/translate_metrics.go index 7bf325e3cc..d0fc68d677 100644 --- a/pkg/exporter/sumologicexporter/translate_metrics.go +++ b/pkg/exporter/sumologicexporter/translate_metrics.go @@ -14,13 +14,13 @@ package sumologicexporter -import "go.opentelemetry.io/collector/model/pdata" +import "go.opentelemetry.io/collector/pdata/pmetric" // translateTelegrafMetric translates telegraf metrics names to align with // Sumo conventions expected in Sumo host related apps, for example: // * `procstat_num_threads` => `Proc_Threads` // * `cpu_usage_irq` => `CPU_Irq` -func translateTelegrafMetric(m pdata.Metric) { +func translateTelegrafMetric(m pmetric.Metric) { var newName string switch m.Name() { diff --git a/pkg/exporter/sumologicexporter/translate_metrics_test.go b/pkg/exporter/sumologicexporter/translate_metrics_test.go index 667acfe52b..278b479b88 100644 --- a/pkg/exporter/sumologicexporter/translate_metrics_test.go +++ b/pkg/exporter/sumologicexporter/translate_metrics_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestTranslateTelegrafMetric_NamesAreTranslatedCorrectly(t *testing.T) { @@ -210,7 +210,7 @@ func TestTranslateTelegrafMetric_NamesAreTranslatedCorrectly(t *testing.T) { for _, tc := range testcases { t.Run(tc.nameIn+"-"+tc.nameOut, func(t *testing.T) { - actual := pdata.NewMetric() + actual := pmetric.NewMetric() actual.SetName(tc.nameIn) translateTelegrafMetric(actual) assert.Equal(t, tc.nameOut, actual.Name()) diff --git a/pkg/extension/sumologicextension/go.mod b/pkg/extension/sumologicextension/go.mod index 7bb48c11f5..33eb21ca8f 100644 --- a/pkg/extension/sumologicextension/go.mod +++ b/pkg/extension/sumologicextension/go.mod @@ -3,11 +3,11 @@ module github.com/SumoLogic/sumologic-otel-collector/pkg/extension/sumologicexte go 1.18 require ( - github.com/cenkalti/backoff/v4 v4.1.2 + github.com/cenkalti/backoff/v4 v4.1.3 github.com/google/uuid v1.3.0 github.com/hashicorp/go-multierror v1.1.1 github.com/stretchr/testify v1.7.1 - go.opentelemetry.io/collector v0.48.0 + go.opentelemetry.io/collector v0.49.0 go.uber.org/zap v1.21.0 google.golang.org/grpc v1.45.0 ) @@ -22,20 +22,21 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/klauspost/compress v1.15.1 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rs/cors v1.8.2 // indirect - github.com/spf13/cast v1.4.1 // indirect - go.opentelemetry.io/collector/model v0.48.0 // indirect + go.opentelemetry.io/collector/pdata v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect + golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect + golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/pkg/extension/sumologicextension/go.sum b/pkg/extension/sumologicextension/go.sum index cda6af2888..72aa4a7676 100644 --- a/pkg/extension/sumologicextension/go.sum +++ b/pkg/extension/sumologicextension/go.sum @@ -17,8 +17,8 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= -github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -120,8 +120,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -162,8 +162,6 @@ github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -176,20 +174,23 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0/go.mod h1:PFmBsWbldL1kiWZk9+0LBZz2brhByaGsvp6pRICMlPE= go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -223,6 +224,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -246,11 +249,13 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter.go b/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter.go index 4f8cc26614..6fd6118079 100644 --- a/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter.go +++ b/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter.go @@ -17,7 +17,7 @@ package bigendianconverter import ( "encoding/binary" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) // NOTE: @@ -25,23 +25,23 @@ import ( // https://github.com/open-telemetry/opentelemetry-collector/blob/v0.28.0/internal/idutils/big_endian_converter.go // to allow processor tests to still run as they used to. -// UInt64ToTraceID converts the pair of uint64 representation of a TraceID to pdata.TraceID. -func UInt64ToTraceID(high, low uint64) pdata.TraceID { +// UInt64ToTraceID converts the pair of uint64 representation of a TraceID to pcommon.TraceID. +func UInt64ToTraceID(high, low uint64) pcommon.TraceID { traceID := [16]byte{} binary.BigEndian.PutUint64(traceID[:8], high) binary.BigEndian.PutUint64(traceID[8:], low) - return pdata.NewTraceID(traceID) + return pcommon.NewTraceID(traceID) } -// SpanIDToUInt64 converts the pdata.SpanID to uint64 representation. -func SpanIDToUInt64(spanID pdata.SpanID) uint64 { +// SpanIDToUInt64 converts the pcommon.SpanID to uint64 representation. +func SpanIDToUInt64(spanID pcommon.SpanID) uint64 { bytes := spanID.Bytes() return binary.BigEndian.Uint64(bytes[:]) } -// UInt64ToSpanID converts the uint64 representation of a SpanID to pdata.SpanID. -func UInt64ToSpanID(id uint64) pdata.SpanID { +// UInt64ToSpanID converts the uint64 representation of a SpanID to pcommon.SpanID. +func UInt64ToSpanID(id uint64) pcommon.SpanID { spanID := [8]byte{} binary.BigEndian.PutUint64(spanID[:], id) - return pdata.NewSpanID(spanID) + return pcommon.NewSpanID(spanID) } diff --git a/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter_test.go b/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter_test.go index c601a15899..5dafbb8b67 100644 --- a/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter_test.go +++ b/pkg/processor/cascadingfilterprocessor/bigendianconverter/big_endian_converter_test.go @@ -19,44 +19,44 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) func TestUInt64ToTraceIDConversion(t *testing.T) { assert.Equal(t, - pdata.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), + pcommon.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), UInt64ToTraceID(0, 0), "Failed 0 conversion:") assert.Equal(t, - pdata.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}), + pcommon.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}), UInt64ToTraceID(256*256+256+1, 256+1), "Failed simple conversion:") assert.Equal(t, - pdata.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05}), + pcommon.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05}), UInt64ToTraceID(0, 5), "Failed to convert 0 high:") assert.Equal(t, UInt64ToTraceID(5, 0), - pdata.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), + pcommon.NewTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), UInt64ToTraceID(5, 0), "Failed to convert 0 low:") assert.Equal(t, - pdata.NewTraceID([16]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05}), + pcommon.NewTraceID([16]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05}), UInt64ToTraceID(math.MaxUint64, 5), "Failed to convert MaxUint64:") } func TestUInt64ToSpanIDConversion(t *testing.T) { assert.Equal(t, - pdata.NewSpanID([8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), + pcommon.NewSpanID([8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), UInt64ToSpanID(0), "Failed 0 conversion:") assert.Equal(t, - pdata.NewSpanID([8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01}), + pcommon.NewSpanID([8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01}), UInt64ToSpanID(256*256+256+1), "Failed simple conversion:") assert.Equal(t, - pdata.NewSpanID([8]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}), + pcommon.NewSpanID([8]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}), UInt64ToSpanID(math.MaxUint64), "Failed to convert MaxUint64:") } diff --git a/pkg/processor/cascadingfilterprocessor/cascading_test.go b/pkg/processor/cascadingfilterprocessor/cascading_test.go index b179c1fafa..3c3067c252 100644 --- a/pkg/processor/cascadingfilterprocessor/cascading_test.go +++ b/pkg/processor/cascadingfilterprocessor/cascading_test.go @@ -22,7 +22,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" cfconfig "github.com/SumoLogic/sumologic-otel-collector/pkg/processor/cascadingfilterprocessor/config" @@ -91,19 +92,19 @@ var cfgAutoRate = cfconfig.Config{ }, } -func fillSpan(span *pdata.Span, durationMicros int64) { +func fillSpan(span *ptrace.Span, durationMicros int64) { nowTs := time.Now().UnixNano() startTime := nowTs - durationMicros*1000 span.Attributes().InsertInt("foo", 55) - span.SetStartTimestamp(pdata.Timestamp(startTime)) - span.SetEndTimestamp(pdata.Timestamp(nowTs)) + span.SetStartTimestamp(pcommon.Timestamp(startTime)) + span.SetEndTimestamp(pcommon.Timestamp(nowTs)) } func createTrace(fsp *cascadingFilterSpanProcessor, numSpans int, durationMicros int64) *sampling.TraceData { - var traceBatches []pdata.Traces + var traceBatches []ptrace.Traces - traces := pdata.NewTraces() + traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() ils := rs.InstrumentationLibrarySpans().AppendEmpty() @@ -141,25 +142,25 @@ func createCascadingEvaluatorWithConfig(t *testing.T, conf cfconfig.Config) *cas func TestSampling(t *testing.T) { cascading := createCascadingEvaluator(t) - decision, policy := cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{0}), createTrace(cascading, 8, 1000000)) + decision, policy := cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{0}), createTrace(cascading, 8, 1000000)) require.NotNil(t, policy) require.Equal(t, sampling.Sampled, decision) - decision, _ = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), createTrace(cascading, 1000, 1000)) + decision, _ = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), createTrace(cascading, 1000, 1000)) require.Equal(t, sampling.SecondChance, decision) } func TestSecondChanceEvaluation(t *testing.T) { cascading := createCascadingEvaluator(t) - decision, _ := cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{0}), createTrace(cascading, 8, 1000)) + decision, _ := cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{0}), createTrace(cascading, 8, 1000)) require.Equal(t, sampling.SecondChance, decision) - decision, _ = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), createTrace(cascading, 8, 1000)) + decision, _ = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), createTrace(cascading, 8, 1000)) require.Equal(t, sampling.SecondChance, decision) // TODO: This could me optimized to make a decision within cascadingfilter processor, as such span would never fit anyway - //decision, _ = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), createTrace(8000, 1000), metrics) + //decision, _ = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), createTrace(8000, 1000), metrics) //require.Equal(t, sampling.NotSampled, decision) } @@ -169,12 +170,12 @@ func TestProbabilisticFilter(t *testing.T) { cascading := createCascadingEvaluator(t) trace1 := createTrace(cascading, 8, 1000000) - decision, _ := cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{0}), trace1) + decision, _ := cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{0}), trace1) require.Equal(t, sampling.Sampled, decision) require.True(t, trace1.SelectedByProbabilisticFilter) trace2 := createTrace(cascading, 800, 1000000) - decision, _ = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), trace2) + decision, _ = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), trace2) require.Equal(t, sampling.SecondChance, decision) require.False(t, trace2.SelectedByProbabilisticFilter) @@ -188,8 +189,8 @@ func TestDropTraces(t *testing.T) { trace1 := createTrace(cascading, 8, 1000000) trace2 := createTrace(cascading, 8, 1000000) trace2.ReceivedBatches[0].ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(2).SetName("health-check") - require.False(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{0}), trace1)) - require.True(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{0}), trace2)) + require.False(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{0}), trace1)) + require.True(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{0}), trace2)) } func TestDropTracesAndNotLimitOthers(t *testing.T) { @@ -200,20 +201,20 @@ func TestDropTracesAndNotLimitOthers(t *testing.T) { trace2.ReceivedBatches[0].ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(2).SetName("health-check") trace3 := createTrace(cascading, 5000, 1000000) - decision, policy := cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{0}), trace1) + decision, policy := cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{0}), trace1) require.Nil(t, policy) require.Equal(t, sampling.Sampled, decision) - require.False(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{0}), trace1)) + require.False(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{0}), trace1)) - decision, policy = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), trace2) + decision, policy = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), trace2) require.Nil(t, policy) require.Equal(t, sampling.Sampled, decision) - require.True(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{1}), trace2)) + require.True(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{1}), trace2)) - decision, policy = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{2}), trace3) + decision, policy = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{2}), trace3) require.Nil(t, policy) require.Equal(t, sampling.Sampled, decision) - require.False(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{2}), trace3)) + require.False(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{2}), trace3)) } func TestDropTracesAndAutoRateOthers(t *testing.T) { @@ -224,33 +225,33 @@ func TestDropTracesAndAutoRateOthers(t *testing.T) { trace2.ReceivedBatches[0].ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(2).SetName("health-check") trace3 := createTrace(cascading, 20, 1000000) - decision, policy := cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{0}), trace1) + decision, policy := cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{0}), trace1) require.NotNil(t, policy) require.Equal(t, sampling.Sampled, decision) - require.False(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{0}), trace1)) + require.False(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{0}), trace1)) - decision, policy = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), trace2) + decision, policy = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), trace2) require.NotNil(t, policy) require.Equal(t, sampling.Sampled, decision) - require.True(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{1}), trace2)) + require.True(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{1}), trace2)) - decision, policy = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{2}), trace3) + decision, policy = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{2}), trace3) require.Nil(t, policy) require.Equal(t, sampling.NotSampled, decision) - require.False(t, cascading.shouldBeDropped(pdata.NewTraceID([16]byte{2}), trace3)) + require.False(t, cascading.shouldBeDropped(pcommon.NewTraceID([16]byte{2}), trace3)) } //func TestSecondChanceReevaluation(t *testing.T) { // cascading := createCascadingEvaluator() // -// decision, _ := cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), createTrace(100, 1000), metrics) +// decision, _ := cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), createTrace(100, 1000), metrics) // require.Equal(t, sampling.Sampled, decision) // // // Too much -// decision, _ = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), createTrace(1000, 1000), metrics) +// decision, _ = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), createTrace(1000, 1000), metrics) // require.Equal(t, sampling.NotSampled, decision) // // // Just right -// decision, _ = cascading.makeProvisionalDecision(pdata.NewTraceID([16]byte{1}), createTrace(900, 1000), metrics) +// decision, _ = cascading.makeProvisionalDecision(pcommon.NewTraceID([16]byte{1}), createTrace(900, 1000), metrics) // require.Equal(t, sampling.Sampled, decision) //} diff --git a/pkg/processor/cascadingfilterprocessor/go.mod b/pkg/processor/cascadingfilterprocessor/go.mod index 5f86fae30d..ff1e68073b 100644 --- a/pkg/processor/cascadingfilterprocessor/go.mod +++ b/pkg/processor/cascadingfilterprocessor/go.mod @@ -6,25 +6,24 @@ require ( github.com/google/uuid v1.3.0 github.com/stretchr/testify v1.7.1 go.opencensus.io v0.23.0 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/pdata v0.49.0 go.uber.org/zap v1.21.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pelletier/go-toml v1.9.3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/cast v1.4.1 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/pkg/processor/cascadingfilterprocessor/go.sum b/pkg/processor/cascadingfilterprocessor/go.sum index 34615532d0..59365ad843 100644 --- a/pkg/processor/cascadingfilterprocessor/go.sum +++ b/pkg/processor/cascadingfilterprocessor/go.sum @@ -15,7 +15,7 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -70,7 +70,6 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8 github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -100,8 +99,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -143,8 +142,6 @@ github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8d github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -159,20 +156,18 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 h1:li8u9OSMvLau7rMs8bmiL82OazG6MAkwPz2i6eS8TBQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -204,7 +199,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -226,7 +221,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher.go b/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher.go index 29e2632b76..0d393a9c0f 100644 --- a/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher.go +++ b/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher.go @@ -20,7 +20,7 @@ import ( "errors" "sync" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) var ( @@ -31,7 +31,7 @@ var ( ) // Batch is the type of batches held by the Batcher. -type Batch []pdata.TraceID +type Batch []pcommon.TraceID // Batcher behaves like a pipeline of batches that has a fixed number of batches in the pipe // and a new batch being built outside of the pipe. Items can be concurrently added to the batch @@ -44,7 +44,7 @@ type Batcher interface { // of limiting the growth of the current batch if appropriate for its scenario. It can // either call CloseCurrentAndTakeFirstBatch earlier or stop adding new items depending on what is // required by the scenario. - AddToCurrentBatch(id pdata.TraceID) + AddToCurrentBatch(id pcommon.TraceID) // CloseCurrentAndTakeFirstBatch takes the batch at the front of the pipe, and moves the current // batch to the end of the pipe, creating a new batch to receive new items. This operation should // be atomic. @@ -59,8 +59,8 @@ type Batcher interface { var _ Batcher = (*batcher)(nil) type batcher struct { - pendingIds chan pdata.TraceID // Channel for the ids to be added to the next batch. - batches chan Batch // Channel with already captured batches. + pendingIds chan pcommon.TraceID // Channel for the ids to be added to the next batch. + batches chan Batch // Channel with already captured batches. // cbMutex protects the currentBatch storing ids. cbMutex sync.Mutex @@ -92,7 +92,7 @@ func New(numBatches, newBatchesInitialCapacity, batchChannelSize uint64) (Batche } batcher := &batcher{ - pendingIds: make(chan pdata.TraceID, batchChannelSize), + pendingIds: make(chan pcommon.TraceID, batchChannelSize), batches: batches, currentBatch: make(Batch, 0, newBatchesInitialCapacity), newBatchesInitialCapacity: newBatchesInitialCapacity, @@ -113,7 +113,7 @@ func New(numBatches, newBatchesInitialCapacity, batchChannelSize uint64) (Batche return batcher, nil } -func (b *batcher) AddToCurrentBatch(id pdata.TraceID) { +func (b *batcher) AddToCurrentBatch(id pcommon.TraceID) { b.pendingIds <- id } diff --git a/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher_test.go b/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher_test.go index 335c0fa189..664b954238 100644 --- a/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher_test.go +++ b/pkg/processor/cascadingfilterprocessor/idbatcher/id_batcher_test.go @@ -22,7 +22,7 @@ import ( "time" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" "github.com/SumoLogic/sumologic-otel-collector/pkg/processor/cascadingfilterprocessor/bigendianconverter" ) @@ -120,7 +120,7 @@ func concurrencyTest(t *testing.T, numBatches, newBatchesInitialCapacity, batchC wg := &sync.WaitGroup{} for i := 0; i < len(ids); i++ { wg.Add(1) - go func(id pdata.TraceID) { + go func(id pcommon.TraceID) { batcher.AddToCurrentBatch(id) wg.Done() }(ids[i]) @@ -152,8 +152,8 @@ func concurrencyTest(t *testing.T, numBatches, newBatchesInitialCapacity, batchC } } -func generateSequentialIds(numIds uint64) []pdata.TraceID { - ids := make([]pdata.TraceID, numIds) +func generateSequentialIds(numIds uint64) []pcommon.TraceID { + ids := make([]pcommon.TraceID, numIds) for i := uint64(0); i < numIds; i++ { ids[i] = bigendianconverter.UInt64ToTraceID(0, i) } diff --git a/pkg/processor/cascadingfilterprocessor/processor.go b/pkg/processor/cascadingfilterprocessor/processor.go index 859660675e..2dc0f775b9 100644 --- a/pkg/processor/cascadingfilterprocessor/processor.go +++ b/pkg/processor/cascadingfilterprocessor/processor.go @@ -28,7 +28,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenterror" "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" "github.com/SumoLogic/sumologic-otel-collector/pkg/processor/cascadingfilterprocessor/config" @@ -407,7 +408,7 @@ func (cfsp *cascadingFilterSpanProcessor) samplingPolicyOnTick() { // Combine all individual batches into a single batch so // consumers may operate on the entire trace - allSpans := pdata.NewTraces() + allSpans := ptrace.NewTraces() for j := 0; j < len(traceBatches); j++ { batch := traceBatches[j] batch.ResourceSpans().MoveAndAppendTo(allSpans.ResourceSpans()) @@ -450,7 +451,7 @@ func (cfsp *cascadingFilterSpanProcessor) samplingPolicyOnTick() { ) } -func updateProbabilisticRateTag(traces pdata.Traces, probabilisticSpans int64, allSpans int64) { +func updateProbabilisticRateTag(traces ptrace.Traces, probabilisticSpans int64, allSpans int64) { ratio := float64(probabilisticSpans) / float64(allSpans) rs := traces.ResourceSpans() @@ -462,7 +463,7 @@ func updateProbabilisticRateTag(traces pdata.Traces, probabilisticSpans int64, a for k := 0; k < spans.Len(); k++ { attrs := spans.At(k).Attributes() av, found := attrs.Get(AttributeSamplingProbability) - if found && av.Type() == pdata.AttributeValueTypeDouble && !math.IsNaN(av.DoubleVal()) && av.DoubleVal() > 0.0 { + if found && av.Type() == pcommon.ValueTypeDouble && !math.IsNaN(av.DoubleVal()) && av.DoubleVal() > 0.0 { av.SetDoubleVal(av.DoubleVal() * ratio) } else { attrs.UpsertDouble(AttributeSamplingProbability, ratio) @@ -473,7 +474,7 @@ func updateProbabilisticRateTag(traces pdata.Traces, probabilisticSpans int64, a } } -func updateFilteringTag(traces pdata.Traces) { +func updateFilteringTag(traces ptrace.Traces) { rs := traces.ResourceSpans() for i := 0; i < rs.Len(); i++ { @@ -488,7 +489,7 @@ func updateFilteringTag(traces pdata.Traces) { } } -func (cfsp *cascadingFilterSpanProcessor) shouldBeDropped(id pdata.TraceID, trace *sampling.TraceData) bool { +func (cfsp *cascadingFilterSpanProcessor) shouldBeDropped(id pcommon.TraceID, trace *sampling.TraceData) bool { for _, dropRule := range cfsp.traceRejectRules { if dropRule.Evaluator.ShouldDrop(id, trace) { err := stats.RecordWithTags(dropRule.ctx, []tag.Mutator{tag.Insert(tagProcessorKey, cfsp.instanceName)}, statPolicyDecision.M(int64(1))) @@ -499,7 +500,7 @@ func (cfsp *cascadingFilterSpanProcessor) shouldBeDropped(id pdata.TraceID, trac return false } -func (cfsp *cascadingFilterSpanProcessor) makeProvisionalDecision(id pdata.TraceID, trace *sampling.TraceData) (sampling.Decision, *TraceAcceptEvaluator) { +func (cfsp *cascadingFilterSpanProcessor) makeProvisionalDecision(id pcommon.TraceID, trace *sampling.TraceData) (sampling.Decision, *TraceAcceptEvaluator) { // When no rules are defined, always sample if len(cfsp.traceAcceptRules) == 0 { return sampling.Sampled, nil @@ -580,7 +581,7 @@ func (cfsp *cascadingFilterSpanProcessor) makeProvisionalDecision(id pdata.Trace } // ConsumeTraces is required by the SpanProcessor interface. -func (cfsp *cascadingFilterSpanProcessor) ConsumeTraces(ctx context.Context, td pdata.Traces) error { +func (cfsp *cascadingFilterSpanProcessor) ConsumeTraces(ctx context.Context, td ptrace.Traces) error { if !cfsp.filteringEnabled { return cfsp.nextConsumer.ConsumeTraces(ctx, td) } @@ -597,8 +598,8 @@ func (cfsp *cascadingFilterSpanProcessor) ConsumeTraces(ctx context.Context, td return nil } -func (cfsp *cascadingFilterSpanProcessor) groupSpansByTraceKey(resourceSpans pdata.ResourceSpans) map[traceKey][]*pdata.Span { - idToSpans := make(map[traceKey][]*pdata.Span) +func (cfsp *cascadingFilterSpanProcessor) groupSpansByTraceKey(resourceSpans ptrace.ResourceSpans) map[traceKey][]*ptrace.Span { + idToSpans := make(map[traceKey][]*ptrace.Span) ilss := resourceSpans.InstrumentationLibrarySpans() for j := 0; j < ilss.Len(); j++ { ils := ilss.At(j) @@ -615,7 +616,7 @@ func (cfsp *cascadingFilterSpanProcessor) groupSpansByTraceKey(resourceSpans pda return idToSpans } -func (cfsp *cascadingFilterSpanProcessor) processTraces(ctx context.Context, resourceSpans pdata.ResourceSpans) { +func (cfsp *cascadingFilterSpanProcessor) processTraces(ctx context.Context, resourceSpans ptrace.ResourceSpans) { // Group spans per their traceId to minimize contention on idToTrace idToSpans := cfsp.groupSpansByTraceKey(resourceSpans) var newTraceIDs int64 @@ -640,7 +641,7 @@ func (cfsp *cascadingFilterSpanProcessor) processTraces(ctx context.Context, res atomic.AddInt32(&actualData.SpanCount, lenSpans) } else { newTraceIDs++ - cfsp.decisionBatcher.AddToCurrentBatch(pdata.NewTraceID(id)) + cfsp.decisionBatcher.AddToCurrentBatch(pcommon.NewTraceID(id)) atomic.AddUint64(&cfsp.numTracesOnMap, 1) postDeletion := false currTime := time.Now() @@ -753,8 +754,8 @@ func (cfsp *cascadingFilterSpanProcessor) dropTrace(traceID traceKey, deletionTi cfsp.logMetricsRecordErrorIfPresent(err, []string{statTraceRemovalAgeSec.Name()}) } -func prepareTraceBatch(rss pdata.ResourceSpans, spans []*pdata.Span) pdata.Traces { - traceTd := pdata.NewTraces() +func prepareTraceBatch(rss ptrace.ResourceSpans, spans []*ptrace.Span) ptrace.Traces { + traceTd := ptrace.NewTraces() rs := traceTd.ResourceSpans().AppendEmpty() rss.Resource().CopyTo(rs.Resource()) ils := rs.InstrumentationLibrarySpans().AppendEmpty() diff --git a/pkg/processor/cascadingfilterprocessor/processor_test.go b/pkg/processor/cascadingfilterprocessor/processor_test.go index 3ce95b4593..54d4794852 100644 --- a/pkg/processor/cascadingfilterprocessor/processor_test.go +++ b/pkg/processor/cascadingfilterprocessor/processor_test.go @@ -26,7 +26,8 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" "github.com/SumoLogic/sumologic-otel-collector/pkg/processor/cascadingfilterprocessor/bigendianconverter" @@ -90,13 +91,13 @@ func TestConcurrentTraceArrival(t *testing.T) { for _, batch := range batches { // Add the same traceId twice. wg.Add(2) - go func(td pdata.Traces) { + go func(td ptrace.Traces) { if err := tsp.ConsumeTraces(context.Background(), td); err != nil { t.Errorf("Failed consuming traces: %v", err) } wg.Done() }(batch) - go func(td pdata.Traces) { + go func(td ptrace.Traces) { if err := tsp.ConsumeTraces(context.Background(), td); err != nil { t.Errorf("Failed consuming traces: %v", err) } @@ -160,7 +161,7 @@ func TestConcurrentTraceMapSize(t *testing.T) { tsp := sp.(*cascadingFilterSpanProcessor) for _, batch := range batches { wg.Add(1) - go func(td pdata.Traces) { + go func(td ptrace.Traces) { if err := tsp.ConsumeTraces(context.Background(), td); err != nil { t.Errorf("Failed consuming traces: %v", err) } @@ -527,15 +528,15 @@ func TestMultipleBatchesAreCombinedIntoOne(t *testing.T) { require.EqualValues(t, 3, len(msp.AllTraces()), "There should be three batches, one for each trace") - expectedSpanIds := make(map[int][]pdata.SpanID) - expectedSpanIds[0] = []pdata.SpanID{ + expectedSpanIds := make(map[int][]pcommon.SpanID) + expectedSpanIds[0] = []pcommon.SpanID{ bigendianconverter.UInt64ToSpanID(uint64(1)), } - expectedSpanIds[1] = []pdata.SpanID{ + expectedSpanIds[1] = []pcommon.SpanID{ bigendianconverter.UInt64ToSpanID(uint64(2)), bigendianconverter.UInt64ToSpanID(uint64(3)), } - expectedSpanIds[2] = []pdata.SpanID{ + expectedSpanIds[2] = []pcommon.SpanID{ bigendianconverter.UInt64ToSpanID(uint64(4)), bigendianconverter.UInt64ToSpanID(uint64(5)), bigendianconverter.UInt64ToSpanID(uint64(6)), @@ -562,8 +563,8 @@ func TestMultipleBatchesAreCombinedIntoOne(t *testing.T) { } //nolint:unused -func collectSpanIds(trace *pdata.Traces) []pdata.SpanID { - spanIDs := make([]pdata.SpanID, 0) +func collectSpanIds(trace *ptrace.Traces) []pcommon.SpanID { + spanIDs := make([]pcommon.SpanID, 0) for i := 0; i < trace.ResourceSpans().Len(); i++ { ilss := trace.ResourceSpans().At(i).InstrumentationLibrarySpans() @@ -582,7 +583,7 @@ func collectSpanIds(trace *pdata.Traces) []pdata.SpanID { } //nolint:unused -func findTrace(a []pdata.Traces, traceID pdata.TraceID) *pdata.Traces { +func findTrace(a []ptrace.Traces, traceID pcommon.TraceID) *ptrace.Traces { for _, batch := range a { id := batch.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).TraceID() if traceID.Bytes() == id.Bytes() { @@ -592,10 +593,10 @@ func findTrace(a []pdata.Traces, traceID pdata.TraceID) *pdata.Traces { return nil } -func generateIdsAndBatches(numIds int) ([]pdata.TraceID, []pdata.Traces) { - traceIds := make([]pdata.TraceID, numIds) +func generateIdsAndBatches(numIds int) ([]pcommon.TraceID, []ptrace.Traces) { + traceIds := make([]pcommon.TraceID, numIds) spanID := 0 - var tds []pdata.Traces + var tds []ptrace.Traces for i := 0; i < numIds; i++ { traceIds[i] = bigendianconverter.UInt64ToTraceID(1, uint64(i+1)) // Send each span in a separate batch @@ -614,13 +615,13 @@ func generateIdsAndBatches(numIds int) ([]pdata.TraceID, []pdata.Traces) { } //nolint:unused -func simpleTraces() pdata.Traces { - return simpleTracesWithID(pdata.NewTraceID([16]byte{1, 2, 3, 4})) +func simpleTraces() ptrace.Traces { + return simpleTracesWithID(pcommon.NewTraceID([16]byte{1, 2, 3, 4})) } //nolint:unused -func simpleTracesWithID(traceID pdata.TraceID) pdata.Traces { - traces := pdata.NewTraces() +func simpleTracesWithID(traceID pcommon.TraceID) ptrace.Traces { + traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() ils := rs.InstrumentationLibrarySpans().AppendEmpty() @@ -642,12 +643,12 @@ type mockDropEvaluator struct{} var _ sampling.PolicyEvaluator = (*mockPolicyEvaluator)(nil) var _ sampling.DropTraceEvaluator = (*mockDropEvaluator)(nil) -func (m *mockPolicyEvaluator) Evaluate(_ pdata.TraceID, _ *sampling.TraceData) sampling.Decision { +func (m *mockPolicyEvaluator) Evaluate(_ pcommon.TraceID, _ *sampling.TraceData) sampling.Decision { m.EvaluationCount++ return m.NextDecision } -func (d *mockDropEvaluator) ShouldDrop(_ pdata.TraceID, _ *sampling.TraceData) bool { +func (d *mockDropEvaluator) ShouldDrop(_ pcommon.TraceID, _ *sampling.TraceData) bool { return true } @@ -685,7 +686,7 @@ func newSyncIDBatcher(numBatches uint64) idbatcher.Batcher { } } -func (s *syncIDBatcher) AddToCurrentBatch(id pdata.TraceID) { +func (s *syncIDBatcher) AddToCurrentBatch(id pcommon.TraceID) { s.Lock() s.openBatch = append(s.openBatch, id) s.Unlock() diff --git a/pkg/processor/cascadingfilterprocessor/sampling/always_sample_test.go b/pkg/processor/cascadingfilterprocessor/sampling/always_sample_test.go index 308c92235b..1f3cbe1e57 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/always_sample_test.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/always_sample_test.go @@ -19,7 +19,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" "go.uber.org/zap" ) @@ -33,8 +33,8 @@ func newAlwaysSample() *policyEvaluator { func TestEvaluate_AlwaysSample(t *testing.T) { filter := newAlwaysSample() decision := filter.Evaluate( - pdata.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), - newTraceStringAttrs(map[string]pdata.AttributeValue{}, "example", "value"), + pcommon.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), + newTraceStringAttrs(map[string]interface{}{}, "example", "value"), ) assert.Equal(t, decision, Sampled) } diff --git a/pkg/processor/cascadingfilterprocessor/sampling/attrs_filter_test.go b/pkg/processor/cascadingfilterprocessor/sampling/attrs_filter_test.go index 4b7bf36195..90167865e5 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/attrs_filter_test.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/attrs_filter_test.go @@ -20,7 +20,8 @@ import ( "testing" "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" ) @@ -132,13 +133,13 @@ func TestAttributesFilter(t *testing.T) { } } -func newTrace() (*TraceData, pdata.AttributeMap) { +func newTrace() (*TraceData, pcommon.Map) { endTs := time.Now().UnixNano() startTs := endTs - 100000 - var traceBatches []pdata.Traces + var traceBatches []ptrace.Traces - traces := pdata.NewTraces() + traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() ils := rs.InstrumentationLibrarySpans().AppendEmpty() @@ -147,8 +148,8 @@ func newTrace() (*TraceData, pdata.AttributeMap) { span := spans.AppendEmpty() span.SetName("fooname") - span.SetStartTimestamp(pdata.Timestamp(startTs)) - span.SetEndTimestamp(pdata.Timestamp(endTs)) + span.SetStartTimestamp(pcommon.Timestamp(startTs)) + span.SetEndTimestamp(pcommon.Timestamp(endTs)) traceBatches = append(traceBatches, traces) diff --git a/pkg/processor/cascadingfilterprocessor/sampling/drop_trace_factory.go b/pkg/processor/cascadingfilterprocessor/sampling/drop_trace_factory.go index d434c809da..d8acc93127 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/drop_trace_factory.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/drop_trace_factory.go @@ -17,7 +17,7 @@ package sampling import ( "regexp" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" "go.uber.org/zap" "github.com/SumoLogic/sumologic-otel-collector/pkg/processor/cascadingfilterprocessor/config" @@ -65,7 +65,7 @@ func NewDropTraceEvaluator(logger *zap.Logger, cfg config.TraceRejectCfg) (DropT } // ShouldDrop checks if trace should be dropped -func (dte *dropTraceEvaluator) ShouldDrop(_ pdata.TraceID, trace *TraceData) bool { +func (dte *dropTraceEvaluator) ShouldDrop(_ pcommon.TraceID, trace *TraceData) bool { trace.Lock() batches := trace.ReceivedBatches trace.Unlock() diff --git a/pkg/processor/cascadingfilterprocessor/sampling/numeric_tag_filter_test.go b/pkg/processor/cascadingfilterprocessor/sampling/numeric_tag_filter_test.go index d6cdb5ca42..374a1bc11f 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/numeric_tag_filter_test.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/numeric_tag_filter_test.go @@ -21,7 +21,8 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" ) @@ -38,11 +39,11 @@ func newNumericAttributeFilter(minValue int64, maxValue int64) *policyEvaluator } func TestNumericTagFilter(t *testing.T) { - var empty = map[string]pdata.AttributeValue{} + var empty = map[string]interface{}{} filter := newNumericAttributeFilter(math.MinInt32, math.MaxInt32) - resAttr := map[string]pdata.AttributeValue{} - resAttr["example"] = pdata.NewAttributeValueInt(8) + resAttr := map[string]interface{}{} + resAttr["example"] = pcommon.NewValueInt(8) cases := []struct { Desc string @@ -80,24 +81,22 @@ func TestNumericTagFilter(t *testing.T) { t.Run(c.Desc, func(t *testing.T) { u, err := uuid.NewRandom() require.NoError(t, err) - decision := filter.Evaluate(pdata.NewTraceID(u), c.Trace) + decision := filter.Evaluate(pcommon.NewTraceID(u), c.Trace) assert.Equal(t, decision, c.Decision) }) } } -func newTraceIntAttrs(nodeAttrs map[string]pdata.AttributeValue, spanAttrKey string, spanAttrValue int64) *TraceData { - var traceBatches []pdata.Traces - traces := pdata.NewTraces() +func newTraceIntAttrs(nodeAttrs map[string]interface{}, spanAttrKey string, spanAttrValue int64) *TraceData { + var traceBatches []ptrace.Traces + traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() - pdata.NewAttributeMapFromMap(nodeAttrs).CopyTo(rs.Resource().Attributes()) + pcommon.NewMapFromRaw(nodeAttrs).CopyTo(rs.Resource().Attributes()) ils := rs.InstrumentationLibrarySpans().AppendEmpty() span := ils.Spans().AppendEmpty() - span.SetTraceID(pdata.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})) - span.SetSpanID(pdata.NewSpanID([8]byte{1, 2, 3, 4, 5, 6, 7, 8})) - attributes := make(map[string]pdata.AttributeValue) - attributes[spanAttrKey] = pdata.NewAttributeValueInt(spanAttrValue) - pdata.NewAttributeMapFromMap(attributes).CopyTo(span.Attributes()) + span.SetTraceID(pcommon.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})) + span.SetSpanID(pcommon.NewSpanID([8]byte{1, 2, 3, 4, 5, 6, 7, 8})) + span.Attributes().InsertInt(spanAttrKey, spanAttrValue) traceBatches = append(traceBatches, traces) return &TraceData{ ReceivedBatches: traceBatches, diff --git a/pkg/processor/cascadingfilterprocessor/sampling/policy.go b/pkg/processor/cascadingfilterprocessor/sampling/policy.go index 8f6d23122f..c860ecb5a9 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/policy.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/policy.go @@ -18,7 +18,8 @@ import ( "sync" "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" ) // TraceData stores the sampling related trace data. @@ -37,7 +38,7 @@ type TraceData struct { // SpanCount track the number of spans on the trace. SpanCount int32 // ReceivedBatches stores all the batches received for the trace. - ReceivedBatches []pdata.Traces + ReceivedBatches []ptrace.Traces } // Decision gives the status of sampling decision. @@ -66,12 +67,12 @@ const ( // which makes a sampling decision for a given trace when requested. type PolicyEvaluator interface { // Evaluate looks at the trace data and returns a corresponding SamplingDecision. - Evaluate(traceID pdata.TraceID, trace *TraceData) Decision + Evaluate(traceID pcommon.TraceID, trace *TraceData) Decision } // DropTraceEvaluator implements a cascading policy evaluator, // which checks if trace should be dropped completely before making any other operations type DropTraceEvaluator interface { // ShouldDrop checks if trace should be dropped - ShouldDrop(traceID pdata.TraceID, trace *TraceData) bool + ShouldDrop(traceID pcommon.TraceID, trace *TraceData) bool } diff --git a/pkg/processor/cascadingfilterprocessor/sampling/policy_filter.go b/pkg/processor/cascadingfilterprocessor/sampling/policy_filter.go index 69fb71d45f..b7dbe3c5fb 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/policy_filter.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/policy_filter.go @@ -17,14 +17,15 @@ package sampling import ( "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" ) -func tsToMicros(ts pdata.Timestamp) int64 { +func tsToMicros(ts pcommon.Timestamp) int64 { return int64(ts / 1000) } -func checkIfAttrsMatched(resAttrs pdata.AttributeMap, spanAttrs pdata.AttributeMap, filters []attributeFilter) bool { +func checkIfAttrsMatched(resAttrs pcommon.Map, spanAttrs pcommon.Map, filters []attributeFilter) bool { for _, filter := range filters { var resAttrMatched bool spanAttrMatched, spanAttrFound := checkAttributeFilterMatchedAndFound(spanAttrs, filter) @@ -39,7 +40,7 @@ func checkIfAttrsMatched(resAttrs pdata.AttributeMap, spanAttrs pdata.AttributeM return true } -func checkAttributeFilterMatchedAndFound(attrs pdata.AttributeMap, filter attributeFilter) (bool, bool) { +func checkAttributeFilterMatchedAndFound(attrs pcommon.Map, filter attributeFilter) (bool, bool) { if v, ok := attrs.Get(filter.key); ok { // String patterns vs values is exclusive if len(filter.patterns) > 0 { @@ -61,14 +62,14 @@ func checkAttributeFilterMatchedAndFound(attrs pdata.AttributeMap, filter attrib } if len(filter.ranges) > 0 { - if v.Type() == pdata.AttributeValueTypeDouble { + if v.Type() == pcommon.ValueTypeDouble { value := v.DoubleVal() for _, r := range filter.ranges { if value >= float64(r.minValue) && value <= float64(r.maxValue) { return true, true } } - } else if v.Type() == pdata.AttributeValueTypeInt { + } else if v.Type() == pcommon.ValueTypeInt { value := v.IntVal() for _, r := range filter.ranges { if value >= r.minValue && value <= r.maxValue { @@ -90,7 +91,7 @@ func checkAttributeFilterMatchedAndFound(attrs pdata.AttributeMap, filter attrib return false, false } -func checkIfNumericAttrFound(attrs pdata.AttributeMap, filter *numericAttributeFilter) bool { +func checkIfNumericAttrFound(attrs pcommon.Map, filter *numericAttributeFilter) bool { if v, ok := attrs.Get(filter.key); ok { value := v.IntVal() if value >= filter.minValue && value <= filter.maxValue { @@ -100,7 +101,7 @@ func checkIfNumericAttrFound(attrs pdata.AttributeMap, filter *numericAttributeF return false } -func checkIfStringAttrFound(attrs pdata.AttributeMap, filter *stringAttributeFilter) bool { +func checkIfStringAttrFound(attrs pcommon.Map, filter *stringAttributeFilter) bool { if v, ok := attrs.Get(filter.key); ok { truncableStr := v.StringVal() if filter.patterns != nil { @@ -123,7 +124,7 @@ func checkIfStringAttrFound(attrs pdata.AttributeMap, filter *stringAttributeFil } // evaluateRules goes through the defined properties and checks if they are matched -func (pe *policyEvaluator) evaluateRules(_ pdata.TraceID, trace *TraceData) Decision { +func (pe *policyEvaluator) evaluateRules(_ pcommon.TraceID, trace *TraceData) Decision { trace.Lock() batches := trace.ReceivedBatches trace.Unlock() @@ -194,7 +195,7 @@ func (pe *policyEvaluator) evaluateRules(_ pdata.TraceID, trace *TraceData) Deci } } - if span.Status().Code() == pdata.StatusCodeError { + if span.Status().Code() == ptrace.StatusCodeError { errorCount++ } } @@ -292,7 +293,7 @@ func (pe *policyEvaluator) updateRate(currSecond int64, numSpans int32) Decision // Evaluate looks at the trace data and returns a corresponding SamplingDecision. Also takes into account // the usage of sampling rate budget -func (pe *policyEvaluator) Evaluate(traceID pdata.TraceID, trace *TraceData) Decision { +func (pe *policyEvaluator) Evaluate(traceID pcommon.TraceID, trace *TraceData) Decision { currSecond := time.Now().Unix() if !pe.shouldConsider(currSecond, trace) { diff --git a/pkg/processor/cascadingfilterprocessor/sampling/rate_limiting_test.go b/pkg/processor/cascadingfilterprocessor/sampling/rate_limiting_test.go index e9524190c1..a7ce19bb98 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/rate_limiting_test.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/rate_limiting_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" "go.uber.org/zap" ) @@ -30,10 +30,10 @@ func newRateLimiterFilter(maxRate int32) *policyEvaluator { } func TestRateLimiter(t *testing.T) { - var empty = map[string]pdata.AttributeValue{} + var empty = map[string]interface{}{} trace := newTraceStringAttrs(empty, "example", "value") - traceID := pdata.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}) + traceID := pcommon.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}) rateLimiter := newRateLimiterFilter(3) // Trace span count greater than spans per second diff --git a/pkg/processor/cascadingfilterprocessor/sampling/span_properties_filter_test.go b/pkg/processor/cascadingfilterprocessor/sampling/span_properties_filter_test.go index e2ce44f908..428f401066 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/span_properties_filter_test.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/span_properties_filter_test.go @@ -23,7 +23,8 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" ) @@ -54,7 +55,7 @@ func newSpanPropertiesFilter(t *testing.T, operationNamePattern *string, minDura func evaluate(t *testing.T, evaluator policyEvaluator, traces *TraceData, expectedDecision Decision) { u, err := uuid.NewRandom() require.NoError(t, err) - decision := evaluator.Evaluate(pdata.NewTraceID(u), traces) + decision := evaluator.Evaluate(pcommon.NewTraceID(u), traces) assert.Equal(t, expectedDecision, decision) } @@ -156,9 +157,9 @@ func newTraceAttrs(operationName string, duration time.Duration, numberOfSpans i endTs := time.Now().UnixNano() startTs := endTs - duration.Nanoseconds() - var traceBatches []pdata.Traces + var traceBatches []ptrace.Traces - traces := pdata.NewTraces() + traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() ils := rs.InstrumentationLibrarySpans().AppendEmpty() @@ -168,13 +169,13 @@ func newTraceAttrs(operationName string, duration time.Duration, numberOfSpans i for i := 0; i < numberOfSpans; i++ { span := spans.AppendEmpty() span.SetName(operationName) - span.SetStartTimestamp(pdata.Timestamp(startTs)) - span.SetEndTimestamp(pdata.Timestamp(endTs)) + span.SetStartTimestamp(pcommon.Timestamp(startTs)) + span.SetEndTimestamp(pcommon.Timestamp(endTs)) } for i := 0; i < numberOfErrors && i < numberOfSpans; i++ { span := spans.At(i) - span.Status().SetCode(pdata.StatusCodeError) + span.Status().SetCode(ptrace.StatusCodeError) } traceBatches = append(traceBatches, traces) diff --git a/pkg/processor/cascadingfilterprocessor/sampling/string_tag_filter_test.go b/pkg/processor/cascadingfilterprocessor/sampling/string_tag_filter_test.go index 406cf76cc1..3e354baf22 100644 --- a/pkg/processor/cascadingfilterprocessor/sampling/string_tag_filter_test.go +++ b/pkg/processor/cascadingfilterprocessor/sampling/string_tag_filter_test.go @@ -20,7 +20,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" ) @@ -48,7 +49,7 @@ func newStringAttributeRegexFilter() *policyEvaluator { } func TestStringTagFilter(t *testing.T) { - var empty = map[string]pdata.AttributeValue{} + var empty = map[string]interface{}{} filter := newStringAttributeFilter() regexFilter := newStringAttributeRegexFilter() @@ -59,17 +60,17 @@ func TestStringTagFilter(t *testing.T) { }{ { Desc: "nonmatching node attribute key", - Trace: newTraceStringAttrs(map[string]pdata.AttributeValue{"non_matching": pdata.NewAttributeValueString("value")}, "", ""), + Trace: newTraceStringAttrs(map[string]interface{}{"non_matching": "value"}, "", ""), Decision: NotSampled, }, { Desc: "nonmatching node attribute value", - Trace: newTraceStringAttrs(map[string]pdata.AttributeValue{"example": pdata.NewAttributeValueString("non_matching")}, "", ""), + Trace: newTraceStringAttrs(map[string]interface{}{"example": "non_matching"}, "", ""), Decision: NotSampled, }, { Desc: "matching node attribute", - Trace: newTraceStringAttrs(map[string]pdata.AttributeValue{"example": pdata.NewAttributeValueString("value")}, "", ""), + Trace: newTraceStringAttrs(map[string]interface{}{"example": "value"}, "", ""), Decision: Sampled, }, { @@ -91,26 +92,24 @@ func TestStringTagFilter(t *testing.T) { for _, c := range cases { t.Run(c.Desc, func(t *testing.T) { - decisionPlain := filter.Evaluate(pdata.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), c.Trace) - decisionRegex := regexFilter.Evaluate(pdata.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), c.Trace) + decisionPlain := filter.Evaluate(pcommon.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), c.Trace) + decisionRegex := regexFilter.Evaluate(pcommon.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), c.Trace) assert.Equal(t, decisionPlain, c.Decision) assert.Equal(t, decisionRegex, c.Decision) }) } } -func newTraceStringAttrs(nodeAttrs map[string]pdata.AttributeValue, spanAttrKey string, spanAttrValue string) *TraceData { - var traceBatches []pdata.Traces - traces := pdata.NewTraces() +func newTraceStringAttrs(nodeAttrs map[string]interface{}, spanAttrKey string, spanAttrValue string) *TraceData { + var traceBatches []ptrace.Traces + traces := ptrace.NewTraces() rs := traces.ResourceSpans().AppendEmpty() - pdata.NewAttributeMapFromMap(nodeAttrs).CopyTo(rs.Resource().Attributes()) + pcommon.NewMapFromRaw(nodeAttrs).CopyTo(rs.Resource().Attributes()) ils := rs.InstrumentationLibrarySpans().AppendEmpty() span := ils.Spans().AppendEmpty() - span.SetTraceID(pdata.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})) - span.SetSpanID(pdata.NewSpanID([8]byte{1, 2, 3, 4, 5, 6, 7, 8})) - attributes := make(map[string]pdata.AttributeValue) - attributes[spanAttrKey] = pdata.NewAttributeValueString(spanAttrValue) - pdata.NewAttributeMapFromMap(attributes).CopyTo(span.Attributes()) + span.SetTraceID(pcommon.NewTraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})) + span.SetSpanID(pcommon.NewSpanID([8]byte{1, 2, 3, 4, 5, 6, 7, 8})) + span.Attributes().InsertString(spanAttrKey, spanAttrValue) traceBatches = append(traceBatches, traces) return &TraceData{ ReceivedBatches: traceBatches, diff --git a/pkg/processor/k8sprocessor/go.mod b/pkg/processor/k8sprocessor/go.mod index b3cc6a1372..3e374e902e 100644 --- a/pkg/processor/k8sprocessor/go.mod +++ b/pkg/processor/k8sprocessor/go.mod @@ -5,17 +5,19 @@ go 1.18 require ( github.com/onsi/ginkgo v1.14.1 // indirect github.com/onsi/gomega v1.10.2 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.48.0 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.49.0 github.com/stretchr/testify v1.7.1 go.opencensus.io v0.23.0 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/model v0.49.0 go.uber.org/zap v1.21.0 k8s.io/api v0.23.5 k8s.io/apimachinery v0.23.5 k8s.io/client-go v0.23.5 ) +require go.opentelemetry.io/collector/pdata v0.49.0 + require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect @@ -28,7 +30,7 @@ require ( github.com/googleapis/gnostic v0.5.5 // indirect github.com/imdario/mergo v0.3.11 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect @@ -38,17 +40,16 @@ require ( github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/cast v1.4.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect + golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect - golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect + golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/pkg/processor/k8sprocessor/go.sum b/pkg/processor/k8sprocessor/go.sum index 0769e6f8f2..039a8c83c9 100644 --- a/pkg/processor/k8sprocessor/go.sum +++ b/pkg/processor/k8sprocessor/go.sum @@ -67,7 +67,7 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -207,7 +207,6 @@ github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3i github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -252,8 +251,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -311,8 +310,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.48.0 h1:ByibognNIqwVvQzI6GZQyyGn2qeMtAXzvXuioQIwpr0= -github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.48.0/go.mod h1:E98HuQLoi7cprqxceKlGIqyuvH17Poh1ORN6P4NS9Sw= +github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.49.0 h1:6zRMrRAAifeYq+R9ICqLcvr/fR8DRhdXWRFSP3grZ30= +github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.49.0/go.mod h1:X8hULwDe+d1zXKYWG1hEbcl6Kn7MWKLyAPdPXJvw3rc= github.com/openshift/api v0.0.0-20210521075222-e273a339932a h1:aBPwLqCg66SbQd+HrjB1GhgTfPtqSY4aeB022tEYmE0= github.com/openshift/api v0.0.0-20210521075222-e273a339932a/go.mod h1:izBmoXbUu3z5kUa4FjZhvekTsyzIWiOoaIgJiZBBMQs= github.com/openshift/build-machinery-go v0.0.0-20210423112049-9415d7ebd33e/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= @@ -336,8 +335,6 @@ github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -365,20 +362,20 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/model v0.49.0 h1:mbUSNgpaBE3GWmzGsRb5t0xILpXIVYv7scPTTfoMt6c= +go.opentelemetry.io/collector/model v0.49.0/go.mod h1:nOYQv9KoFPs6ihJwOi24qB209EOhS9HkwhGj54YiEAw= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 h1:li8u9OSMvLau7rMs8bmiL82OazG6MAkwPz2i6eS8TBQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -472,8 +469,9 @@ golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -549,13 +547,14 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/pkg/processor/k8sprocessor/pod_association.go b/pkg/processor/k8sprocessor/pod_association.go index 94a80470bd..fc24e29560 100644 --- a/pkg/processor/k8sprocessor/pod_association.go +++ b/pkg/processor/k8sprocessor/pod_association.go @@ -21,8 +21,8 @@ import ( "strings" "go.opentelemetry.io/collector/client" - "go.opentelemetry.io/collector/model/pdata" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" + "go.opentelemetry.io/collector/pdata/pcommon" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sprocessor/kube" ) @@ -30,7 +30,7 @@ import ( // extractPodIds extracts IP and pod UID from attributes or request context. // It returns a value pair containing configured label and IP Address and/or Pod UID. // If empty value in return it means that attributes does not contains configured label to match resources for Pod. -func extractPodID(ctx context.Context, attrs pdata.AttributeMap, associations []kube.Association) (podIdentifierKey string, podIdentifierValue kube.PodIdentifier) { +func extractPodID(ctx context.Context, attrs pcommon.Map, associations []kube.Association) (podIdentifierKey string, podIdentifierValue kube.PodIdentifier) { connectionIP := getConnectionIP(ctx) hostname := stringAttributeFromMap(attrs, conventions.AttributeHostName) @@ -132,9 +132,9 @@ func getConnectionIP(ctx context.Context) kube.PodIdentifier { return kube.PodIdentifier(c.Addr.String()) } -func stringAttributeFromMap(attrs pdata.AttributeMap, key string) string { +func stringAttributeFromMap(attrs pcommon.Map, key string) string { if val, ok := attrs.Get(key); ok { - if val.Type() == pdata.AttributeValueTypeString { + if val.Type() == pcommon.ValueTypeString { return val.StringVal() } } diff --git a/pkg/processor/k8sprocessor/processor.go b/pkg/processor/k8sprocessor/processor.go index a7b7f18047..61e0d76629 100644 --- a/pkg/processor/k8sprocessor/processor.go +++ b/pkg/processor/k8sprocessor/processor.go @@ -19,7 +19,10 @@ import ( "time" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" @@ -85,7 +88,7 @@ func (kp *kubernetesprocessor) Shutdown(context.Context) error { } // ProcessTraces process traces and add k8s metadata using resource IP or incoming IP as pod origin. -func (kp *kubernetesprocessor) ProcessTraces(ctx context.Context, td pdata.Traces) (pdata.Traces, error) { +func (kp *kubernetesprocessor) ProcessTraces(ctx context.Context, td ptrace.Traces) (ptrace.Traces, error) { rss := td.ResourceSpans() for i := 0; i < rss.Len(); i++ { kp.processResource(ctx, rss.At(i).Resource()) @@ -95,7 +98,7 @@ func (kp *kubernetesprocessor) ProcessTraces(ctx context.Context, td pdata.Trace } // ProcessMetrics process metrics and add k8s metadata using resource IP, hostname or incoming IP as pod origin. -func (kp *kubernetesprocessor) ProcessMetrics(ctx context.Context, md pdata.Metrics) (pdata.Metrics, error) { +func (kp *kubernetesprocessor) ProcessMetrics(ctx context.Context, md pmetric.Metrics) (pmetric.Metrics, error) { rm := md.ResourceMetrics() for i := 0; i < rm.Len(); i++ { kp.processResource(ctx, rm.At(i).Resource()) @@ -105,7 +108,7 @@ func (kp *kubernetesprocessor) ProcessMetrics(ctx context.Context, md pdata.Metr } // ProcessLogs process logs and add k8s metadata using resource IP, hostname or incoming IP as pod origin. -func (kp *kubernetesprocessor) ProcessLogs(ctx context.Context, ld pdata.Logs) (pdata.Logs, error) { +func (kp *kubernetesprocessor) ProcessLogs(ctx context.Context, ld plog.Logs) (plog.Logs, error) { rl := ld.ResourceLogs() for i := 0; i < rl.Len(); i++ { kp.processResource(ctx, rl.At(i).Resource()) @@ -115,7 +118,7 @@ func (kp *kubernetesprocessor) ProcessLogs(ctx context.Context, ld pdata.Logs) ( } // processResource adds Pod metadata tags to resource based on pod association configuration -func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pdata.Resource) { +func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pcommon.Resource) { podIdentifierKey, podIdentifierValue := extractPodID(ctx, resource.Attributes(), kp.podAssociations) if podIdentifierValue == "" { return diff --git a/pkg/processor/k8sprocessor/processor_test.go b/pkg/processor/k8sprocessor/processor_test.go index 1e1024b2cf..27fd0697ec 100644 --- a/pkg/processor/k8sprocessor/processor_test.go +++ b/pkg/processor/k8sprocessor/processor_test.go @@ -29,8 +29,11 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" @@ -155,9 +158,9 @@ func newMultiTest( func (m *multiTest) testConsume( ctx context.Context, - traces pdata.Traces, - metrics pdata.Metrics, - logs pdata.Logs, + traces ptrace.Traces, + metrics pmetric.Metrics, + logs plog.Logs, errFunc func(err error), ) { errs := []error{ @@ -197,7 +200,7 @@ func (m *multiTest) assertResourceAttributesLen(batchNo int, attrsLen int) { assert.Equal(m.t, m.nextLogs.AllLogs()[batchNo].ResourceLogs().At(0).Resource().Attributes().Len(), attrsLen) } -func (m *multiTest) assertResource(batchNum int, resourceFunc func(res pdata.Resource)) { +func (m *multiTest) assertResource(batchNum int, resourceFunc func(res pcommon.Resource)) { rss := m.nextTrace.AllTraces()[batchNum].ResourceSpans() r := rss.At(0).Resource() @@ -247,10 +250,10 @@ func TestProcessorBadClientProvider(t *testing.T) { }, withKubeClientProvider(clientProvider)) } -type generateResourceFunc func(res pdata.Resource) +type generateResourceFunc func(res pcommon.Resource) -func generateTraces(resourceFunc ...generateResourceFunc) pdata.Traces { - t := pdata.NewTraces() +func generateTraces(resourceFunc ...generateResourceFunc) ptrace.Traces { + t := ptrace.NewTraces() rs := t.ResourceSpans().AppendEmpty() for _, resFun := range resourceFunc { res := rs.Resource() @@ -261,8 +264,8 @@ func generateTraces(resourceFunc ...generateResourceFunc) pdata.Traces { return t } -func generateMetrics(resourceFunc ...generateResourceFunc) pdata.Metrics { - m := pdata.NewMetrics() +func generateMetrics(resourceFunc ...generateResourceFunc) pmetric.Metrics { + m := pmetric.NewMetrics() ms := m.ResourceMetrics().AppendEmpty() for _, resFun := range resourceFunc { res := ms.Resource() @@ -273,8 +276,8 @@ func generateMetrics(resourceFunc ...generateResourceFunc) pdata.Metrics { return m } -func generateLogs(resourceFunc ...generateResourceFunc) pdata.Logs { - l := pdata.NewLogs() +func generateLogs(resourceFunc ...generateResourceFunc) plog.Logs { + l := plog.NewLogs() ls := l.ResourceLogs().AppendEmpty() for _, resFun := range resourceFunc { res := ls.Resource() @@ -286,25 +289,25 @@ func generateLogs(resourceFunc ...generateResourceFunc) pdata.Logs { } func withPassthroughIP(passthroughIP string) generateResourceFunc { - return func(res pdata.Resource) { + return func(res pcommon.Resource) { res.Attributes().InsertString(k8sIPLabelName, passthroughIP) } } func withHostname(hostname string) generateResourceFunc { - return func(res pdata.Resource) { + return func(res pcommon.Resource) { res.Attributes().InsertString(conventions.AttributeHostName, hostname) } } func withPodUID(uid string) generateResourceFunc { - return func(res pdata.Resource) { + return func(res pcommon.Resource) { res.Attributes().InsertString("k8s.pod.uid", uid) } } func withPodAndNamespace(pod string, namespace string) generateResourceFunc { - return func(res pdata.Resource) { + return func(res pcommon.Resource) { res.Attributes().InsertString("k8s.pod.name", pod) res.Attributes().InsertString("k8s.namespace.name", namespace) } @@ -350,7 +353,7 @@ func TestIPDetectionFromContext(t *testing.T) { m.assertBatchesLen(1) m.assertResourceObjectLen(0) - m.assertResource(0, func(r pdata.Resource) { + m.assertResource(0, func(r pcommon.Resource) { require.Greater(t, r.Attributes().Len(), 0) assertResourceHasStringAttribute(t, r, "k8s.pod.ip", "1.1.1.1") }) @@ -361,8 +364,8 @@ func TestNilBatch(t *testing.T) { m := newMultiTest(t, NewFactory().CreateDefaultConfig(), nil) m.testConsume( context.Background(), - pdata.NewTraces(), - pdata.NewMetrics(), + ptrace.NewTraces(), + pmetric.NewMetrics(), generateLogs(), func(err error) { assert.NoError(t, err) @@ -458,7 +461,7 @@ func TestNoIP(t *testing.T) { m.assertBatchesLen(1) m.assertResourceObjectLen(0) - m.assertResource(0, func(res pdata.Resource) { + m.assertResource(0, func(res pcommon.Resource) { assert.Equal(t, 0, res.Attributes().Len()) }) } @@ -511,7 +514,7 @@ func TestIPSourceWithoutPodAssociation(t *testing.T) { metrics := generateMetrics() logs := generateLogs() - resources := []pdata.Resource{ + resources := []pcommon.Resource{ traces.ResourceSpans().At(0).Resource(), metrics.ResourceMetrics().At(0).Resource(), } @@ -527,7 +530,7 @@ func TestIPSourceWithoutPodAssociation(t *testing.T) { m.testConsume(ctx, traces, metrics, logs, nil) m.assertBatchesLen(i + 1) - m.assertResource(i, func(res pdata.Resource) { + m.assertResource(i, func(res pcommon.Resource) { require.Greater(t, res.Attributes().Len(), 0) assertResourceHasStringAttribute(t, res, "k8s.pod.ip", tc.out) }) @@ -605,7 +608,7 @@ func TestIPSourceWithPodAssociation(t *testing.T) { metrics := generateMetrics() logs := generateLogs() - resources := []pdata.Resource{ + resources := []pcommon.Resource{ traces.ResourceSpans().At(0).Resource(), metrics.ResourceMetrics().At(0).Resource(), logs.ResourceLogs().At(0).Resource(), @@ -617,7 +620,7 @@ func TestIPSourceWithPodAssociation(t *testing.T) { m.testConsume(ctx, traces, metrics, logs, nil) m.assertBatchesLen(i + 1) - m.assertResource(i, func(res pdata.Resource) { + m.assertResource(i, func(res pcommon.Resource) { require.Greater(t, res.Attributes().Len(), 0) assertResourceHasStringAttribute(t, res, tc.outLabel, tc.outValue) }) @@ -656,7 +659,7 @@ func TestPodUID(t *testing.T) { m.assertBatchesLen(1) m.assertResourceObjectLen(0) - m.assertResource(0, func(r pdata.Resource) { + m.assertResource(0, func(r pcommon.Resource) { require.Greater(t, r.Attributes().Len(), 0) assertResourceHasStringAttribute(t, r, "k8s.pod.uid", "ef10d10b-2da5-4030-812e-5f45c1531227") }) @@ -714,7 +717,7 @@ func TestProcessorAddLabels(t *testing.T) { m.assertBatchesLen(i + 1) m.assertResourceObjectLen(i) - m.assertResource(i, func(res pdata.Resource) { + m.assertResource(i, func(res pcommon.Resource) { require.Greater(t, res.Attributes().Len(), 0) assertResourceHasStringAttribute(t, res, "k8s.pod.ip", ip) for k, v := range attrs { @@ -762,7 +765,7 @@ func TestProcessorPicksUpPassthoughPodIp(t *testing.T) { m.assertResourceObjectLen(0) m.assertResourceAttributesLen(0, 3) - m.assertResource(0, func(res pdata.Resource) { + m.assertResource(0, func(res pcommon.Resource) { assertResourceHasStringAttribute(t, res, k8sIPLabelName, "2.2.2.2") assertResourceHasStringAttribute(t, res, "k", "v") assertResourceHasStringAttribute(t, res, "1", "2") @@ -805,7 +808,7 @@ func TestProcessorByPodNameAndNamespace(t *testing.T) { m.assertResourceObjectLen(0) m.assertResourceAttributesLen(0, 5) - m.assertResource(0, func(res pdata.Resource) { + m.assertResource(0, func(res pcommon.Resource) { assertResourceHasStringAttribute(t, res, "_hostname", "PodA.test") assertResourceHasStringAttribute(t, res, "k", "v") assertResourceHasStringAttribute(t, res, "1", "2") @@ -1017,10 +1020,10 @@ func TestStartStop(t *testing.T) { assert.True(t, controller.HasStopped()) } -func assertResourceHasStringAttribute(t *testing.T, r pdata.Resource, k, v string) { +func assertResourceHasStringAttribute(t *testing.T, r pcommon.Resource, k, v string) { got, ok := r.Attributes().Get(k) assert.True(t, ok, fmt.Sprintf("resource does not contain attribute %s", k)) - assert.EqualValues(t, pdata.AttributeValueTypeString, got.Type(), "attribute %s is not of type string", k) + assert.EqualValues(t, pcommon.ValueTypeString, got.Type(), "attribute %s is not of type string", k) assert.EqualValues(t, v, got.StringVal(), "attribute %s is not equal to %s", k, v) } diff --git a/pkg/processor/metricfrequencyprocessor/go.mod b/pkg/processor/metricfrequencyprocessor/go.mod index 82eb003316..e1a9254040 100644 --- a/pkg/processor/metricfrequencyprocessor/go.mod +++ b/pkg/processor/metricfrequencyprocessor/go.mod @@ -5,23 +5,22 @@ go 1.18 require ( github.com/patrickmn/go-cache v2.1.0+incompatible github.com/stretchr/testify v1.7.1 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/pdata v0.49.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/cast v1.4.1 // indirect go.opencensus.io v0.23.0 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect diff --git a/pkg/processor/metricfrequencyprocessor/go.sum b/pkg/processor/metricfrequencyprocessor/go.sum index 74a5dd84b5..6eaebfdf4a 100644 --- a/pkg/processor/metricfrequencyprocessor/go.sum +++ b/pkg/processor/metricfrequencyprocessor/go.sum @@ -15,7 +15,7 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -68,7 +68,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -98,8 +97,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -141,8 +140,6 @@ github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8d github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -157,20 +154,18 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 h1:li8u9OSMvLau7rMs8bmiL82OazG6MAkwPz2i6eS8TBQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -202,7 +197,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -224,7 +219,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pkg/processor/metricfrequencyprocessor/metriccache.go b/pkg/processor/metricfrequencyprocessor/metriccache.go index a9a81d6619..6a34c909c0 100644 --- a/pkg/processor/metricfrequencyprocessor/metriccache.go +++ b/pkg/processor/metricfrequencyprocessor/metriccache.go @@ -5,11 +5,12 @@ import ( "time" "github.com/patrickmn/go-cache" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) type DataPoint struct { - Timestamp pdata.Timestamp + Timestamp pcommon.Timestamp Value float64 } @@ -38,7 +39,7 @@ func newMetricCache(config cacheConfig) *metricCache { return c } -func (mc *metricCache) Register(name string, dataPoint pdata.NumberDataPoint) { +func (mc *metricCache) Register(name string, dataPoint pmetric.NumberDataPoint) { internalCache, exists := mc.internalCaches[name] if !exists { @@ -52,8 +53,8 @@ func (mc *metricCache) Register(name string, dataPoint pdata.NumberDataPoint) { internalCache.Set(key, value, cache.DefaultExpiration) } -func (mc *metricCache) List(metricName string) map[pdata.Timestamp]float64 { - out := make(map[pdata.Timestamp]float64) +func (mc *metricCache) List(metricName string) map[pcommon.Timestamp]float64 { + out := make(map[pcommon.Timestamp]float64) internalCache, found := mc.internalCaches[metricName] if found { for _, item := range internalCache.Items() { diff --git a/pkg/processor/metricfrequencyprocessor/metriccache_test.go b/pkg/processor/metricfrequencyprocessor/metriccache_test.go index 64b3994185..8546ec537e 100644 --- a/pkg/processor/metricfrequencyprocessor/metriccache_test.go +++ b/pkg/processor/metricfrequencyprocessor/metriccache_test.go @@ -5,7 +5,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestEmptyRead(t *testing.T) { @@ -22,7 +23,7 @@ func TestSingleRegister(t *testing.T) { result := cache.List("a") - assert.Equal(t, map[pdata.Timestamp]float64{timestamp1: 0.0}, result) + assert.Equal(t, map[pcommon.Timestamp]float64{timestamp1: 0.0}, result) } func TestTwoRegistersOfSingleMetric(t *testing.T) { @@ -32,7 +33,7 @@ func TestTwoRegistersOfSingleMetric(t *testing.T) { result := cache.List("a") - assert.Equal(t, map[pdata.Timestamp]float64{timestamp1: 0.0, timestamp2: 1.0}, result) + assert.Equal(t, map[pcommon.Timestamp]float64{timestamp1: 0.0, timestamp2: 1.0}, result) } func TestTwoRegistersOnTwoMetrics(t *testing.T) { @@ -43,20 +44,20 @@ func TestTwoRegistersOnTwoMetrics(t *testing.T) { result1 := cache.List("a") result2 := cache.List("b") - assert.Equal(t, map[pdata.Timestamp]float64{timestamp1: 0.0}, result1) - assert.Equal(t, map[pdata.Timestamp]float64{timestamp2: 1.0}, result2) + assert.Equal(t, map[pcommon.Timestamp]float64{timestamp1: 0.0}, result1) + assert.Equal(t, map[pcommon.Timestamp]float64{timestamp2: 1.0}, result2) } -var emptyResult = make(map[pdata.Timestamp]float64) -var timestamp1 = pdata.NewTimestampFromTime(time.Unix(0, 0)) -var timestamp2 = pdata.NewTimestampFromTime(time.Unix(1, 0)) +var emptyResult = make(map[pcommon.Timestamp]float64) +var timestamp1 = pcommon.NewTimestampFromTime(time.Unix(0, 0)) +var timestamp2 = pcommon.NewTimestampFromTime(time.Unix(1, 0)) func newCache() *metricCache { return newMetricCache(createDefaultConfig().(*Config).cacheConfig) } -func newDataPoint(timestamp pdata.Timestamp, value float64) pdata.NumberDataPoint { - result := pdata.NewNumberDataPoint() +func newDataPoint(timestamp pcommon.Timestamp, value float64) pmetric.NumberDataPoint { + result := pmetric.NewNumberDataPoint() result.SetTimestamp(timestamp) result.SetDoubleVal(value) return result diff --git a/pkg/processor/metricfrequencyprocessor/pdata.go b/pkg/processor/metricfrequencyprocessor/pdata.go index 4ebc0011ad..9b060e2613 100644 --- a/pkg/processor/metricfrequencyprocessor/pdata.go +++ b/pkg/processor/metricfrequencyprocessor/pdata.go @@ -4,10 +4,11 @@ import ( "math" "sort" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) -type pdataTimestampByValue []pdata.Timestamp +type pdataTimestampByValue []pcommon.Timestamp func (pta pdataTimestampByValue) Len() int { return len(pta) @@ -21,15 +22,15 @@ func (pta pdataTimestampByValue) Swap(i, j int) { pta[i], pta[j] = pta[j], pta[i] } -func sortTimestampArray(timestamps []pdata.Timestamp) { +func sortTimestampArray(timestamps []pcommon.Timestamp) { sort.Sort(pdataTimestampByValue(timestamps)) } -func getVal(point pdata.NumberDataPoint) float64 { +func getVal(point pmetric.NumberDataPoint) float64 { switch point.ValueType() { - case pdata.MetricValueTypeDouble: + case pmetric.MetricValueTypeDouble: return point.DoubleVal() - case pdata.MetricValueTypeInt: + case pmetric.MetricValueTypeInt: return float64(point.IntVal()) default: return math.NaN() diff --git a/pkg/processor/metricfrequencyprocessor/processor.go b/pkg/processor/metricfrequencyprocessor/processor.go index a5ec824498..06b99c43c1 100644 --- a/pkg/processor/metricfrequencyprocessor/processor.go +++ b/pkg/processor/metricfrequencyprocessor/processor.go @@ -3,7 +3,7 @@ package metricfrequencyprocessor import ( "context" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/processor/processorhelper" ) @@ -14,7 +14,7 @@ type metricsfrequencyprocessor struct { var _ processorhelper.ProcessMetricsFunc = (*metricsfrequencyprocessor)(nil).ProcessMetrics // ProcessMetrics applies metricSieve to incoming metrics. It mutates the argument. -func (mfp *metricsfrequencyprocessor) ProcessMetrics(_ context.Context, md pdata.Metrics) (pdata.Metrics, error) { +func (mfp *metricsfrequencyprocessor) ProcessMetrics(_ context.Context, md pmetric.Metrics) (pmetric.Metrics, error) { rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { rm := rms.At(i) @@ -31,10 +31,10 @@ func (mfp *metricsfrequencyprocessor) ProcessMetrics(_ context.Context, md pdata return md, nil } -func metricSliceEmpty(metrics pdata.InstrumentationLibraryMetrics) bool { +func metricSliceEmpty(metrics pmetric.ScopeMetrics) bool { return metrics.Metrics().Len() == 0 } -func ilmSliceEmpty(metrics pdata.ResourceMetrics) bool { +func ilmSliceEmpty(metrics pmetric.ResourceMetrics) bool { return metrics.InstrumentationLibraryMetrics().Len() == 0 } diff --git a/pkg/processor/metricfrequencyprocessor/processor_test.go b/pkg/processor/metricfrequencyprocessor/processor_test.go index 627e3742d9..a2fb6ed9fa 100644 --- a/pkg/processor/metricfrequencyprocessor/processor_test.go +++ b/pkg/processor/metricfrequencyprocessor/processor_test.go @@ -7,7 +7,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestSieveAllFromEmpty(t *testing.T) { @@ -133,35 +134,35 @@ func TestSelectionWithTwoLibraries(t *testing.T) { assert.Equal(t, "m2", result.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) } -func createGauge() pdata.Gauge { - dpSlice := pdata.NewNumberDataPointSlice() - pdata.NewNumberDataPoint().CopyTo(dpSlice.AppendEmpty()) +func createGauge() pmetric.Gauge { + dpSlice := pmetric.NewNumberDataPointSlice() + pmetric.NewNumberDataPoint().CopyTo(dpSlice.AppendEmpty()) - gauge := pdata.NewGauge() + gauge := pmetric.NewGauge() dpSlice.CopyTo(gauge.DataPoints()) return gauge } -func createMetric(name string) pdata.Metric { - metric := pdata.NewMetric() +func createMetric(name string) pmetric.Metric { + metric := pmetric.NewMetric() metric.SetName(name) - metric.SetDataType(pdata.MetricDataTypeGauge) + metric.SetDataType(pmetric.MetricDataTypeGauge) createGauge().CopyTo(metric.Gauge()) return metric } -func createInstrumentedLibrary(name string) pdata.InstrumentationLibrary { - library := pdata.NewInstrumentationLibrary() +func createInstrumentedLibrary(name string) pcommon.InstrumentationScope { + library := pcommon.NewInstrumentationScope() library.SetName(name) library.SetVersion("-") return library } -func createIlm(name string, metricNames []string) pdata.InstrumentationLibraryMetrics { - ilm := pdata.NewInstrumentationLibraryMetrics() +func createIlm(name string, metricNames []string) pmetric.ScopeMetrics { + ilm := pmetric.NewScopeMetrics() createInstrumentedLibrary(name).CopyTo(ilm.InstrumentationLibrary()) for _, metricName := range metricNames { createMetric(metricName).CopyTo(ilm.Metrics().AppendEmpty()) @@ -170,11 +171,11 @@ func createIlm(name string, metricNames []string) pdata.InstrumentationLibraryMe return ilm } -func createRm(metricsPerLibrary map[string][]string) pdata.ResourceMetrics { - rm := pdata.NewResourceMetrics() +func createRm(metricsPerLibrary map[string][]string) pmetric.ResourceMetrics { + rm := pmetric.NewResourceMetrics() keys := getStringKeySlice(metricsPerLibrary) sort.Strings(keys) - pdata.NewResource().CopyTo(rm.Resource()) + pcommon.NewResource().CopyTo(rm.Resource()) for _, key := range keys { library := key metrics := metricsPerLibrary[library] @@ -184,8 +185,8 @@ func createRm(metricsPerLibrary map[string][]string) pdata.ResourceMetrics { return rm } -func createMetrics(metricsPerLibraryArgs ...map[string][]string) pdata.Metrics { - metrics := pdata.NewMetrics() +func createMetrics(metricsPerLibraryArgs ...map[string][]string) pmetric.Metrics { + metrics := pmetric.NewMetrics() for _, metricsPerLibrary := range metricsPerLibraryArgs { createRm(metricsPerLibrary).CopyTo(metrics.ResourceMetrics().AppendEmpty()) } diff --git a/pkg/processor/metricfrequencyprocessor/sieve.go b/pkg/processor/metricfrequencyprocessor/sieve.go index 94247e3303..d87d5ccf66 100644 --- a/pkg/processor/metricfrequencyprocessor/sieve.go +++ b/pkg/processor/metricfrequencyprocessor/sieve.go @@ -5,7 +5,8 @@ import ( "sort" "time" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) const ( @@ -14,7 +15,7 @@ const ( ) type metricSieve interface { - Sift(metric pdata.Metric) bool + Sift(metric pmetric.Metric) bool } // defaultMetricSieve removes data points from MetricSlices that would be reported more often than preset @@ -27,7 +28,7 @@ type defaultMetricSieve struct { config sieveConfig metricCache *metricCache - lastReported map[string]pdata.Timestamp + lastReported map[string]pcommon.Timestamp } var _ metricSieve = (*defaultMetricSieve)(nil) @@ -35,30 +36,30 @@ var _ metricSieve = (*defaultMetricSieve)(nil) func newMetricSieve(config *Config) *defaultMetricSieve { return &defaultMetricSieve{ metricCache: newMetricCache(config.cacheConfig), - lastReported: make(map[string]pdata.Timestamp), + lastReported: make(map[string]pcommon.Timestamp), config: config.sieveConfig, } } // Sift removes data points from MetricSlices of the metric argument according to specified strategy. // It returns true if the metric should be removed. -func (ms *defaultMetricSieve) Sift(metric pdata.Metric) bool { +func (ms *defaultMetricSieve) Sift(metric pmetric.Metric) bool { switch metric.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: return ms.siftDropGauge(metric) default: return false } } -func (ms *defaultMetricSieve) siftDropGauge(metric pdata.Metric) bool { +func (ms *defaultMetricSieve) siftDropGauge(metric pmetric.Metric) bool { metric.Gauge().DataPoints().RemoveIf(ms.siftDataPoint(metric.Name())) return metric.Gauge().DataPoints().Len() == 0 } -func (ms *defaultMetricSieve) siftDataPoint(name string) func(pdata.NumberDataPoint) bool { - return func(dataPoint pdata.NumberDataPoint) bool { +func (ms *defaultMetricSieve) siftDataPoint(name string) func(pmetric.NumberDataPoint) bool { + return func(dataPoint pmetric.NumberDataPoint) bool { if math.IsNaN(getVal(dataPoint)) { return false } @@ -105,15 +106,15 @@ func (ms *defaultMetricSieve) siftDataPoint(name string) func(pdata.NumberDataPo } } -func (ms *defaultMetricSieve) metricRequiresSamples(point pdata.NumberDataPoint, earliest pdata.Timestamp) bool { +func (ms *defaultMetricSieve) metricRequiresSamples(point pmetric.NumberDataPoint, earliest pcommon.Timestamp) bool { return point.Timestamp().AsTime().Before(earliest.AsTime().Add(ms.config.MinPointAccumulationTime)) } -func pastCategoryFrequency(point pdata.NumberDataPoint, lastReport pdata.Timestamp, categoryFrequency time.Duration) bool { +func pastCategoryFrequency(point pmetric.NumberDataPoint, lastReport pcommon.Timestamp, categoryFrequency time.Duration) bool { return point.Timestamp().AsTime().Add(safetyInterval).After(lastReport.AsTime().Add(categoryFrequency)) } -func isConstant(point pdata.NumberDataPoint, points map[pdata.Timestamp]float64) bool { +func isConstant(point pmetric.NumberDataPoint, points map[pcommon.Timestamp]float64) bool { for _, value := range points { if !almostEqual(getVal(point), value) { return false @@ -126,7 +127,7 @@ func isConstant(point pdata.NumberDataPoint, points map[pdata.Timestamp]float64) // isLowInformation is a heuristic attempt at defining uninteresting metrics. Requirements: // 1) no big changes - defined by no iqr anomalies // 2) little oscillations - defined by low variation -func (ms *defaultMetricSieve) isLowInformation(points map[pdata.Timestamp]float64) bool { +func (ms *defaultMetricSieve) isLowInformation(points map[pcommon.Timestamp]float64) bool { q1, q3 := calculateQ1Q3(points) iqr := q3 - q1 variation := calculateVariation(points) @@ -136,7 +137,7 @@ func (ms *defaultMetricSieve) isLowInformation(points map[pdata.Timestamp]float6 } // calculateQ1Q3 returns specific quantiles - it refers to quantiles .25 and .75 respectively -func calculateQ1Q3(points map[pdata.Timestamp]float64) (float64, float64) { +func calculateQ1Q3(points map[pcommon.Timestamp]float64) (float64, float64) { values := valueSlice(points) sort.Float64s(values) q1Index := len(points) / 4 @@ -144,7 +145,7 @@ func calculateQ1Q3(points map[pdata.Timestamp]float64) (float64, float64) { return values[q1Index], values[q3Index] } -func withinBounds(points map[pdata.Timestamp]float64, lowerBound float64, upperBound float64) bool { +func withinBounds(points map[pcommon.Timestamp]float64, lowerBound float64, upperBound float64) bool { for _, v := range points { if v < lowerBound { return false @@ -158,7 +159,7 @@ func withinBounds(points map[pdata.Timestamp]float64, lowerBound float64, upperB } // calculateVariation returns a sum of absolute values of differences of subsequent data points. -func calculateVariation(points map[pdata.Timestamp]float64) float64 { +func calculateVariation(points map[pcommon.Timestamp]float64) float64 { keys := keySlice(points) sortTimestampArray(keys) @@ -178,8 +179,8 @@ func (ms *defaultMetricSieve) lowVariation(variation float64, iqr float64) bool return variation < ms.config.VariationIqrThresholdCoef*iqr } -func earliestTimestamp(points map[pdata.Timestamp]float64) pdata.Timestamp { - min := pdata.NewTimestampFromTime(time.Now()) +func earliestTimestamp(points map[pcommon.Timestamp]float64) pcommon.Timestamp { + min := pcommon.NewTimestampFromTime(time.Now()) for k := range points { if k < min { min = k @@ -189,8 +190,8 @@ func earliestTimestamp(points map[pdata.Timestamp]float64) pdata.Timestamp { return min } -func keySlice(mapping map[pdata.Timestamp]float64) []pdata.Timestamp { - out := make([]pdata.Timestamp, len(mapping)) +func keySlice(mapping map[pcommon.Timestamp]float64) []pcommon.Timestamp { + out := make([]pcommon.Timestamp, len(mapping)) i := 0 for k := range mapping { out[i] = k @@ -200,7 +201,7 @@ func keySlice(mapping map[pdata.Timestamp]float64) []pdata.Timestamp { return out } -func valueSlice(mapping map[pdata.Timestamp]float64) []float64 { +func valueSlice(mapping map[pcommon.Timestamp]float64) []float64 { out := make([]float64, len(mapping)) i := 0 for _, v := range mapping { diff --git a/pkg/processor/metricfrequencyprocessor/sieve_helper_test.go b/pkg/processor/metricfrequencyprocessor/sieve_helper_test.go index ddd0df4799..ab1c73f197 100644 --- a/pkg/processor/metricfrequencyprocessor/sieve_helper_test.go +++ b/pkg/processor/metricfrequencyprocessor/sieve_helper_test.go @@ -1,18 +1,16 @@ package metricfrequencyprocessor -import ( - "go.opentelemetry.io/collector/model/pdata" -) +import "go.opentelemetry.io/collector/pdata/pmetric" type siftAllSieve struct{} -func (s *siftAllSieve) Sift(metric pdata.Metric) bool { +func (s *siftAllSieve) Sift(metric pmetric.Metric) bool { return true } type keepAllSieve struct{} -func (s *keepAllSieve) Sift(metric pdata.Metric) bool { +func (s *keepAllSieve) Sift(metric pmetric.Metric) bool { return false } @@ -20,6 +18,6 @@ type singleMetricSieve struct { name string } -func (s *singleMetricSieve) Sift(metric pdata.Metric) bool { +func (s *singleMetricSieve) Sift(metric pmetric.Metric) bool { return metric.Name() == s.name } diff --git a/pkg/processor/metricfrequencyprocessor/sieve_test.go b/pkg/processor/metricfrequencyprocessor/sieve_test.go index 898ab57a83..95df8d6f12 100644 --- a/pkg/processor/metricfrequencyprocessor/sieve_test.go +++ b/pkg/processor/metricfrequencyprocessor/sieve_test.go @@ -5,7 +5,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) func TestAccumulate(t *testing.T) { @@ -23,7 +24,7 @@ func TestAccumulate(t *testing.T) { func TestIsConstant(t *testing.T) { type testCase struct { - dataPoint pdata.NumberDataPoint + dataPoint pmetric.NumberDataPoint values map[int64]float64 expectedValue bool } @@ -207,19 +208,19 @@ func TestVariation(t *testing.T) { } } -func unixPointsToPdata(points map[int64]float64) map[pdata.Timestamp]float64 { - out := make(map[pdata.Timestamp]float64) +func unixPointsToPdata(points map[int64]float64) map[pcommon.Timestamp]float64 { + out := make(map[pcommon.Timestamp]float64) for unix, value := range points { - timestamp := pdata.NewTimestampFromTime(time.Unix(unix, 0)) + timestamp := pcommon.NewTimestampFromTime(time.Unix(unix, 0)) out[timestamp] = value } return out } -func createDataPoint(timestamp time.Time, value float64) pdata.NumberDataPoint { - pdataTimestamp := pdata.NewTimestampFromTime(timestamp) - out := pdata.NewNumberDataPoint() +func createDataPoint(timestamp time.Time, value float64) pmetric.NumberDataPoint { + pdataTimestamp := pcommon.NewTimestampFromTime(timestamp) + out := pmetric.NewNumberDataPoint() out.SetTimestamp(pdataTimestamp) out.SetDoubleVal(value) return out @@ -229,10 +230,10 @@ func setupHistory(sieve metricSieve, dataPoints map[time.Time]float64) { sieve.Sift(dataPointsToMetric(dataPoints)) } -func dataPointsToMetric(dataPoints map[time.Time]float64) pdata.Metric { - out := pdata.NewMetric() +func dataPointsToMetric(dataPoints map[time.Time]float64) pmetric.Metric { + out := pmetric.NewMetric() out.SetName("test") - out.SetDataType(pdata.MetricDataTypeGauge) + out.SetDataType(pmetric.MetricDataTypeGauge) target := out.Gauge().DataPoints() for timestamp, value := range dataPoints { createDataPoint(timestamp, value).CopyTo(target.AppendEmpty()) diff --git a/pkg/processor/sourceprocessor/attribute_filler.go b/pkg/processor/sourceprocessor/attribute_filler.go index 87aebb1d7f..60c343ce66 100644 --- a/pkg/processor/sourceprocessor/attribute_filler.go +++ b/pkg/processor/sourceprocessor/attribute_filler.go @@ -19,7 +19,7 @@ import ( "regexp" "strings" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) var ( @@ -69,7 +69,7 @@ func createSourceNameFiller(cfg *Config) attributeFiller { return filler } -func (f *attributeFiller) fillResourceOrUseAnnotation(atts *pdata.AttributeMap, annotationKey string) bool { +func (f *attributeFiller) fillResourceOrUseAnnotation(atts *pcommon.Map, annotationKey string) bool { val, found := atts.Get(annotationKey) if found { annotationFiller := extractFormat(val.StringVal(), f.name) @@ -80,7 +80,7 @@ func (f *attributeFiller) fillResourceOrUseAnnotation(atts *pdata.AttributeMap, return f.fillAttributes(atts) } -func (f *attributeFiller) fillAttributes(atts *pdata.AttributeMap) bool { +func (f *attributeFiller) fillAttributes(atts *pcommon.Map) bool { if len(f.compiledFormat) == 0 { return false } @@ -97,7 +97,7 @@ func (f *attributeFiller) fillAttributes(atts *pdata.AttributeMap) bool { return false } -func (f *attributeFiller) resourceLabelValues(atts *pdata.AttributeMap) []interface{} { +func (f *attributeFiller) resourceLabelValues(atts *pcommon.Map) []interface{} { arr := make([]interface{}, 0) for _, label := range f.labels { if value, found := atts.Get(label); found { diff --git a/pkg/processor/sourceprocessor/go.mod b/pkg/processor/sourceprocessor/go.mod index d046bdb232..eff745a74a 100644 --- a/pkg/processor/sourceprocessor/go.mod +++ b/pkg/processor/sourceprocessor/go.mod @@ -5,22 +5,21 @@ go 1.18 require ( github.com/stretchr/testify v1.7.1 go.opencensus.io v0.23.0 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/pdata v0.49.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/cast v1.4.1 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect diff --git a/pkg/processor/sourceprocessor/go.sum b/pkg/processor/sourceprocessor/go.sum index 4dc9153ae2..5b51acc380 100644 --- a/pkg/processor/sourceprocessor/go.sum +++ b/pkg/processor/sourceprocessor/go.sum @@ -15,7 +15,7 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -68,7 +68,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -98,8 +97,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -139,8 +138,6 @@ github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8d github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -155,20 +152,18 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 h1:li8u9OSMvLau7rMs8bmiL82OazG6MAkwPz2i6eS8TBQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -200,7 +195,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -222,7 +217,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pkg/processor/sourceprocessor/source_category_filler.go b/pkg/processor/sourceprocessor/source_category_filler.go index 452e0a6e13..c7dad96c32 100644 --- a/pkg/processor/sourceprocessor/source_category_filler.go +++ b/pkg/processor/sourceprocessor/source_category_filler.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) // sourceCategoryFiller adds source category attribute to a collection of attributes. @@ -64,7 +64,7 @@ func extractTemplateAttributes(template string) []string { // - the source category container-level annotation (e.g. "k8s.pod.annotation.sumologic.com/container-name.sourceCategory"), // - the source category pod-level annotation (e.g. "k8s.pod.annotation.sumologic.com/sourceCategory"), // - the source category configured in the processor's "source_category" configuration option. -func (f *sourceCategoryFiller) fill(attributes *pdata.AttributeMap) { +func (f *sourceCategoryFiller) fill(attributes *pcommon.Map) { containerSourceCategory := f.getSourceCategoryFromContainerAnnotation(attributes) if containerSourceCategory != "" { attributes.UpsertString(sourceCategoryKey, containerSourceCategory) @@ -96,7 +96,7 @@ func (f *sourceCategoryFiller) fill(attributes *pdata.AttributeMap) { attributes.UpsertString(sourceCategoryKey, sourceCategoryValue) } -func (f *sourceCategoryFiller) getSourceCategoryFromContainerAnnotation(attributes *pdata.AttributeMap) string { +func (f *sourceCategoryFiller) getSourceCategoryFromContainerAnnotation(attributes *pcommon.Map) string { if !f.containerAnnotationsEnabled { return "" } @@ -116,7 +116,7 @@ func (f *sourceCategoryFiller) getSourceCategoryFromContainerAnnotation(attribut return "" } -func (f *sourceCategoryFiller) replaceTemplateAttributes(template string, templateAttributes []string, attributes *pdata.AttributeMap) string { +func (f *sourceCategoryFiller) replaceTemplateAttributes(template string, templateAttributes []string, attributes *pcommon.Map) string { replacerArgs := make([]string, len(templateAttributes)*2) for i, templateAttribute := range templateAttributes { attributeValue, found := attributes.Get(templateAttribute) @@ -133,7 +133,7 @@ func (f *sourceCategoryFiller) replaceTemplateAttributes(template string, templa return strings.NewReplacer(replacerArgs...).Replace(template) } -func getAnnotationAttributeValue(annotationAttributePrefix string, annotation string, attributes *pdata.AttributeMap) string { +func getAnnotationAttributeValue(annotationAttributePrefix string, annotation string, attributes *pcommon.Map) string { annotationAttribute, found := attributes.Get(annotationAttributePrefix + annotation) if found { return annotationAttribute.StringVal() diff --git a/pkg/processor/sourceprocessor/source_category_filler_test.go b/pkg/processor/sourceprocessor/source_category_filler_test.go index 4807b029d9..455102a65b 100644 --- a/pkg/processor/sourceprocessor/source_category_filler_test.go +++ b/pkg/processor/sourceprocessor/source_category_filler_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" ) func TestNewSourceCategoryFiller(t *testing.T) { @@ -36,7 +36,7 @@ func TestFill(t *testing.T) { cfg := createDefaultConfig().(*Config) cfg.SourceCategory = "source-%{k8s.namespace.name}-%{k8s.pod.uid}-cat" - attrs := pdata.NewAttributeMap() + attrs := pcommon.NewMap() attrs.InsertString("k8s.namespace.name", "ns-1") attrs.InsertString("k8s.pod.uid", "123asd") @@ -49,7 +49,7 @@ func TestFill(t *testing.T) { func TestFillWithAnnotations(t *testing.T) { cfg := createDefaultConfig().(*Config) - attrs := pdata.NewAttributeMap() + attrs := pcommon.NewMap() attrs.InsertString("k8s.namespace.name", "ns-1") attrs.InsertString("k8s.pod.uid", "123asd") attrs.InsertString("k8s.pod.annotation.sumologic.com/sourceCategory", "sc-from-annot-%{k8s.namespace.name}-%{k8s.pod.uid}") @@ -67,7 +67,7 @@ func TestFillWithContainerAnnotations(t *testing.T) { cfg := createDefaultConfig().(*Config) cfg.SourceCategory = "my-source-category" - attrs := pdata.NewAttributeMap() + attrs := pcommon.NewMap() attrs.InsertString("k8s.pod.annotation.sumologic.com/container-name-1.sourceCategory", "first_source-category") attrs.InsertString("k8s.pod.annotation.sumologic.com/container-name-2.sourceCategory", "another/source-category") attrs.InsertString("k8s.container.name", "container-name-1") @@ -83,7 +83,7 @@ func TestFillWithContainerAnnotations(t *testing.T) { cfg.SourceCategory = "my-source-category" cfg.ContainerAnnotations.Enabled = true - attrs := pdata.NewAttributeMap() + attrs := pcommon.NewMap() attrs.InsertString("k8s.pod.annotation.sumologic.com/container-name-1.sourceCategory", "first_source-category") attrs.InsertString("k8s.pod.annotation.sumologic.com/container-name-2.sourceCategory", "another/source-category") attrs.InsertString("k8s.container.name", "container-name-1") @@ -99,7 +99,7 @@ func TestFillWithContainerAnnotations(t *testing.T) { cfg.SourceCategory = "my-source-category" cfg.ContainerAnnotations.Enabled = true - attrs := pdata.NewAttributeMap() + attrs := pcommon.NewMap() attrs.InsertString("k8s.pod.annotation.sumologic.com/container-name-1.sourceCategory", "first_source-category") attrs.InsertString("k8s.pod.annotation.sumologic.com/container-name-2.sourceCategory", "another/source-category") attrs.InsertString("k8s.container.name", "container-name-2") @@ -119,7 +119,7 @@ func TestFillWithContainerAnnotations(t *testing.T) { "customAnno_prefix:", } - attrs := pdata.NewAttributeMap() + attrs := pcommon.NewMap() attrs.InsertString("k8s.pod.annotation.customAnno_prefix:container-name-1.sourceCategory", "first_source-category") attrs.InsertString("k8s.pod.annotation.customAnno_prefix:container-name-2.sourceCategory", "another/source-category") attrs.InsertString("k8s.pod.annotation.customAnno_prefix:container-name-3.sourceCategory", "THIRD_s-c!") diff --git a/pkg/processor/sourceprocessor/source_processor.go b/pkg/processor/sourceprocessor/source_processor.go index 1f515b15f5..1b651ddb8d 100644 --- a/pkg/processor/sourceprocessor/source_processor.go +++ b/pkg/processor/sourceprocessor/source_processor.go @@ -22,7 +22,10 @@ import ( "strings" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/model/pdata" + "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/SumoLogic/sumologic-otel-collector/pkg/processor/sourceprocessor/observability" ) @@ -107,28 +110,28 @@ func newSourceProcessor(cfg *Config) *sourceProcessor { } } -func (sp *sourceProcessor) fillOtherMeta(atts pdata.AttributeMap) { +func (sp *sourceProcessor) fillOtherMeta(atts pcommon.Map) { if sp.collector != "" { atts.UpsertString(collectorKey, sp.collector) } } -func (sp *sourceProcessor) isFilteredOut(atts pdata.AttributeMap) bool { +func (sp *sourceProcessor) isFilteredOut(atts pcommon.Map) bool { // TODO: This is quite inefficient when done for each package (ore even more so, span) separately. // It should be moved to K8S Meta Processor and done once per new pod/changed pod if value, found := atts.Get(sp.annotationAttribute(excludeAnnotation)); found { - if value.Type() == pdata.AttributeValueTypeString && value.StringVal() == "true" { + if value.Type() == pcommon.ValueTypeString && value.StringVal() == "true" { return true - } else if value.Type() == pdata.AttributeValueTypeBool && value.BoolVal() { + } else if value.Type() == pcommon.ValueTypeBool && value.BoolVal() { return true } } if value, found := atts.Get(sp.annotationAttribute(includeAnnotation)); found { - if value.Type() == pdata.AttributeValueTypeString && value.StringVal() == "true" { + if value.Type() == pcommon.ValueTypeString && value.StringVal() == "true" { return false - } else if value.Type() == pdata.AttributeValueTypeBool && value.BoolVal() { + } else if value.Type() == pcommon.ValueTypeBool && value.BoolVal() { return false } } @@ -149,7 +152,7 @@ func (sp *sourceProcessor) annotationAttribute(annotationKey string) string { } // ProcessTraces processes traces -func (sp *sourceProcessor) ProcessTraces(ctx context.Context, td pdata.Traces) (pdata.Traces, error) { +func (sp *sourceProcessor) ProcessTraces(ctx context.Context, td ptrace.Traces) (ptrace.Traces, error) { rss := td.ResourceSpans() for i := 0; i < rss.Len(); i++ { @@ -167,7 +170,7 @@ func (sp *sourceProcessor) ProcessTraces(ctx context.Context, td pdata.Traces) ( } if sp.isFilteredOut(atts) { - rs.InstrumentationLibrarySpans().RemoveIf(func(pdata.InstrumentationLibrarySpans) bool { return true }) + rs.InstrumentationLibrarySpans().RemoveIf(func(ptrace.ScopeSpans) bool { return true }) observability.RecordFilteredOutN(totalSpans) } else { observability.RecordFilteredInN(totalSpans) @@ -178,7 +181,7 @@ func (sp *sourceProcessor) ProcessTraces(ctx context.Context, td pdata.Traces) ( } // ProcessMetrics processes metrics -func (sp *sourceProcessor) ProcessMetrics(ctx context.Context, md pdata.Metrics) (pdata.Metrics, error) { +func (sp *sourceProcessor) ProcessMetrics(ctx context.Context, md pmetric.Metrics) (pmetric.Metrics, error) { rss := md.ResourceMetrics() for i := 0; i < rss.Len(); i++ { @@ -187,7 +190,7 @@ func (sp *sourceProcessor) ProcessMetrics(ctx context.Context, md pdata.Metrics) atts := res.Attributes() if sp.isFilteredOut(atts) { - rs.InstrumentationLibraryMetrics().RemoveIf(func(pdata.InstrumentationLibraryMetrics) bool { return true }) + rs.InstrumentationLibraryMetrics().RemoveIf(func(pmetric.ScopeMetrics) bool { return true }) } } @@ -195,7 +198,7 @@ func (sp *sourceProcessor) ProcessMetrics(ctx context.Context, md pdata.Metrics) } // ProcessLogs processes logs -func (sp *sourceProcessor) ProcessLogs(ctx context.Context, md pdata.Logs) (pdata.Logs, error) { +func (sp *sourceProcessor) ProcessLogs(ctx context.Context, md plog.Logs) (plog.Logs, error) { rss := md.ResourceLogs() var dockerLog dockerLog @@ -206,7 +209,7 @@ func (sp *sourceProcessor) ProcessLogs(ctx context.Context, md pdata.Logs) (pdat atts := res.Attributes() if sp.isFilteredOut(atts) { - rs.InstrumentationLibraryLogs().RemoveIf(func(pdata.InstrumentationLibraryLogs) bool { return true }) + rs.InstrumentationLibraryLogs().RemoveIf(func(plog.ScopeLogs) bool { return true }) } // Due to fluent-bit configuration for sumologic kubernetes collection, @@ -224,7 +227,7 @@ func (sp *sourceProcessor) ProcessLogs(ctx context.Context, md pdata.Logs) (pdat logs := ill.LogRecords() for k := 0; k < logs.Len(); k++ { log := logs.At(k) - if log.Body().Type() == pdata.AttributeValueTypeString { + if log.Body().Type() == pcommon.ValueTypeString { err := json.Unmarshal([]byte(log.Body().StringVal()), &dockerLog) // If there was any parsing error or any of the expected key have no value @@ -251,7 +254,7 @@ func (sp *sourceProcessor) ProcessLogs(ctx context.Context, md pdata.Logs) (pdat // - enrich pod name, so it can be used in templates // - fills source attributes based on config or annotations // - set metadata (collector name) -func (sp *sourceProcessor) processResource(res pdata.Resource) pdata.Resource { +func (sp *sourceProcessor) processResource(res pcommon.Resource) pcommon.Resource { atts := res.Attributes() sp.enrichPodName(&atts) @@ -288,7 +291,7 @@ func SafeEncodeString(s string) string { return string(r) } -func (sp *sourceProcessor) enrichPodName(atts *pdata.AttributeMap) { +func (sp *sourceProcessor) enrichPodName(atts *pcommon.Map) { // This replicates sanitize_pod_name function // Strip out dynamic bits from pod name. // NOTE: Kubernetes deployments append a template hash. @@ -327,13 +330,13 @@ func (sp *sourceProcessor) enrichPodName(atts *pdata.AttributeMap) { // and matches is with the provided regex. // It returns the string value of found elements and a boolean flag whether the // value matched the provided regex. -func matchFieldByRegex(atts pdata.AttributeMap, field string, r *regexp.Regexp) (string, bool) { +func matchFieldByRegex(atts pcommon.Map, field string, r *regexp.Regexp) (string, bool) { att, ok := atts.Get(field) if !ok { return "", false } - if att.Type() != pdata.AttributeValueTypeString { + if att.Type() != pcommon.ValueTypeString { return "", false } diff --git a/pkg/processor/sourceprocessor/source_processor_test.go b/pkg/processor/sourceprocessor/source_processor_test.go index 04fba714f5..596d47846f 100644 --- a/pkg/processor/sourceprocessor/source_processor_test.go +++ b/pkg/processor/sourceprocessor/source_processor_test.go @@ -20,7 +20,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/ptrace" ) func createConfig() *Config { @@ -77,8 +79,8 @@ var ( } ) -func newLogsDataWithLogs(resourceAttrs map[string]string, logAttrs map[string]string) pdata.Logs { - ld := pdata.NewLogs() +func newLogsDataWithLogs(resourceAttrs map[string]string, logAttrs map[string]string) plog.Logs { + ld := plog.NewLogs() rs := ld.ResourceLogs().AppendEmpty() attrs := rs.Resource().Attributes() for k, v := range resourceAttrs { @@ -95,8 +97,8 @@ func newLogsDataWithLogs(resourceAttrs map[string]string, logAttrs map[string]st return ld } -func newTraceData(labels map[string]string) pdata.Traces { - td := pdata.NewTraces() +func newTraceData(labels map[string]string) ptrace.Traces { + td := ptrace.NewTraces() rs := td.ResourceSpans().AppendEmpty() attrs := rs.Resource().Attributes() for k, v := range labels { @@ -105,7 +107,7 @@ func newTraceData(labels map[string]string) pdata.Traces { return td } -func newTraceDataWithSpans(_resourceLabels map[string]string, _spanLabels map[string]string) pdata.Traces { +func newTraceDataWithSpans(_resourceLabels map[string]string, _spanLabels map[string]string) ptrace.Traces { // This will be very small attribute set, the actual data will be at span level td := newTraceData(_resourceLabels) ils := td.ResourceSpans().At(0).InstrumentationLibrarySpans().AppendEmpty() @@ -118,7 +120,7 @@ func newTraceDataWithSpans(_resourceLabels map[string]string, _spanLabels map[st return td } -func prepareAttributesForAssert(t pdata.Traces) { +func prepareAttributesForAssert(t ptrace.Traces) { for i := 0; i < t.ResourceSpans().Len(); i++ { rss := t.ResourceSpans().At(i) rss.Resource().Attributes().Sort() @@ -131,13 +133,13 @@ func prepareAttributesForAssert(t pdata.Traces) { } } -func assertTracesEqual(t *testing.T, t1 pdata.Traces, t2 pdata.Traces) { +func assertTracesEqual(t *testing.T, t1 ptrace.Traces, t2 ptrace.Traces) { prepareAttributesForAssert(t1) prepareAttributesForAssert(t2) assert.Equal(t, t1, t2) } -func assertSpansEqual(t *testing.T, t1 pdata.Traces, t2 pdata.Traces) { +func assertSpansEqual(t *testing.T, t1 ptrace.Traces, t2 ptrace.Traces) { prepareAttributesForAssert(t1) prepareAttributesForAssert(t2) assert.Equal(t, t1.ResourceSpans().Len(), t2.ResourceSpans().Len()) @@ -187,7 +189,7 @@ func TestLogsSourceHostKey(t *testing.T) { out, err := sp.ProcessLogs(context.Background(), pLogs) require.NoError(t, err) - out.ResourceLogs().At(0).Resource().Attributes().Range(func(k string, v pdata.AttributeValue) bool { + out.ResourceLogs().At(0).Resource().Attributes().Range(func(k string, v pcommon.Value) bool { t.Logf("k %s : v %v\n", k, v.StringVal()) return true }) @@ -219,7 +221,7 @@ func TestLogsSourceHostKey(t *testing.T) { out, err := sp.ProcessLogs(context.Background(), pLogs) require.NoError(t, err) - out.ResourceLogs().At(0).Resource().Attributes().Range(func(k string, v pdata.AttributeValue) bool { + out.ResourceLogs().At(0).Resource().Attributes().Range(func(k string, v pcommon.Value) bool { t.Logf("k %s : v %v\n", k, v.StringVal()) return true }) @@ -259,7 +261,7 @@ func TestTraceSourceFilteringOutByRegex(t *testing.T) { testcases := []struct { name string cfg *Config - want pdata.Traces + want ptrace.Traces }{ { name: "pod exclude regex", @@ -270,10 +272,10 @@ func TestTraceSourceFilteringOutByRegex(t *testing.T) { } return cfg }(), - want: func() pdata.Traces { + want: func() ptrace.Traces { want := newTraceDataWithSpans(mergedK8sLabels, k8sLabels) want.ResourceSpans().At(0).InstrumentationLibrarySpans(). - RemoveIf(func(pdata.InstrumentationLibrarySpans) bool { return true }) + RemoveIf(func(ptrace.ScopeSpans) bool { return true }) return want }(), }, @@ -286,10 +288,10 @@ func TestTraceSourceFilteringOutByRegex(t *testing.T) { } return cfg }(), - want: func() pdata.Traces { + want: func() ptrace.Traces { want := newTraceDataWithSpans(mergedK8sLabels, k8sLabels) want.ResourceSpans().At(0).InstrumentationLibrarySpans(). - RemoveIf(func(pdata.InstrumentationLibrarySpans) bool { return true }) + RemoveIf(func(ptrace.ScopeSpans) bool { return true }) return want }(), }, @@ -302,10 +304,10 @@ func TestTraceSourceFilteringOutByRegex(t *testing.T) { } return cfg }(), - want: func() pdata.Traces { + want: func() ptrace.Traces { want := newTraceDataWithSpans(mergedK8sLabels, k8sLabels) want.ResourceSpans().At(0).InstrumentationLibrarySpans(). - RemoveIf(func(pdata.InstrumentationLibrarySpans) bool { return true }) + RemoveIf(func(ptrace.ScopeSpans) bool { return true }) return want }(), }, @@ -314,7 +316,7 @@ func TestTraceSourceFilteringOutByRegex(t *testing.T) { cfg: func() *Config { return createConfig() }(), - want: func() pdata.Traces { + want: func() ptrace.Traces { return newTraceDataWithSpans(mergedK8sLabels, k8sLabels) }(), }, @@ -341,7 +343,7 @@ func TestTraceSourceFilteringOutByExclude(t *testing.T) { want := newTraceDataWithSpans(limitedLabelsWithMeta, mergedK8sLabels) want.ResourceSpans().At(0).InstrumentationLibrarySpans(). - RemoveIf(func(pdata.InstrumentationLibrarySpans) bool { return true }) + RemoveIf(func(ptrace.ScopeSpans) bool { return true }) rtp := newSourceProcessor(cfg) @@ -505,7 +507,7 @@ func TestSourceCategoryTemplateWithCustomAttribute(t *testing.T) { }) } -func assertAttribute(t *testing.T, attributes pdata.AttributeMap, attributeName string, expectedValue string) { +func assertAttribute(t *testing.T, attributes pcommon.Map, attributeName string, expectedValue string) { value, exists := attributes.Get(attributeName) if expectedValue == "" { @@ -525,7 +527,7 @@ func TestLogProcessorJson(t *testing.T) { body string expectedBody string expectedAttributes map[string]string - testLogs pdata.Logs + testLogs plog.Logs }{ { name: "dockerFormat", @@ -571,7 +573,7 @@ func TestLogProcessorJson(t *testing.T) { for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - inputLog := pdata.NewLogs() + inputLog := plog.NewLogs() inputLog. ResourceLogs(). AppendEmpty(). diff --git a/pkg/processor/sumologicschemaprocessor/cloud_namespace_processor.go b/pkg/processor/sumologicschemaprocessor/cloud_namespace_processor.go index 9d5e0d01cc..afe1327b74 100644 --- a/pkg/processor/sumologicschemaprocessor/cloud_namespace_processor.go +++ b/pkg/processor/sumologicschemaprocessor/cloud_namespace_processor.go @@ -15,8 +15,11 @@ package sumologicschemaprocessor import ( - "go.opentelemetry.io/collector/model/pdata" conventions "go.opentelemetry.io/collector/model/semconv/v1.6.1" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" ) // cloudNamespaceProcessor adds the `cloud.namespace` resource attribute to logs, metrics and traces. @@ -37,21 +40,21 @@ func newCloudNamespaceProcessor(addCloudNamespace bool) (*cloudNamespaceProcesso }, nil } -func (*cloudNamespaceProcessor) processLogs(logs pdata.Logs) (pdata.Logs, error) { +func (*cloudNamespaceProcessor) processLogs(logs plog.Logs) (plog.Logs, error) { for i := 0; i < logs.ResourceLogs().Len(); i++ { addCloudNamespaceAttribute(logs.ResourceLogs().At(i).Resource().Attributes()) } return logs, nil } -func (*cloudNamespaceProcessor) processMetrics(metrics pdata.Metrics) (pdata.Metrics, error) { +func (*cloudNamespaceProcessor) processMetrics(metrics pmetric.Metrics) (pmetric.Metrics, error) { for i := 0; i < metrics.ResourceMetrics().Len(); i++ { addCloudNamespaceAttribute(metrics.ResourceMetrics().At(i).Resource().Attributes()) } return metrics, nil } -func (*cloudNamespaceProcessor) processTraces(traces pdata.Traces) (pdata.Traces, error) { +func (*cloudNamespaceProcessor) processTraces(traces ptrace.Traces) (ptrace.Traces, error) { for i := 0; i < traces.ResourceSpans().Len(); i++ { addCloudNamespaceAttribute(traces.ResourceSpans().At(i).Resource().Attributes()) } @@ -62,7 +65,7 @@ func (*cloudNamespaceProcessor) processTraces(traces pdata.Traces) (pdata.Traces // to a collection of attributes that already contains a `cloud.platform` attribute. // It does not add the `cloud.namespace` attribute for all `cloud.platform` values, // but only for a few specific ones - namely AWS EC2, AWS ECS, and AWS Elastic Beanstalk. -func addCloudNamespaceAttribute(attributes pdata.AttributeMap) { +func addCloudNamespaceAttribute(attributes pcommon.Map) { cloudPlatformAttributeValue, found := attributes.Get(conventions.AttributeCloudPlatform) if !found { return diff --git a/pkg/processor/sumologicschemaprocessor/go.mod b/pkg/processor/sumologicschemaprocessor/go.mod index dcbc4b6392..5feb07b03e 100644 --- a/pkg/processor/sumologicschemaprocessor/go.mod +++ b/pkg/processor/sumologicschemaprocessor/go.mod @@ -6,24 +6,25 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opencensus.io v0.23.0 // indirect - go.opentelemetry.io/collector v0.48.0 + go.opentelemetry.io/collector v0.49.0 gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) require ( github.com/gogo/protobuf v1.3.2 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/spf13/cast v1.4.1 // indirect github.com/stretchr/testify v1.7.1 - go.opentelemetry.io/collector/model v0.48.0 - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/collector/model v0.49.0 + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 ) + +require go.opentelemetry.io/collector/pdata v0.49.0 diff --git a/pkg/processor/sumologicschemaprocessor/go.sum b/pkg/processor/sumologicschemaprocessor/go.sum index 4dc9153ae2..e385b31f8b 100644 --- a/pkg/processor/sumologicschemaprocessor/go.sum +++ b/pkg/processor/sumologicschemaprocessor/go.sum @@ -15,7 +15,7 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -68,7 +68,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -98,8 +97,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -139,8 +138,6 @@ github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8d github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -155,20 +152,20 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/model v0.49.0 h1:mbUSNgpaBE3GWmzGsRb5t0xILpXIVYv7scPTTfoMt6c= +go.opentelemetry.io/collector/model v0.49.0/go.mod h1:nOYQv9KoFPs6ihJwOi24qB209EOhS9HkwhGj54YiEAw= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 h1:li8u9OSMvLau7rMs8bmiL82OazG6MAkwPz2i6eS8TBQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -200,7 +197,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -222,7 +219,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pkg/processor/sumologicschemaprocessor/processor.go b/pkg/processor/sumologicschemaprocessor/processor.go index 95f2837546..3fce8cd0f0 100644 --- a/pkg/processor/sumologicschemaprocessor/processor.go +++ b/pkg/processor/sumologicschemaprocessor/processor.go @@ -18,7 +18,9 @@ import ( "context" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" ) @@ -54,7 +56,7 @@ func (processor *sumologicSchemaProcessor) shutdown(_ context.Context) error { return nil } -func (processor *sumologicSchemaProcessor) processLogs(_ context.Context, logs pdata.Logs) (pdata.Logs, error) { +func (processor *sumologicSchemaProcessor) processLogs(_ context.Context, logs plog.Logs) (plog.Logs, error) { logs, err := processor.cloudNamespaceProcessor.processLogs(logs) if err != nil { return logs, err @@ -63,7 +65,7 @@ func (processor *sumologicSchemaProcessor) processLogs(_ context.Context, logs p return logs, nil } -func (processor *sumologicSchemaProcessor) processMetrics(ctx context.Context, metrics pdata.Metrics) (pdata.Metrics, error) { +func (processor *sumologicSchemaProcessor) processMetrics(ctx context.Context, metrics pmetric.Metrics) (pmetric.Metrics, error) { metrics, err := processor.cloudNamespaceProcessor.processMetrics(metrics) if err != nil { return metrics, err @@ -72,7 +74,7 @@ func (processor *sumologicSchemaProcessor) processMetrics(ctx context.Context, m return metrics, nil } -func (processor *sumologicSchemaProcessor) processTraces(ctx context.Context, traces pdata.Traces) (pdata.Traces, error) { +func (processor *sumologicSchemaProcessor) processTraces(ctx context.Context, traces ptrace.Traces) (ptrace.Traces, error) { traces, err := processor.cloudNamespaceProcessor.processTraces(traces) if err != nil { return traces, err diff --git a/pkg/processor/sumologicschemaprocessor/processor_test.go b/pkg/processor/sumologicschemaprocessor/processor_test.go index 9064737783..4fc8d976c7 100644 --- a/pkg/processor/sumologicschemaprocessor/processor_test.go +++ b/pkg/processor/sumologicschemaprocessor/processor_test.go @@ -21,7 +21,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" ) @@ -29,18 +31,18 @@ func TestAddCloudNamespaceForLogs(t *testing.T) { testCases := []struct { name string addCloudNamespace bool - createLogs func() pdata.Logs - test func(pdata.Logs) + createLogs func() plog.Logs + test func(plog.Logs) }{ { name: "adds cloud.namespace attribute for EC2", addCloudNamespace: true, - createLogs: func() pdata.Logs { - inputLogs := pdata.NewLogs() + createLogs: func() plog.Logs { + inputLogs := plog.NewLogs() inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") return inputLogs }, - test: func(outputLogs pdata.Logs) { + test: func(outputLogs plog.Logs) { cloudNamespaceAttribute, found := outputLogs.ResourceLogs().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", cloudNamespaceAttribute.StringVal()) @@ -49,12 +51,12 @@ func TestAddCloudNamespaceForLogs(t *testing.T) { { name: "adds cloud.namespace attribute for ECS", addCloudNamespace: true, - createLogs: func() pdata.Logs { - inputLogs := pdata.NewLogs() + createLogs: func() plog.Logs { + inputLogs := plog.NewLogs() inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ecs") return inputLogs }, - test: func(outputLogs pdata.Logs) { + test: func(outputLogs plog.Logs) { cloudNamespaceAttribute, found := outputLogs.ResourceLogs().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "ecs", cloudNamespaceAttribute.StringVal()) @@ -63,12 +65,12 @@ func TestAddCloudNamespaceForLogs(t *testing.T) { { name: "adds cloud.namespace attribute for Beanstalk", addCloudNamespace: true, - createLogs: func() pdata.Logs { - inputLogs := pdata.NewLogs() + createLogs: func() plog.Logs { + inputLogs := plog.NewLogs() inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_elastic_beanstalk") return inputLogs }, - test: func(outputLogs pdata.Logs) { + test: func(outputLogs plog.Logs) { cloudNamespaceAttribute, found := outputLogs.ResourceLogs().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "ElasticBeanstalk", cloudNamespaceAttribute.StringVal()) @@ -77,15 +79,15 @@ func TestAddCloudNamespaceForLogs(t *testing.T) { { name: "does not add cloud.namespace attribute for unknown cloud.platform attribute values", addCloudNamespace: false, - createLogs: func() pdata.Logs { - inputLogs := pdata.NewLogs() + createLogs: func() plog.Logs { + inputLogs := plog.NewLogs() inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_eks") inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_lambda") inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "azure_vm") inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "gcp_app_engine") return inputLogs }, - test: func(outputLogs pdata.Logs) { + test: func(outputLogs plog.Logs) { for i := 0; i < outputLogs.ResourceLogs().Len(); i++ { _, found := outputLogs.ResourceLogs().At(i).Resource().Attributes().Get("cloud.namespace") assert.False(t, found) @@ -95,12 +97,12 @@ func TestAddCloudNamespaceForLogs(t *testing.T) { { name: "does not add cloud.namespce attribute when disabled", addCloudNamespace: false, - createLogs: func() pdata.Logs { - inputLogs := pdata.NewLogs() + createLogs: func() plog.Logs { + inputLogs := plog.NewLogs() inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") return inputLogs }, - test: func(outputLogs pdata.Logs) { + test: func(outputLogs plog.Logs) { cloudNamespaceAttribute, found := outputLogs.ResourceLogs().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", cloudNamespaceAttribute.StringVal()) @@ -109,15 +111,15 @@ func TestAddCloudNamespaceForLogs(t *testing.T) { { name: "adds different cloud.namespace attributes to different resources", addCloudNamespace: true, - createLogs: func() pdata.Logs { - inputLogs := pdata.NewLogs() + createLogs: func() plog.Logs { + inputLogs := plog.NewLogs() inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_lambda") inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ecs") inputLogs.ResourceLogs().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_elastic_beanstalk") return inputLogs }, - test: func(outputLogs pdata.Logs) { + test: func(outputLogs plog.Logs) { ec2ResourceAttribute, found := outputLogs.ResourceLogs().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", ec2ResourceAttribute.StringVal()) @@ -156,18 +158,18 @@ func TestAddCloudNamespaceForMetrics(t *testing.T) { testCases := []struct { name string addCloudNamespace bool - createMetrics func() pdata.Metrics - test func(pdata.Metrics) + createMetrics func() pmetric.Metrics + test func(pmetric.Metrics) }{ { name: "adds cloud.namespace attribute for EC2", addCloudNamespace: true, - createMetrics: func() pdata.Metrics { - inputMetrics := pdata.NewMetrics() + createMetrics: func() pmetric.Metrics { + inputMetrics := pmetric.NewMetrics() inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") return inputMetrics }, - test: func(outputMetrics pdata.Metrics) { + test: func(outputMetrics pmetric.Metrics) { cloudNamespaceAttribute, found := outputMetrics.ResourceMetrics().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", cloudNamespaceAttribute.StringVal()) @@ -176,12 +178,12 @@ func TestAddCloudNamespaceForMetrics(t *testing.T) { { name: "adds cloud.namespace attribute for ECS", addCloudNamespace: true, - createMetrics: func() pdata.Metrics { - inputMetrics := pdata.NewMetrics() + createMetrics: func() pmetric.Metrics { + inputMetrics := pmetric.NewMetrics() inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ecs") return inputMetrics }, - test: func(outputMetrics pdata.Metrics) { + test: func(outputMetrics pmetric.Metrics) { cloudNamespaceAttribute, found := outputMetrics.ResourceMetrics().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "ecs", cloudNamespaceAttribute.StringVal()) @@ -190,12 +192,12 @@ func TestAddCloudNamespaceForMetrics(t *testing.T) { { name: "adds cloud.namespace attribute for Beanstalk", addCloudNamespace: true, - createMetrics: func() pdata.Metrics { - inputMetrics := pdata.NewMetrics() + createMetrics: func() pmetric.Metrics { + inputMetrics := pmetric.NewMetrics() inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_elastic_beanstalk") return inputMetrics }, - test: func(outputMetrics pdata.Metrics) { + test: func(outputMetrics pmetric.Metrics) { cloudNamespaceAttribute, found := outputMetrics.ResourceMetrics().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "ElasticBeanstalk", cloudNamespaceAttribute.StringVal()) @@ -204,15 +206,15 @@ func TestAddCloudNamespaceForMetrics(t *testing.T) { { name: "does not add cloud.namespace attribute for unknown cloud.platform attribute values", addCloudNamespace: false, - createMetrics: func() pdata.Metrics { - inputMetrics := pdata.NewMetrics() + createMetrics: func() pmetric.Metrics { + inputMetrics := pmetric.NewMetrics() inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_eks") inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_lambda") inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "azure_vm") inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "gcp_app_engine") return inputMetrics }, - test: func(outputMetrics pdata.Metrics) { + test: func(outputMetrics pmetric.Metrics) { for i := 0; i < outputMetrics.ResourceMetrics().Len(); i++ { _, found := outputMetrics.ResourceMetrics().At(i).Resource().Attributes().Get("cloud.namespace") assert.False(t, found) @@ -222,12 +224,12 @@ func TestAddCloudNamespaceForMetrics(t *testing.T) { { name: "does not add cloud.namespce attribute when disabled", addCloudNamespace: false, - createMetrics: func() pdata.Metrics { - inputMetrics := pdata.NewMetrics() + createMetrics: func() pmetric.Metrics { + inputMetrics := pmetric.NewMetrics() inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") return inputMetrics }, - test: func(outputMetrics pdata.Metrics) { + test: func(outputMetrics pmetric.Metrics) { cloudNamespaceAttribute, found := outputMetrics.ResourceMetrics().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", cloudNamespaceAttribute.StringVal()) @@ -236,15 +238,15 @@ func TestAddCloudNamespaceForMetrics(t *testing.T) { { name: "adds different cloud.namespace attributes to different resources", addCloudNamespace: true, - createMetrics: func() pdata.Metrics { - inputMetrics := pdata.NewMetrics() + createMetrics: func() pmetric.Metrics { + inputMetrics := pmetric.NewMetrics() inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_lambda") inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ecs") inputMetrics.ResourceMetrics().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_elastic_beanstalk") return inputMetrics }, - test: func(outputMetrics pdata.Metrics) { + test: func(outputMetrics pmetric.Metrics) { ec2ResourceAttribute, found := outputMetrics.ResourceMetrics().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", ec2ResourceAttribute.StringVal()) @@ -283,18 +285,18 @@ func TestAddCloudNamespaceForTraces(t *testing.T) { testCases := []struct { name string addCloudNamespace bool - createTraces func() pdata.Traces - test func(pdata.Traces) + createTraces func() ptrace.Traces + test func(ptrace.Traces) }{ { name: "adds cloud.namespace attribute for EC2", addCloudNamespace: true, - createTraces: func() pdata.Traces { - inputTraces := pdata.NewTraces() + createTraces: func() ptrace.Traces { + inputTraces := ptrace.NewTraces() inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") return inputTraces }, - test: func(outputTraces pdata.Traces) { + test: func(outputTraces ptrace.Traces) { cloudNamespaceAttribute, found := outputTraces.ResourceSpans().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", cloudNamespaceAttribute.StringVal()) @@ -303,12 +305,12 @@ func TestAddCloudNamespaceForTraces(t *testing.T) { { name: "adds cloud.namespace attribute for ECS", addCloudNamespace: true, - createTraces: func() pdata.Traces { - inputTraces := pdata.NewTraces() + createTraces: func() ptrace.Traces { + inputTraces := ptrace.NewTraces() inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ecs") return inputTraces }, - test: func(outputTraces pdata.Traces) { + test: func(outputTraces ptrace.Traces) { cloudNamespaceAttribute, found := outputTraces.ResourceSpans().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "ecs", cloudNamespaceAttribute.StringVal()) @@ -317,12 +319,12 @@ func TestAddCloudNamespaceForTraces(t *testing.T) { { name: "adds cloud.namespace attribute for Beanstalk", addCloudNamespace: true, - createTraces: func() pdata.Traces { - inputTraces := pdata.NewTraces() + createTraces: func() ptrace.Traces { + inputTraces := ptrace.NewTraces() inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_elastic_beanstalk") return inputTraces }, - test: func(outputTraces pdata.Traces) { + test: func(outputTraces ptrace.Traces) { cloudNamespaceAttribute, found := outputTraces.ResourceSpans().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "ElasticBeanstalk", cloudNamespaceAttribute.StringVal()) @@ -331,15 +333,15 @@ func TestAddCloudNamespaceForTraces(t *testing.T) { { name: "does not add cloud.namespace attribute for unknown cloud.platform attribute values", addCloudNamespace: false, - createTraces: func() pdata.Traces { - inputTraces := pdata.NewTraces() + createTraces: func() ptrace.Traces { + inputTraces := ptrace.NewTraces() inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_eks") inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_lambda") inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "azure_vm") inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "gcp_app_engine") return inputTraces }, - test: func(outputTraces pdata.Traces) { + test: func(outputTraces ptrace.Traces) { for i := 0; i < outputTraces.ResourceSpans().Len(); i++ { _, found := outputTraces.ResourceSpans().At(i).Resource().Attributes().Get("cloud.namespace") assert.False(t, found) @@ -349,12 +351,12 @@ func TestAddCloudNamespaceForTraces(t *testing.T) { { name: "does not add cloud.namespce attribute when disabled", addCloudNamespace: false, - createTraces: func() pdata.Traces { - inputTraces := pdata.NewTraces() + createTraces: func() ptrace.Traces { + inputTraces := ptrace.NewTraces() inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") return inputTraces }, - test: func(outputTraces pdata.Traces) { + test: func(outputTraces ptrace.Traces) { cloudNamespaceAttribute, found := outputTraces.ResourceSpans().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", cloudNamespaceAttribute.StringVal()) @@ -363,15 +365,15 @@ func TestAddCloudNamespaceForTraces(t *testing.T) { { name: "adds different cloud.namespace attributes to different resources", addCloudNamespace: true, - createTraces: func() pdata.Traces { - inputTraces := pdata.NewTraces() + createTraces: func() ptrace.Traces { + inputTraces := ptrace.NewTraces() inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ec2") inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_lambda") inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_ecs") inputTraces.ResourceSpans().AppendEmpty().Resource().Attributes().InsertString("cloud.platform", "aws_elastic_beanstalk") return inputTraces }, - test: func(outputTraces pdata.Traces) { + test: func(outputTraces ptrace.Traces) { ec2ResourceAttribute, found := outputTraces.ResourceSpans().At(0).Resource().Attributes().Get("cloud.namespace") assert.True(t, found) assert.Equal(t, "aws/ec2", ec2ResourceAttribute.StringVal()) diff --git a/pkg/processor/sumologicsyslogprocessor/go.mod b/pkg/processor/sumologicsyslogprocessor/go.mod index 64a22f52b6..f7f5529992 100644 --- a/pkg/processor/sumologicsyslogprocessor/go.mod +++ b/pkg/processor/sumologicsyslogprocessor/go.mod @@ -4,23 +4,22 @@ go 1.18 require ( github.com/stretchr/testify v1.7.1 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/pdata v0.49.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/cast v1.4.1 // indirect go.opencensus.io v0.23.0 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect diff --git a/pkg/processor/sumologicsyslogprocessor/go.sum b/pkg/processor/sumologicsyslogprocessor/go.sum index 4dc9153ae2..5b51acc380 100644 --- a/pkg/processor/sumologicsyslogprocessor/go.sum +++ b/pkg/processor/sumologicsyslogprocessor/go.sum @@ -15,7 +15,7 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -68,7 +68,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -98,8 +97,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -139,8 +138,6 @@ github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8d github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -155,20 +152,18 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0 h1:li8u9OSMvLau7rMs8bmiL82OazG6MAkwPz2i6eS8TBQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0 h1:woM+Mb4d0A+Dxa3rYPenSN5ZeS9qHUvE8rlObiLRXTY= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -200,7 +195,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -222,7 +217,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pkg/processor/sumologicsyslogprocessor/processor.go b/pkg/processor/sumologicsyslogprocessor/processor.go index 7a576274e2..37935d5f21 100644 --- a/pkg/processor/sumologicsyslogprocessor/processor.go +++ b/pkg/processor/sumologicsyslogprocessor/processor.go @@ -20,7 +20,7 @@ import ( "regexp" "strconv" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) // tailSamplingSpanProcessor handles the incoming trace data and uses the given sampling @@ -76,7 +76,7 @@ func newSumologicSyslogProcessor(cfg *Config) (*sumologicSyslogProcessor, error) // ProcessLogs tries to extract facility number from log syslog line and maps it to facility name. // Facility is taken as $number/8 rounded down, where log looks like `^<$number> .*` -func (ssp *sumologicSyslogProcessor) ProcessLogs(ctx context.Context, ld pdata.Logs) (pdata.Logs, error) { +func (ssp *sumologicSyslogProcessor) ProcessLogs(ctx context.Context, ld plog.Logs) (plog.Logs, error) { // Iterate over ResourceLogs rls := ld.ResourceLogs() for i := 0; i < rls.Len(); i++ { diff --git a/pkg/processor/sumologicsyslogprocessor/processor_test.go b/pkg/processor/sumologicsyslogprocessor/processor_test.go index 6aa6964b1b..5979af00fc 100644 --- a/pkg/processor/sumologicsyslogprocessor/processor_test.go +++ b/pkg/processor/sumologicsyslogprocessor/processor_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/plog" ) func TestProcessLogs(t *testing.T) { @@ -37,7 +37,7 @@ func TestProcessLogs(t *testing.T) { `syslog`, } - logs := pdata.NewLogs() + logs := plog.NewLogs() rls := logs.ResourceLogs().AppendEmpty() rls.InstrumentationLibraryLogs().EnsureCapacity(len(lines)) ills := rls.InstrumentationLibraryLogs().AppendEmpty() diff --git a/pkg/receiver/telegrafreceiver/README.md b/pkg/receiver/telegrafreceiver/README.md index 29163c1160..7d1f6c5117 100644 --- a/pkg/receiver/telegrafreceiver/README.md +++ b/pkg/receiver/telegrafreceiver/README.md @@ -56,8 +56,8 @@ With its current implementation Telegraf receiver has the following limitations: from input plugin to the receiver for translation (into otc data model) without any processing - only the following Telegraf metric data types are supported: - - `telegraf.Gauge` that is translated to `pdata.MetricDataTypeGauge`, - - `telegraf.Counter` that is translated to `pdata.MetricDataTypeSum`. + - `telegraf.Gauge` that is translated to `pmetric.MetricDataTypeGauge`, + - `telegraf.Counter` that is translated to `pmetric.MetricDataTypeSum`. ## Migration from Telegraf diff --git a/pkg/receiver/telegrafreceiver/converter.go b/pkg/receiver/telegrafreceiver/converter.go index 1704bdbf51..a8b08d36e1 100644 --- a/pkg/receiver/telegrafreceiver/converter.go +++ b/pkg/receiver/telegrafreceiver/converter.go @@ -18,7 +18,7 @@ import ( "fmt" "github.com/influxdata/telegraf" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" ) @@ -27,7 +27,7 @@ const ( ) type MetricConverter interface { - Convert(telegraf.Metric) (pdata.Metrics, error) + Convert(telegraf.Metric) (pmetric.Metrics, error) } type metricConverter struct { @@ -42,9 +42,9 @@ func newConverter(separateField bool, logger *zap.Logger) MetricConverter { } } -// Convert converts telegraf.Metric to pdata.Metrics. -func (mc metricConverter) Convert(m telegraf.Metric) (pdata.Metrics, error) { - ms := pdata.NewMetrics() +// Convert converts telegraf.Metric to pmetric.Metrics. +func (mc metricConverter) Convert(m telegraf.Metric) (pmetric.Metrics, error) { + ms := pmetric.NewMetrics() rms := ms.ResourceMetrics() rm := rms.AppendEmpty() @@ -130,27 +130,27 @@ func (mc metricConverter) Convert(m telegraf.Metric) (pdata.Metrics, error) { } case telegraf.Summary: - return pdata.Metrics{}, fmt.Errorf("unsupported metric type: telegraf.Summary") + return pmetric.Metrics{}, fmt.Errorf("unsupported metric type: telegraf.Summary") case telegraf.Histogram: - return pdata.Metrics{}, fmt.Errorf("unsupported metric type: telegraf.Histogram") + return pmetric.Metrics{}, fmt.Errorf("unsupported metric type: telegraf.Histogram") default: - return pdata.Metrics{}, fmt.Errorf("unknown metric type: %T", t) + return pmetric.Metrics{}, fmt.Errorf("unknown metric type: %T", t) } return ms, nil } -// convertToGauge returns a pdata.Metric gauge converted from telegraf metric, +// convertToGauge returns a pmetric.Metric gauge converted from telegraf metric, // based on provided metric name, field and metric options which are passed // to metric constructors to manipulate the created metric in a functional manner. -func (mc metricConverter) convertToGauge(name string, f *telegraf.Field, opts ...MetricOpt) (pdata.Metric, error) { +func (mc metricConverter) convertToGauge(name string, f *telegraf.Field, opts ...MetricOpt) (pmetric.Metric, error) { if mc.separateField { opts = append(opts, WithField(f.Key)) } opts = append(opts, WithName(mc.createMetricName(name, f.Key))) - var pm pdata.Metric + var pm pmetric.Metric switch v := f.Value.(type) { case float64: pm = newDoubleGauge(v, opts...) @@ -174,16 +174,16 @@ func (mc metricConverter) convertToGauge(name string, f *telegraf.Field, opts .. return pm, nil } -// convertToGauge returns a pdata.Metric sum converted from telegraf metric, +// convertToGauge returns a pmetric.Metric sum converted from telegraf metric, // based on provided metric name, field and metric options which are passed // to metric constructors to manipulate the created metric in a functional manner. -func (mc metricConverter) convertToSum(name string, f *telegraf.Field, opts ...MetricOpt) (pdata.Metric, error) { +func (mc metricConverter) convertToSum(name string, f *telegraf.Field, opts ...MetricOpt) (pmetric.Metric, error) { if mc.separateField { opts = append(opts, WithField(f.Key)) } opts = append(opts, WithName(mc.createMetricName(name, f.Key))) - var pm pdata.Metric + var pm pmetric.Metric switch v := f.Value.(type) { case float64: pm = newDoubleSum(v, opts...) @@ -222,14 +222,14 @@ func (mc metricConverter) createMetricName(name string, field string) string { func newDoubleSum( value float64, opts ...MetricOpt, -) pdata.Metric { - pm := pdata.NewMetric() - pm.SetDataType(pdata.MetricDataTypeSum) +) pmetric.Metric { + pm := pmetric.NewMetric() + pm.SetDataType(pmetric.MetricDataTypeSum) // "[...] OTLP Sum is either translated into a Timeseries Counter, when // the sum is monotonic, or a Gauge when the sum is not monotonic." // https://github.com/open-telemetry/opentelemetry-specification/blob/7fc28733/specification/metrics/datamodel.md#opentelemetry-protocol-data-model ds := pm.Sum() - ds.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative) + ds.SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative) ds.SetIsMonotonic(true) dps := ds.DataPoints() dp := dps.AppendEmpty() @@ -244,14 +244,14 @@ func newDoubleSum( func newIntSum( value int64, opts ...MetricOpt, -) pdata.Metric { - pm := pdata.NewMetric() - pm.SetDataType(pdata.MetricDataTypeSum) +) pmetric.Metric { + pm := pmetric.NewMetric() + pm.SetDataType(pmetric.MetricDataTypeSum) // "[...] OTLP Sum is either translated into a Timeseries Counter, when // the sum is monotonic, or a Gauge when the sum is not monotonic." // https://github.com/open-telemetry/opentelemetry-specification/blob/7fc28733/specification/metrics/datamodel.md#opentelemetry-protocol-data-model ds := pm.Sum() - ds.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative) + ds.SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative) ds.SetIsMonotonic(true) dps := ds.DataPoints() dp := dps.AppendEmpty() @@ -266,9 +266,9 @@ func newIntSum( func newDoubleGauge( value float64, opts ...MetricOpt, -) pdata.Metric { - pm := pdata.NewMetric() - pm.SetDataType(pdata.MetricDataTypeGauge) +) pmetric.Metric { + pm := pmetric.NewMetric() + pm.SetDataType(pmetric.MetricDataTypeGauge) dps := pm.Gauge().DataPoints() dp := dps.AppendEmpty() dp.SetDoubleVal(value) @@ -282,9 +282,9 @@ func newDoubleGauge( func newIntGauge( value int64, opts ...MetricOpt, -) pdata.Metric { - pm := pdata.NewMetric() - pm.SetDataType(pdata.MetricDataTypeGauge) +) pmetric.Metric { + pm := pmetric.NewMetric() + pm.SetDataType(pmetric.MetricDataTypeGauge) dps := pm.Gauge().DataPoints() dp := dps.AppendEmpty() dp.SetIntVal(value) diff --git a/pkg/receiver/telegrafreceiver/converter_test.go b/pkg/receiver/telegrafreceiver/converter_test.go index f74af8735c..a5c09669e8 100644 --- a/pkg/receiver/telegrafreceiver/converter_test.go +++ b/pkg/receiver/telegrafreceiver/converter_test.go @@ -22,7 +22,8 @@ import ( "github.com/influxdata/telegraf/metric" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" ) @@ -34,7 +35,7 @@ func TestConverter(t *testing.T) { metricsFn func() telegraf.Metric separateField bool expectedErr bool - expectedFn func() pdata.MetricSlice + expectedFn func() pmetric.MetricSlice }{ { name: "gauge_int_with_one_field", @@ -46,8 +47,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(39097651200, WithName("mem_available"), @@ -66,8 +67,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(39097651200, WithName("mem"), WithField("available"), @@ -90,8 +91,8 @@ func TestConverter(t *testing.T) { // } // return metric.New("mem", tags, fields, tim, telegraf.Gauge) // }, - // expectedFn: func() pdata.MetricSlice { - // metrics := pdata.NewMetricSlice() + // expectedFn: func() pmetric.MetricSlice { + // metrics := pmetric.NewMetricSlice() // metrics.Append( // newIntGauge(39097651200, // WithName("mem_available"), @@ -112,8 +113,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newDoubleGauge(54.505050, WithName("mem_available_percent"), WithTime(tim), @@ -131,8 +132,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newDoubleGauge(54.505050, WithName("mem"), WithField("available_percent"), @@ -155,8 +156,8 @@ func TestConverter(t *testing.T) { // } // return metric.New("mem", tags, fields, tim, telegraf.Gauge) // }, - // expectedFn: func() pdata.MetricSlice { - // metrics := pdata.NewMetricSlice() + // expectedFn: func() pmetric.MetricSlice { + // metrics := pmetric.NewMetricSlice() // metrics.Append( // newDoubleGauge(54.505050, // WithName("mem_available_percent"), @@ -179,8 +180,8 @@ func TestConverter(t *testing.T) { } return metric.New("mem", tags, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newDoubleGauge(54.505050, WithName("mem_available_percent"), WithTime(tim), @@ -202,8 +203,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(39097651200, WithName("mem_available"), WithTime(tim), @@ -238,8 +239,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Gauge) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(39097651200, WithName("mem"), WithField("available"), @@ -263,8 +264,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Counter) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntSum(39097651200, WithName("mem_available"), WithTime(tim), @@ -282,8 +283,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Counter) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntSum(39097651200, WithName("mem"), WithField("available"), @@ -306,8 +307,8 @@ func TestConverter(t *testing.T) { // } // return metric.New("mem", tags, fields, tim, telegraf.Counter) // }, - // expectedFn: func() pdata.MetricSlice { - // metrics := pdata.NewMetricSlice() + // expectedFn: func() pmetric.MetricSlice { + // metrics := pmetric.NewMetricSlice() // metrics.Append( // newIntSum(39097651200, // WithName("mem_available"), @@ -334,8 +335,8 @@ func TestConverter(t *testing.T) { // } // return metric.New("mem", tags, fields, tim, telegraf.Counter) // }, - // expectedFn: func() pdata.MetricSlice { - // metrics := pdata.NewMetricSlice() + // expectedFn: func() pmetric.MetricSlice { + // metrics := pmetric.NewMetricSlice() // metrics.Append( // newIntSum(39097651200, // WithName("mem_available"), @@ -358,8 +359,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Counter) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newDoubleSum(39097651200.123, WithName("mem_available"), WithTime(tim), @@ -377,8 +378,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Counter) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newDoubleSum(39097651200.123, WithName("mem"), WithField("available"), @@ -401,8 +402,8 @@ func TestConverter(t *testing.T) { // } // return metric.New("mem", tags, fields, tim, telegraf.Counter) // }, - // expectedFn: func() pdata.MetricSlice { - // metrics := pdata.NewMetricSlice() + // expectedFn: func() pmetric.MetricSlice { + // metrics := pmetric.NewMetricSlice() // metrics.Append( // newDoubleSum(39097651200.123, // WithName("mem"), @@ -427,8 +428,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Counter) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntSum(39097651200, WithName("mem_available"), WithTime(tim), @@ -459,8 +460,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Counter) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntSum(39097651200, WithName("mem"), WithField("available"), @@ -484,8 +485,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Untyped) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(39097651200, WithName("mem_available"), WithTime(tim), @@ -503,8 +504,8 @@ func TestConverter(t *testing.T) { return metric.New("mem", nil, fields, tim, telegraf.Untyped) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newDoubleGauge(43.10542941093445, WithName("mem_used_percent"), WithTime(tim), @@ -522,8 +523,8 @@ func TestConverter(t *testing.T) { return metric.New("cpu", nil, fields, tim, telegraf.Untyped) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(0, WithName("cpu_throttling_supported"), WithTime(tim), @@ -541,8 +542,8 @@ func TestConverter(t *testing.T) { return metric.New("cpu", nil, fields, tim, telegraf.Untyped) }, - expectedFn: func() pdata.MetricSlice { - metrics := pdata.NewMetricSlice() + expectedFn: func() pmetric.MetricSlice { + metrics := pmetric.NewMetricSlice() newIntGauge(1, WithName("cpu_throttling_supported"), WithTime(tim), @@ -581,14 +582,14 @@ func TestConverter(t *testing.T) { } } -func assertResourceAttributes(t *testing.T, tags []*telegraf.Tag, resource pdata.Resource) { - resource.Attributes().Range(func(k string, v pdata.AttributeValue) bool { +func assertResourceAttributes(t *testing.T, tags []*telegraf.Tag, resource pcommon.Resource) { + resource.Attributes().Range(func(k string, v pcommon.Value) bool { var found bool for _, tag := range tags { if k != tag.Key { continue } - if assert.Equal(t, pdata.AttributeValueTypeString, v.Type()) { + if assert.Equal(t, pcommon.ValueTypeString, v.Type()) { if assert.Equal(t, tag.Value, v.StringVal()) { found = true } @@ -600,7 +601,7 @@ func assertResourceAttributes(t *testing.T, tags []*telegraf.Tag, resource pdata }) } -func pdataMetricSlicesAreEqual(t *testing.T, expected, actual pdata.MetricSlice) { +func pdataMetricSlicesAreEqual(t *testing.T, expected, actual pmetric.MetricSlice) { for i := 0; i < expected.Len(); i++ { em := expected.At(i) eName := em.Name() @@ -629,9 +630,9 @@ func pdataMetricSlicesAreEqual(t *testing.T, expected, actual pdata.MetricSlice) // assertEqualDataPointsWithLabels checks that provided metrics have the same // data points with the same set of labels. -func assertEqualDataPointsWithLabels(t *testing.T, em pdata.Metric, am pdata.Metric) { +func assertEqualDataPointsWithLabels(t *testing.T, em pmetric.Metric, am pmetric.Metric) { switch em.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: edps := em.Gauge().DataPoints() adps := am.Gauge().DataPoints() assert.Equal(t, edps.Len(), adps.Len()) @@ -641,7 +642,7 @@ func assertEqualDataPointsWithLabels(t *testing.T, em pdata.Metric, am pdata.Met assert.Equal(t, expected.DoubleVal(), actual.DoubleVal()) assertEqualDataPoints(t, am.Name(), expected, actual) } - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: edps := em.Sum().DataPoints() adps := am.Sum().DataPoints() assert.Equal(t, edps.Len(), adps.Len()) @@ -655,12 +656,12 @@ func assertEqualDataPointsWithLabels(t *testing.T, em pdata.Metric, am pdata.Met } type DataPoint interface { - Timestamp() pdata.Timestamp - StartTimestamp() pdata.Timestamp - LabelsMap() pdata.AttributeMap + Timestamp() pcommon.Timestamp + StartTimestamp() pcommon.Timestamp + LabelsMap() pcommon.Map } -func assertEqualDataPoints(t *testing.T, metricName string, expected, actual pdata.NumberDataPoint) { +func assertEqualDataPoints(t *testing.T, metricName string, expected, actual pmetric.NumberDataPoint) { // NOTE: cannot compare values due to different return types of Value() // func for different metric types. // assert.Equal(t, edp.Value(), adp.Value()) @@ -679,7 +680,7 @@ func assertEqualDataPoints(t *testing.T, metricName string, expected, actual pda // assert.Equal(t, edp.LabelsMap().Sort(), adp.LabelsMap().Sort()) } -func pdataMetricSlicesWithFieldsAreEqual(t *testing.T, expected, actual pdata.MetricSlice) { +func pdataMetricSlicesWithFieldsAreEqual(t *testing.T, expected, actual pmetric.MetricSlice) { for i := 0; i < expected.Len(); i++ { em := expected.At(i) eName := em.Name() @@ -688,7 +689,7 @@ func pdataMetricSlicesWithFieldsAreEqual(t *testing.T, expected, actual pdata.Me // assert the fields for ef := range eFields { am, ok := metricSliceContainsMetricWithField(actual, eName, ef) - if assert.True(t, ok, "pdata.MetricSlice doesn't contain %s", eName) { + if assert.True(t, ok, "pmetric.MetricSlice doesn't contain %s", eName) { t.Logf("expected field name %s", ef) adp, ok := fieldFromMetric(am, ef) @@ -701,15 +702,15 @@ func pdataMetricSlicesWithFieldsAreEqual(t *testing.T, expected, actual pdata.Me } } -// metricSliceContainsMetricWithField searches through metrics in pdata.MetricSlice -// and return the pdata.Metric that contains the requested field and a flag +// metricSliceContainsMetricWithField searches through metrics in pmetric.MetricSlice +// and return the pmetric.Metric that contains the requested field and a flag // whether such a metric was found. -func metricSliceContainsMetricWithField(ms pdata.MetricSlice, name string, field string) (pdata.Metric, bool) { +func metricSliceContainsMetricWithField(ms pmetric.MetricSlice, name string, field string) (pmetric.Metric, bool) { for i := 0; i < ms.Len(); i++ { m := ms.At(i) if m.Name() == name { switch m.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: mg := m.Gauge() dps := mg.DataPoints() for i := 0; i < dps.Len(); i++ { @@ -727,14 +728,14 @@ func metricSliceContainsMetricWithField(ms pdata.MetricSlice, name string, field } } - return pdata.Metric{}, false + return pmetric.Metric{}, false } // getFieldsFromMetric returns a map of fields in a metric gathered from all // data points' label maps. -func getFieldsFromMetric(m pdata.Metric) map[string]struct{} { +func getFieldsFromMetric(m pmetric.Metric) map[string]struct{} { switch m.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: ret := make(map[string]struct{}) for i := 0; i < m.Gauge().DataPoints().Len(); i++ { dp := m.Gauge().DataPoints().At(i) @@ -751,11 +752,11 @@ func getFieldsFromMetric(m pdata.Metric) map[string]struct{} { } } -// fieldFromMetric searches through pdata.Metric's data points to find +// fieldFromMetric searches through pmetric.Metric's data points to find // a particular field. -func fieldFromMetric(m pdata.Metric, field string) (pdata.NumberDataPoint, bool) { +func fieldFromMetric(m pmetric.Metric, field string) (pmetric.NumberDataPoint, bool) { switch m.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: dps := m.Gauge().DataPoints() for i := 0; i < dps.Len(); i++ { dp := dps.At(i) @@ -770,8 +771,8 @@ func fieldFromMetric(m pdata.Metric, field string) (pdata.NumberDataPoint, bool) } default: - return pdata.NumberDataPoint{}, false + return pmetric.NumberDataPoint{}, false } - return pdata.NumberDataPoint{}, false + return pmetric.NumberDataPoint{}, false } diff --git a/pkg/receiver/telegrafreceiver/go.mod b/pkg/receiver/telegrafreceiver/go.mod index 47179fac8e..ff5468c0f9 100644 --- a/pkg/receiver/telegrafreceiver/go.mod +++ b/pkg/receiver/telegrafreceiver/go.mod @@ -3,11 +3,11 @@ module github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/telegrafreceiv go 1.18 require ( - github.com/cenkalti/backoff/v4 v4.1.2 + github.com/cenkalti/backoff/v4 v4.1.3 github.com/influxdata/telegraf v1.22.0 github.com/stretchr/testify v1.7.1 - go.opentelemetry.io/collector v0.48.0 - go.opentelemetry.io/collector/model v0.48.0 + go.opentelemetry.io/collector v0.49.0 + go.opentelemetry.io/collector/pdata v0.49.0 go.uber.org/zap v1.21.0 ) @@ -42,7 +42,7 @@ require ( github.com/doclambda/protobufquery v0.0.0-20210317203640-88ffabe06a60 // indirect github.com/fatih/color v1.10.0 // indirect github.com/frankban/quicktest v1.14.2 // indirect - github.com/go-logfmt/logfmt v0.5.0 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-ping/ping v0.0.0-20210201095549-52eed920f98c // indirect github.com/go-redis/redis v6.15.9+incompatible // indirect @@ -79,7 +79,7 @@ require ( github.com/karrick/godirwalk v1.16.1 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.15.1 // indirect - github.com/knadh/koanf v1.4.0 // indirect + github.com/knadh/koanf v1.4.1 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.12 // indirect @@ -98,19 +98,18 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/prometheus v1.8.2-0.20210430082741-2a4b8e12bbf2 // indirect - github.com/shirou/gopsutil/v3 v3.22.2 // indirect + github.com/shirou/gopsutil/v3 v3.22.3 // indirect github.com/sirupsen/logrus v1.8.1 // indirect github.com/sleepinggenius2/gosmi v0.4.4 // indirect - github.com/spf13/cast v1.4.1 // indirect github.com/stretchr/objx v0.2.0 // indirect github.com/tidwall/gjson v1.10.2 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/tinylib/msgp v1.1.6 // indirect - github.com/tklauser/go-sysconf v0.3.9 // indirect - github.com/tklauser/numcpus v0.3.0 // indirect + github.com/tklauser/go-sysconf v0.3.10 // indirect + github.com/tklauser/numcpus v0.4.0 // indirect github.com/vjeantet/grok v1.0.1 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.0 // indirect @@ -118,15 +117,15 @@ require ( github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect go.mongodb.org/mongo-driver v1.8.4 // indirect - go.opentelemetry.io/otel v1.6.1 // indirect - go.opentelemetry.io/otel/metric v0.28.0 // indirect - go.opentelemetry.io/otel/trace v1.6.1 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect + go.opentelemetry.io/otel/metric v0.29.0 // indirect + go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect golang.org/x/mod v0.5.1 // indirect - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect - golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect + golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect + golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect golang.org/x/text v0.3.7 // indirect diff --git a/pkg/receiver/telegrafreceiver/go.sum b/pkg/receiver/telegrafreceiver/go.sum index 183742d805..42c6601bca 100644 --- a/pkg/receiver/telegrafreceiver/go.sum +++ b/pkg/receiver/telegrafreceiver/go.sum @@ -197,11 +197,12 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= -github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -438,11 +439,13 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= @@ -691,8 +694,8 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51 github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -870,6 +873,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= @@ -898,8 +902,8 @@ github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= -github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= -github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= +github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1006,6 +1010,7 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= @@ -1139,6 +1144,7 @@ github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83A github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -1160,8 +1166,9 @@ github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.23.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= +github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/exporter-toolkit v0.5.1/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -1176,6 +1183,7 @@ github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4 github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/prometheus v1.8.2-0.20210430082741-2a4b8e12bbf2 h1:AHi2TGs09Mv4v688/bjcY2PfAcu9+p4aPvsgVQ4nYDk= github.com/prometheus/prometheus v1.8.2-0.20210430082741-2a4b8e12bbf2/go.mod h1:5aBj+GpLB+V5MCnrKm5+JAqEJwzDiLugOmDhgt7sDec= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= @@ -1207,8 +1215,8 @@ github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvW github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks= -github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shirou/gopsutil/v3 v3.22.3 h1:UebRzEomgMpv61e3hgD1tGooqX5trFbdU/ehphbHd00= +github.com/shirou/gopsutil/v3 v3.22.3/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -1237,8 +1245,6 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= @@ -1283,10 +1289,10 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw= github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= -github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= -github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= -github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -1364,18 +1370,16 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.48.0 h1:/kUmNzsYgdPmbdscOGtCFPyZvxICrzmCFth2krzJuWs= -go.opentelemetry.io/collector v0.48.0/go.mod h1:iklh3+Npx1DalC6PvEi9ysjx9zLbjgOUQFTIh2MufQU= -go.opentelemetry.io/collector/model v0.48.0 h1:xmN4LdZ92q6PZnaKhMdIlC5KGtPJeOYaWCnA1PQ2oZw= -go.opentelemetry.io/collector/model v0.48.0/go.mod h1:1QVYv8TqsTMt9wVC5BUF9fqMVtk2C5EclWDnuVqdKoU= -go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= -go.opentelemetry.io/otel v1.6.1 h1:6r1YrcTenBvYa1x491d0GGpTVBsNECmrc/K6b+zDeis= -go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= -go.opentelemetry.io/otel/metric v0.28.0 h1:o5YNh+jxACMODoAo1bI7OES0RUW4jAMae0Vgs2etWAQ= -go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= -go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= -go.opentelemetry.io/otel/trace v1.6.1 h1:f8c93l5tboBYZna1nWk0W9DYyMzJXDWdZcJZ0Kb400U= -go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/collector v0.49.0 h1:brKMIUwlL1bt0Faxqqxvj7549KWm9FEN77Z4i4RAlDE= +go.opentelemetry.io/collector v0.49.0/go.mod h1:ErYGC1VzzrpK/uM134DJIbARX3jl9vtTqgIXsiWxjGE= +go.opentelemetry.io/collector/pdata v0.49.0 h1:aYj5rOlRC0x7lGXbc185LMsMMoY/pjOTXr5s1O2SzXs= +go.opentelemetry.io/collector/pdata v0.49.0/go.mod h1:YwmKuiFhNgtmhRdpi8Q8FAWPa0AwJTCSlssSsAtuRcY= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujXOS4jKc= +go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -1533,8 +1537,9 @@ golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1548,8 +1553,8 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b h1:clP8eMhB30EHdc0bd2Twtq6kgU7yl5ub2cQLSdrv1Dg= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1665,13 +1670,14 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/pkg/receiver/telegrafreceiver/metric_opt.go b/pkg/receiver/telegrafreceiver/metric_opt.go index 2354415c38..e00910d884 100644 --- a/pkg/receiver/telegrafreceiver/metric_opt.go +++ b/pkg/receiver/telegrafreceiver/metric_opt.go @@ -18,15 +18,16 @@ import ( "time" "github.com/influxdata/telegraf" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" ) -// MetricOpt is an option func that takes in a pdata.Metric and manipulates it. -type MetricOpt func(m pdata.Metric) +// MetricOpt is an option func that takes in a pmetric.Metric and manipulates it. +type MetricOpt func(m pmetric.Metric) // WithName returns a MetricOpt which will set the returned metric name. func WithName(name string) MetricOpt { - return func(m pdata.Metric) { + return func(m pmetric.Metric) { m.SetName(name) } } @@ -39,18 +40,18 @@ func dataPointTimeOpt(t time.Time) TimeOpt { // WithTime returns a MetricOpt which will set the returned metric's timestamp. func WithTime(t time.Time) MetricOpt { - return func(m pdata.Metric) { + return func(m pmetric.Metric) { opts := options{ timeopt: dataPointTimeOpt(t), } switch m.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: handleDataPoints( m.Gauge().DataPoints(), opts, ) - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: handleDataPoints( m.Sum().DataPoints(), opts, @@ -63,12 +64,12 @@ func WithTime(t time.Time) MetricOpt { // field tag to the specified one. func WithField(field string) MetricOpt { f := WithTag(&telegraf.Tag{Key: fieldLabel, Value: field}) - return func(m pdata.Metric) { + return func(m pmetric.Metric) { f(m) } } -type AttributeMapOpt func(attributeMap pdata.AttributeMap) +type AttributeMapOpt func(attributeMap pcommon.Map) type TimeOpt func() time.Time type options struct { @@ -76,7 +77,7 @@ type options struct { timeopt TimeOpt } -func handleDataPoints(dps pdata.NumberDataPointSlice, opts options) { +func handleDataPoints(dps pmetric.NumberDataPointSlice, opts options) { for i := 0; i < dps.Len(); i++ { dp := dps.At(i) for _, opt := range opts.stringMapOpts { @@ -84,13 +85,13 @@ func handleDataPoints(dps pdata.NumberDataPointSlice, opts options) { } if opts.timeopt != nil { - dp.SetTimestamp(pdata.Timestamp(opts.timeopt().UnixNano())) + dp.SetTimestamp(pcommon.Timestamp(opts.timeopt().UnixNano())) } } } -func insertTagToPdataStringMapOpt(tag *telegraf.Tag) func(attributeMap pdata.AttributeMap) { - return func(sm pdata.AttributeMap) { +func insertTagToPdataStringMapOpt(tag *telegraf.Tag) func(attributeMap pcommon.Map) { + return func(sm pcommon.Map) { sm.InsertString(tag.Key, tag.Value) } } @@ -98,7 +99,7 @@ func insertTagToPdataStringMapOpt(tag *telegraf.Tag) func(attributeMap pdata.Att // WithTag returns a MetricOpt which will insert a specified telegraf tag into // all underlying data points' label maps. func WithTag(tag *telegraf.Tag) MetricOpt { - return func(m pdata.Metric) { + return func(m pmetric.Metric) { opts := options{ stringMapOpts: []AttributeMapOpt{ insertTagToPdataStringMapOpt(tag), @@ -106,13 +107,13 @@ func WithTag(tag *telegraf.Tag) MetricOpt { } switch m.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: handleDataPoints( m.Gauge().DataPoints(), opts, ) - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: handleDataPoints( m.Sum().DataPoints(), opts, @@ -121,8 +122,8 @@ func WithTag(tag *telegraf.Tag) MetricOpt { } } -func insertTagsToPdataStringMapOpt(tags []*telegraf.Tag) func(attributeMap pdata.AttributeMap) { - return func(sm pdata.AttributeMap) { +func insertTagsToPdataStringMapOpt(tags []*telegraf.Tag) func(attributeMap pcommon.Map) { + return func(sm pcommon.Map) { for _, tag := range tags { sm.InsertString(tag.Key, tag.Value) } @@ -132,7 +133,7 @@ func insertTagsToPdataStringMapOpt(tags []*telegraf.Tag) func(attributeMap pdata // WithTags returns a MetricOpt which will insert a list of telegraf tags into // all underlying data points' label maps. func WithTags(tags []*telegraf.Tag) MetricOpt { - return func(m pdata.Metric) { + return func(m pmetric.Metric) { opts := options{ stringMapOpts: []AttributeMapOpt{ insertTagsToPdataStringMapOpt(tags), @@ -140,12 +141,12 @@ func WithTags(tags []*telegraf.Tag) MetricOpt { } switch m.DataType() { - case pdata.MetricDataTypeGauge: + case pmetric.MetricDataTypeGauge: handleDataPoints( m.Gauge().DataPoints(), opts, ) - case pdata.MetricDataTypeSum: + case pmetric.MetricDataTypeSum: handleDataPoints( m.Sum().DataPoints(), opts, diff --git a/pkg/receiver/telegrafreceiver/receiver.go b/pkg/receiver/telegrafreceiver/receiver.go index bc71ac1714..e5970693e3 100644 --- a/pkg/receiver/telegrafreceiver/receiver.go +++ b/pkg/receiver/telegrafreceiver/receiver.go @@ -26,7 +26,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" ) @@ -89,10 +89,10 @@ func (r *telegrafreceiver) Start(ctx context.Context, host component.Host) error continue } - var ms pdata.Metrics + var ms pmetric.Metrics if ms, fErr = r.metricConverter.Convert(m); fErr != nil { r.logger.Error( - "Error converting telegraf.Metric to pdata.Metrics", + "Error converting telegraf.Metric to pmetric.Metrics", zap.Error(fErr), ) continue @@ -111,7 +111,7 @@ func (r *telegrafreceiver) Start(ctx context.Context, host component.Host) error } // Consume metrics and retry on recoverable errors -func (r *telegrafreceiver) consumeWithRetry(ctx context.Context, metrics pdata.Metrics) error { +func (r *telegrafreceiver) consumeWithRetry(ctx context.Context, metrics pmetric.Metrics) error { constantBackoff := backoff.WithMaxRetries(backoff.NewConstantBackOff(r.consumeRetryDelay), r.consumeMaxRetries) // retry handling according to https://github.com/open-telemetry/opentelemetry-collector/blob/master/component/receiver.go#L45 diff --git a/pkg/receiver/telegrafreceiver/receiver_test.go b/pkg/receiver/telegrafreceiver/receiver_test.go index 3864816e84..d8423c94c0 100644 --- a/pkg/receiver/telegrafreceiver/receiver_test.go +++ b/pkg/receiver/telegrafreceiver/receiver_test.go @@ -26,7 +26,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/model/pdata" + "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" "go.uber.org/zap/zapcore" "go.uber.org/zap/zaptest/observer" @@ -48,7 +48,7 @@ type countingErrorConsumer struct { CallCount int } -func (er *countingErrorConsumer) ConsumeMetrics(context.Context, pdata.Metrics) error { +func (er *countingErrorConsumer) ConsumeMetrics(context.Context, pmetric.Metrics) error { er.CallCount++ return er.err } @@ -87,7 +87,7 @@ func TestConsumeRetryOnRecoverableError(t *testing.T) { consumeMaxRetries: uint64(maxRetries), } - metrics := pdata.Metrics{} + metrics := pmetric.Metrics{} err := receiver.consumeWithRetry(ctx, metrics) assert.NotEqual(t, nil, err) assert.Equal(t, maxRetries+1, consumer.CallCount) @@ -109,7 +109,7 @@ func TestConsumeNoRetryOnPermanentError(t *testing.T) { consumeMaxRetries: 10, } - metrics := pdata.Metrics{} + metrics := pmetric.Metrics{} err := receiver.consumeWithRetry(ctx, metrics) assert.Error(t, err) assert.Equal(t, 1, consumer.CallCount)