Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/datadog] Decouple Config structs from internal components #8375

Merged
merged 4 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[exporter/datadog] Remove reference to Config on ProcessMetrics
  • Loading branch information
mx-psi committed Mar 10, 2022
commit ac59bafbc28d2a034d4c15fc2a20784322ea3b6e
4 changes: 1 addition & 3 deletions exporter/datadogexporter/internal/metrics/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (

"go.opentelemetry.io/collector/component"
"gopkg.in/zorkian/go-datadog-api.v2"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/config"
)

type MetricDataType string
Expand Down Expand Up @@ -94,7 +92,7 @@ func DefaultMetrics(exporterType string, hostname string, timestamp uint64, buil

// ProcessMetrics adds the hostname to the metric and prefixes it with the "otel"
// namespace as the Datadog backend expects
func ProcessMetrics(ms []datadog.Metric, cfg *config.Config) {
func ProcessMetrics(ms []datadog.Metric) {
addNamespace(ms, otelNamespacePrefix)
}

Expand Down
13 changes: 1 addition & 12 deletions exporter/datadogexporter/internal/metrics/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import (

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component"
"go.uber.org/zap"
"gopkg.in/zorkian/go-datadog-api.v2"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/config"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/internal/utils/cache"
)

Expand Down Expand Up @@ -82,15 +80,6 @@ func TestProcessMetrics(t *testing.T) {
// Reset hostname cache
cache.Cache.Flush()

cfg := &config.Config{
// Global tags should be ignored and sent as metadata
TagsConfig: config.TagsConfig{
Env: "test_env",
Tags: []string{"key:val"},
},
}
cfg.Sanitize(zap.NewNop())

ms := []datadog.Metric{
NewGauge(
"metric_name",
Expand All @@ -106,7 +95,7 @@ func TestProcessMetrics(t *testing.T) {
),
}

ProcessMetrics(ms, cfg)
ProcessMetrics(ms)

assert.Equal(t, "metric_name", *ms[0].Metric)
assert.ElementsMatch(t,
Expand Down
2 changes: 1 addition & 1 deletion exporter/datadogexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (exp *metricsExporter) PushMetricsData(ctx context.Context, md pdata.Metric
return fmt.Errorf("failed to map metrics: %w", err)
}
ms, sl := consumer.All(pushTime, exp.params.BuildInfo)
metrics.ProcessMetrics(ms, exp.cfg)
metrics.ProcessMetrics(ms)

err = nil
if len(ms) > 0 {
Expand Down