Skip to content

Commit 1ad45b9

Browse files
codebotenatoulme
andauthored
[chore] remove utils package (#43643)
Moving funcs in use to different package Part of #41780 Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com> Co-authored-by: Antoine Toulme <atoulme@splunk.com>
1 parent e92b833 commit 1ad45b9

File tree

6 files changed

+7
-49
lines changed

6 files changed

+7
-49
lines changed

exporter/signalfxexporter/dpclient.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"go.uber.org/zap"
2323

2424
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation"
25-
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/utils"
2625
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
2726
)
2827

@@ -102,7 +101,7 @@ func (s *sfxDPClient) pushMetricsData(
102101

103102
// export any histograms in otlp if sendOTLPHistograms is true
104103
if s.sendOTLPHistograms {
105-
histogramData, metricCount := utils.GetHistograms(md)
104+
histogramData, metricCount := getHistograms(md)
106105
if metricCount > 0 {
107106
droppedCount, err := s.pushOTLPMetricsDataForToken(ctx, histogramData, metricToken)
108107
if err != nil {

exporter/signalfxexporter/exporter_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
componentmetadata "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/metadata"
4242
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation"
4343
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation/dpfilters"
44-
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/utils"
4544
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
4645
metadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata"
4746
)
@@ -2099,7 +2098,7 @@ func TestConsumeMixedMetrics(t *testing.T) {
20992098

21002099
if tt.wantThrottleErr {
21012100
if tt.wantPartialMetricsErr {
2102-
partialMetrics, _ := utils.GetHistograms(smallBatch)
2101+
partialMetrics, _ := getHistograms(smallBatch)
21032102
throttleErr := errors.New(errMsg)
21042103
throttleErr = exporterhelper.NewThrottleRetry(throttleErr, time.Duration(tt.retryAfter)*time.Second)
21052104
testErr := consumererror.NewMetrics(throttleErr, partialMetrics)

exporter/signalfxexporter/factory_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -656,29 +656,3 @@ func testReadJSON(f string, v any) error {
656656
}
657657
return json.Unmarshal(bytes, &v)
658658
}
659-
660-
func buildHistogramDP(dp pmetric.HistogramDataPoint, timestamp pcommon.Timestamp) {
661-
dp.SetStartTimestamp(timestamp)
662-
dp.SetTimestamp(timestamp)
663-
dp.SetMin(1.0)
664-
dp.SetMax(2)
665-
dp.SetCount(5)
666-
dp.SetSum(7.0)
667-
dp.BucketCounts().FromRaw([]uint64{3, 2})
668-
dp.ExplicitBounds().FromRaw([]float64{1, 2})
669-
dp.Attributes().PutStr("k1", "v1")
670-
}
671-
672-
func buildHistogram(im pmetric.Metric, name string, timestamp pcommon.Timestamp, dpCount int) {
673-
im.SetName(name)
674-
im.SetDescription("Histogram")
675-
im.SetUnit("1")
676-
im.SetEmptyHistogram().SetAggregationTemporality(pmetric.AggregationTemporalityDelta)
677-
idps := im.Histogram().DataPoints()
678-
idps.EnsureCapacity(dpCount)
679-
680-
for range dpCount {
681-
dp := idps.AppendEmpty()
682-
buildHistogramDP(dp, timestamp)
683-
}
684-
}

exporter/signalfxexporter/internal/utils/histogram_utils.go renamed to exporter/signalfxexporter/histogram_utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package utils // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/utils"
4+
package signalfxexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter"
55

66
import (
77
"go.opentelemetry.io/collector/pdata/pcommon"
@@ -76,10 +76,10 @@ func matchedHistogramMetrics(ilm pmetric.ScopeMetrics) (matchedMetricsIdx []int)
7676
return matchedMetricsIdx
7777
}
7878

79-
// GetHistograms returns new Metrics slice containing only Histogram metrics found in the input
79+
// getHistograms returns new Metrics slice containing only Histogram metrics found in the input
8080
// and the count of histogram metrics
8181
// This function also adds the host ID attribute to the resource if it can be derived from the resource attributes
82-
func GetHistograms(md pmetric.Metrics) (pmetric.Metrics, int) {
82+
func getHistograms(md pmetric.Metrics) (pmetric.Metrics, int) {
8383
matchedMetricsIdxes := matchedHistogramResourceMetrics(md)
8484
matchedRmCount := len(matchedMetricsIdxes)
8585
if matchedRmCount == 0 {

exporter/signalfxexporter/internal/utils/histogram_utils_test.go renamed to exporter/signalfxexporter/histogram_utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package utils
4+
package signalfxexporter
55

66
import (
77
"testing"
@@ -383,7 +383,7 @@ func TestHistogramsAreRetrieved(t *testing.T) {
383383
for _, tt := range tests {
384384
t.Run(tt.name, func(t *testing.T) {
385385
md := tt.inMetricsFunc()
386-
gotMetrics, gotCount := GetHistograms(md)
386+
gotMetrics, gotCount := getHistograms(md)
387387
assert.Equal(t, tt.wantMetricCount, gotCount)
388388
if tt.wantMetricCount == 0 {
389389
assert.Equal(t, tt.wantMetrics(), gotMetrics)

exporter/signalfxexporter/internal/utils/package_test.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)