diff --git a/exporter/signalfxexporter/dpclient.go b/exporter/signalfxexporter/dpclient.go index 90ea212e7fae0..0c097c9ec0e1e 100644 --- a/exporter/signalfxexporter/dpclient.go +++ b/exporter/signalfxexporter/dpclient.go @@ -22,7 +22,6 @@ import ( "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation" - "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/utils" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" ) @@ -102,7 +101,7 @@ func (s *sfxDPClient) pushMetricsData( // export any histograms in otlp if sendOTLPHistograms is true if s.sendOTLPHistograms { - histogramData, metricCount := utils.GetHistograms(md) + histogramData, metricCount := getHistograms(md) if metricCount > 0 { droppedCount, err := s.pushOTLPMetricsDataForToken(ctx, histogramData, metricToken) if err != nil { diff --git a/exporter/signalfxexporter/exporter_test.go b/exporter/signalfxexporter/exporter_test.go index ec498b9454ee0..d8fb00e0d06f4 100644 --- a/exporter/signalfxexporter/exporter_test.go +++ b/exporter/signalfxexporter/exporter_test.go @@ -41,7 +41,6 @@ import ( componentmetadata "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation/dpfilters" - "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/utils" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" metadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata" ) @@ -2099,7 +2098,7 @@ func TestConsumeMixedMetrics(t *testing.T) { if tt.wantThrottleErr { if tt.wantPartialMetricsErr { - partialMetrics, _ := utils.GetHistograms(smallBatch) + partialMetrics, _ := getHistograms(smallBatch) throttleErr := errors.New(errMsg) throttleErr = exporterhelper.NewThrottleRetry(throttleErr, time.Duration(tt.retryAfter)*time.Second) testErr := consumererror.NewMetrics(throttleErr, partialMetrics) diff --git a/exporter/signalfxexporter/factory_test.go b/exporter/signalfxexporter/factory_test.go index 2f2697c95ec58..ac2d57da078b9 100644 --- a/exporter/signalfxexporter/factory_test.go +++ b/exporter/signalfxexporter/factory_test.go @@ -656,29 +656,3 @@ func testReadJSON(f string, v any) error { } return json.Unmarshal(bytes, &v) } - -func buildHistogramDP(dp pmetric.HistogramDataPoint, timestamp pcommon.Timestamp) { - dp.SetStartTimestamp(timestamp) - dp.SetTimestamp(timestamp) - dp.SetMin(1.0) - dp.SetMax(2) - dp.SetCount(5) - dp.SetSum(7.0) - dp.BucketCounts().FromRaw([]uint64{3, 2}) - dp.ExplicitBounds().FromRaw([]float64{1, 2}) - dp.Attributes().PutStr("k1", "v1") -} - -func buildHistogram(im pmetric.Metric, name string, timestamp pcommon.Timestamp, dpCount int) { - im.SetName(name) - im.SetDescription("Histogram") - im.SetUnit("1") - im.SetEmptyHistogram().SetAggregationTemporality(pmetric.AggregationTemporalityDelta) - idps := im.Histogram().DataPoints() - idps.EnsureCapacity(dpCount) - - for range dpCount { - dp := idps.AppendEmpty() - buildHistogramDP(dp, timestamp) - } -} diff --git a/exporter/signalfxexporter/internal/utils/histogram_utils.go b/exporter/signalfxexporter/histogram_utils.go similarity index 95% rename from exporter/signalfxexporter/internal/utils/histogram_utils.go rename to exporter/signalfxexporter/histogram_utils.go index 9e1212cc41ffb..ab4151cdf81a4 100644 --- a/exporter/signalfxexporter/internal/utils/histogram_utils.go +++ b/exporter/signalfxexporter/histogram_utils.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package utils // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/utils" +package signalfxexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter" import ( "go.opentelemetry.io/collector/pdata/pcommon" @@ -76,10 +76,10 @@ func matchedHistogramMetrics(ilm pmetric.ScopeMetrics) (matchedMetricsIdx []int) return matchedMetricsIdx } -// GetHistograms returns new Metrics slice containing only Histogram metrics found in the input +// getHistograms returns new Metrics slice containing only Histogram metrics found in the input // and the count of histogram metrics // This function also adds the host ID attribute to the resource if it can be derived from the resource attributes -func GetHistograms(md pmetric.Metrics) (pmetric.Metrics, int) { +func getHistograms(md pmetric.Metrics) (pmetric.Metrics, int) { matchedMetricsIdxes := matchedHistogramResourceMetrics(md) matchedRmCount := len(matchedMetricsIdxes) if matchedRmCount == 0 { diff --git a/exporter/signalfxexporter/internal/utils/histogram_utils_test.go b/exporter/signalfxexporter/histogram_utils_test.go similarity index 99% rename from exporter/signalfxexporter/internal/utils/histogram_utils_test.go rename to exporter/signalfxexporter/histogram_utils_test.go index c752e129999d3..11fbd35e82269 100644 --- a/exporter/signalfxexporter/internal/utils/histogram_utils_test.go +++ b/exporter/signalfxexporter/histogram_utils_test.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package utils +package signalfxexporter import ( "testing" @@ -383,7 +383,7 @@ func TestHistogramsAreRetrieved(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { md := tt.inMetricsFunc() - gotMetrics, gotCount := GetHistograms(md) + gotMetrics, gotCount := getHistograms(md) assert.Equal(t, tt.wantMetricCount, gotCount) if tt.wantMetricCount == 0 { assert.Equal(t, tt.wantMetrics(), gotMetrics) diff --git a/exporter/signalfxexporter/internal/utils/package_test.go b/exporter/signalfxexporter/internal/utils/package_test.go deleted file mode 100644 index 832862afb8884..0000000000000 --- a/exporter/signalfxexporter/internal/utils/package_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package utils - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -}