Skip to content

Commit

Permalink
Fix breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed Apr 18, 2024
1 parent ee1ca72 commit d1148bd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 48 deletions.
28 changes: 4 additions & 24 deletions exporter/datadogexporter/metrics_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -686,7 +688,6 @@ func Test_metricsExporter_PushMetricsData_Zorkian(t *testing.T) {
},
},
},
expectedStats: testutil.StatsPayloads,
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions internal/datadog/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions internal/datadog/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}

Expand Down
4 changes: 0 additions & 4 deletions internal/datadog/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 0 additions & 16 deletions internal/datadog/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d1148bd

Please sign in to comment.