From d1148bd4bb9e02d84b8c56de4f5d28bcb1d5bcf3 Mon Sep 17 00:00:00 2001 From: Yang Song Date: Thu, 18 Apr 2024 15:39:29 -0400 Subject: [PATCH] Fix breaking changes --- .../datadogexporter/metrics_exporter_test.go | 28 +++---------------- internal/datadog/agent.go | 3 +- internal/datadog/agent_test.go | 3 +- internal/datadog/go.mod | 4 --- internal/datadog/go.sum | 16 ----------- 5 files changed, 6 insertions(+), 48 deletions(-) diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 23e1401e8b65..5bf808913323 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -22,7 +22,6 @@ import ( "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata/payload" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" - "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" @@ -629,7 +628,10 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) { expectedErr: nil, }, { - metrics: createTestMetricsWithStats(t), + metrics: createTestMetrics(map[string]string{ + conventions.AttributeDeploymentEnvironment: "dev", + "custom_attribute": "custom_value", + }), source: source.Source{ Kind: source.HostnameKind, Identifier: "test-host", @@ -686,7 +688,6 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) { }, }, }, - expectedStats: testutil.StatsPayloads, }, } for _, tt := range tests { @@ -773,27 +774,6 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) { } } -func createTestMetricsWithStats(t *testing.T) pmetric.Metrics { - md := createTestMetrics(map[string]string{ - conventions.AttributeDeploymentEnvironment: "dev", - "custom_attribute": "custom_value", - }) - dest := md.ResourceMetrics() - set := componenttest.NewNopTelemetrySettings() - var err error - set.Logger, err = zap.NewDevelopment() - require.NoError(t, err) - attributesTranslator, err := attributes.NewTranslator(set) - require.NoError(t, err) - trans, err := metrics.NewTranslator(set, attributesTranslator) - require.NoError(t, err) - src := trans. - StatsPayloadToMetrics(&pb.StatsPayload{Stats: testutil.StatsPayloads}). - ResourceMetrics() - src.MoveAndAppendTo(dest) - return md -} - func createTestMetrics(additionalAttributes map[string]string) pmetric.Metrics { const ( host = "test-host" diff --git a/internal/datadog/agent.go b/internal/datadog/agent.go index 7bba14cad2cf..37971096218d 100644 --- a/internal/datadog/agent.go +++ b/internal/datadog/agent.go @@ -18,7 +18,6 @@ import ( "github.com/DataDog/datadog-agent/pkg/trace/telemetry" "github.com/DataDog/datadog-agent/pkg/trace/timing" "github.com/DataDog/datadog-go/v5/statsd" - "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "go.opentelemetry.io/collector/pdata/ptrace" ) @@ -54,7 +53,7 @@ func NewAgentWithConfig(ctx context.Context, cfg *traceconfig.AgentConfig, out c // in the exporter). In order to avoid duplicating the hostname setting in the processor and // exporter, we use a placeholder and fill it in later (in the Datadog Exporter or Agent OTLP // Ingest). This gives a better user experience. - cfg.Hostname = metrics.UnsetHostnamePlaceholder + cfg.Hostname = "__unset__" pchan := make(chan *api.Payload, 1000) a := agent.NewAgent(ctx, cfg, telemetry.NewNoopCollector(), metricsClient) // replace the Concentrator (the component which computes and flushes APM Stats from incoming diff --git a/internal/datadog/agent_test.go b/internal/datadog/agent_test.go index ebacc48598e8..c7787814fa16 100644 --- a/internal/datadog/agent_test.go +++ b/internal/datadog/agent_test.go @@ -12,7 +12,6 @@ import ( traceconfig "github.com/DataDog/datadog-agent/pkg/trace/config" "github.com/DataDog/datadog-agent/pkg/trace/testutil" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" - "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" ) @@ -26,7 +25,7 @@ func TestTraceAgentConfig(t *testing.T) { agnt := NewAgentWithConfig(context.Background(), cfg, out, metricClient, timingReporter) require.Zero(t, cfg.ReceiverPort) require.NotEmpty(t, cfg.Endpoints[0].APIKey) - require.Equal(t, metrics.UnsetHostnamePlaceholder, cfg.Hostname) + require.Equal(t, "__unset__", cfg.Hostname) require.Equal(t, out, agnt.Concentrator.Out) } diff --git a/internal/datadog/go.mod b/internal/datadog/go.mod index 75f69b6eae53..c39099b041d9 100644 --- a/internal/datadog/go.mod +++ b/internal/datadog/go.mod @@ -7,7 +7,6 @@ require ( github.com/DataDog/datadog-agent/pkg/trace v0.52.1-0.20240321095122-a3c5dbb936ae github.com/DataDog/datadog-go/v5 v5.5.0 github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.14.0 - github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.14.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.98.1-0.20240412014414-62f589864e3d go.opentelemetry.io/collector/pdata v1.5.1-0.20240412014414-62f589864e3d @@ -25,7 +24,6 @@ require ( github.com/DataDog/datadog-agent/pkg/util/scrubber v0.52.1-0.20240321095122-a3c5dbb936ae // indirect github.com/DataDog/go-sqllexer v0.0.9 // indirect github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect - github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.14.0 // indirect github.com/DataDog/sketches-go v1.4.4 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -57,7 +55,6 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/opencontainers/runtime-spec v1.1.0-rc.3 // indirect github.com/outcaste-io/ristretto v0.2.1 // indirect - github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/philhofer/fwd v1.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -82,7 +79,6 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect diff --git a/internal/datadog/go.sum b/internal/datadog/go.sum index 7b12dca70379..66f2ee399c2d 100644 --- a/internal/datadog/go.sum +++ b/internal/datadog/go.sum @@ -20,14 +20,8 @@ github.com/DataDog/go-sqllexer v0.0.9 h1:Cx2Cu1S0hfj4coCCA8hzjM9+UNFRkcu1avIV//R github.com/DataDog/go-sqllexer v0.0.9/go.mod h1:nB4Ea2YNsqMwtbWMc4Fm/oP98IIrSPapqwOwPioMspY= github.com/DataDog/go-tuf v1.0.2-0.5.2 h1:EeZr937eKAWPxJ26IykAdWA4A0jQXJgkhUjqEI/w7+I= github.com/DataDog/go-tuf v1.0.2-0.5.2/go.mod h1:zBcq6f654iVqmkk8n2Cx81E1JnNTMOAx1UEO/wZR+P0= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.14.0 h1:J0IEqkrB8BjtuDHofR8Q3J+Z8829Ja1Mlix9cyG8wJI= -github.com/DataDog/opentelemetry-mapping-go/pkg/internal/sketchtest v0.14.0/go.mod h1:66XlN7QpQKqIvw8e2UbCXV5X8wGnEw851nT9BjJ75dY= github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.14.0 h1:10TPqpTlIkmDPFWVIEZ4ZX3rWrCrx3rEoeoAooZr6LM= github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.14.0/go.mod h1:dvIWN9pA2zWNTw5rhDWZgzZnhcfpH++d+8d1SWW6xkY= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.14.0 h1:2Ou9n/048KM9E70G+LpJ4svBH2kOb8NkxwEqEGAamHo= -github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.14.0/go.mod h1:CAj5xIuF45abugAck7OzjMLH5y20ylaEj1qbQEjU1gk= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.14.0 h1:QHx6B/VUx3rZQqrQNZI5BfypbhhGSRzCz05viyJEQmM= -github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.14.0/go.mod h1:q4c7zbmdnIdSJNZuBsveTk5ZeRkSkS2g6b8zzFF1mE4= github.com/DataDog/sketches-go v1.4.4 h1:dF52vzXRFSPOj2IjXSWLvXq3jubL4CI69kwYjJ1w5Z8= github.com/DataDog/sketches-go v1.4.4/go.mod h1:XR0ns2RtEEF09mDKXiKZiQg+nfZStrq1ZuL1eezeZe0= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= @@ -101,8 +95,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lightstep/go-expohisto v1.0.0 h1:UPtTS1rGdtehbbAF7o/dhkWLTDI73UifG8LbfQI7cA4= -github.com/lightstep/go-expohisto v1.0.0/go.mod h1:xDXD0++Mu2FOaItXtdDfksfgxfV0z1TMPa+e/EUd0cs= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= @@ -115,16 +107,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.94.0 h1:nTayRLarCGkB9ld7p8jWJe/9wvf8gNDaS5fRjybkEpg= -github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.94.0/go.mod h1:xoBvqu56hbky3KZafo68nxtV2+J81+pvo1ttNirakcU= -github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.94.0 h1:DSGhzGAaC767esMB0Ulr+9xWe6SW0LFUYMxLrLOAkjM= -github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.94.0/go.mod h1:Nv4nK3E7sUpDbNv0zI0zY15g2xR4jMg+n8taV8dsMeE= github.com/opencontainers/runtime-spec v1.1.0-rc.3 h1:l04uafi6kxByhbxev7OWiuUv0LZxEsYUfDWZ6bztAuU= github.com/opencontainers/runtime-spec v1.1.0-rc.3/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/outcaste-io/ristretto v0.2.1 h1:KCItuNIGJZcursqHr3ghO7fc5ddZLEHspL9UR0cQM64= github.com/outcaste-io/ristretto v0.2.1/go.mod h1:W8HywhmtlopSB1jeMg3JtdIhf+DYkLAr0VN/s4+MHac= -github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -220,8 +206,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=