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/datadogexporter: use pkg/trace #9693

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

### 🧰 Bug fixes 🧰

- `datadogexporter`: The `traces.span_name_remappings` setting now correctly refers to the OpenTelemetry key to be renamed without any sort of normalization. (#9693)
- `datadogexporter`: Unify traces exporter behavior with Datadog Agent OTLP traces ingest. (#9693)
- `aerospikereceiver`: Fix issue where namespaces would not be collected (#11465)
- `filestorageextension`: Copy values returned by Get (#11776)
- `redactionprocessor`: respect allow_all_keys configuration (#11542)
Expand Down
18 changes: 9 additions & 9 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ require (
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/ClickHouse/clickhouse-go v1.5.4 // indirect
github.com/DataDog/agent-payload/v5 v5.0.23 // indirect
github.com/DataDog/datadog-agent/pkg/quantile v0.36.0-rc.4.0.20220426134022-b55bccd5073f // indirect
github.com/DataDog/datadog-agent/pkg/trace/exportable v0.0.0-20201016145401-4646cf596b02 // indirect
github.com/DataDog/datadog-agent/pkg/util/log v0.0.0-20201009092105-58e18918b2db // indirect
github.com/DataDog/datadog-go v4.8.2+incompatible // indirect
github.com/DataDog/agent-payload/v5 v5.0.22 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/otlp/model v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/quantile v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/trace v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-go/v5 v5.1.0 // indirect
github.com/DataDog/sketches-go v1.4.1 // indirect
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v0.32.2 // indirect
Expand All @@ -58,7 +60,6 @@ require (
github.com/SermoDigital/jose v0.9.2-0.20161205224733-f6df55f235c2 // indirect
github.com/Shopify/sarama v1.34.1 // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/aerospike/aerospike-client-go/v5 v5.8.0 // indirect
github.com/alecthomas/participle/v2 v2.0.0-alpha9 // indirect
Expand Down Expand Up @@ -86,7 +87,6 @@ require (
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
github.com/cilium/ebpf v0.7.0 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/cloudfoundry-incubator/uaago v0.0.0-20190307164349-8136b7bbe76e // indirect
Expand Down Expand Up @@ -436,7 +436,7 @@ require (
github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921 // indirect
github.com/shirou/gopsutil v3.21.10+incompatible // indirect
github.com/secure-systems-lab/go-securesystemslib v0.3.1 // indirect
github.com/shirou/gopsutil/v3 v3.22.5 // indirect
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect
github.com/signalfx/gohistogram v0.0.0-20160107210732-1ccfd2ff5083 // indirect
Expand All @@ -456,6 +456,7 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.429 // indirect
github.com/tg123/go-htpasswd v1.2.0 // indirect
github.com/theupdateframework/go-tuf v0.3.0 // indirect
github.com/tidwall/gjson v1.12.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
Expand Down Expand Up @@ -513,7 +514,6 @@ require (
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.38.1 // indirect
gopkg.in/alexcesaro/statsd.v2 v2.0.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
Expand Down
321 changes: 32 additions & 289 deletions cmd/configschema/go.sum

Large diffs are not rendered by default.

57 changes: 0 additions & 57 deletions exporter/datadogexporter/denylister.go

This file was deleted.

83 changes: 0 additions & 83 deletions exporter/datadogexporter/denylister_test.go

This file was deleted.

5 changes: 5 additions & 0 deletions exporter/datadogexporter/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ exporters:
## Trace exporter specific configuration.
#
# traces:
## @param max_events_per_second - integer - optional - default: 200
## Maximum number of APM Analytics events per second to sample.
#
# max_events_per_second: 200

## @param endpoint - string - optional
## The host of the Datadog intake server to send traces to.
## If unset it will be determined from the `DD_APM_URL` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
Expand Down
48 changes: 28 additions & 20 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package datadogexporter // import "github.com/open-telemetry/opentelemetry-colle

import (
"context"
"errors"
"fmt"
"os"
"sync"
Expand Down Expand Up @@ -238,55 +239,62 @@ func (f *factory) createTracesExporter(
set component.ExporterCreateSettings,
c config.Exporter,
) (component.TracesExporter, error) {

cfg := c.(*ddconfig.Config)

cfg, ok := c.(*ddconfig.Config)
if !ok {
return nil, errors.New("programming error: config structure is not of type *ddconfig.Config")
}
mx-psi marked this conversation as resolved.
Show resolved Hide resolved
if err := cfg.Sanitize(set.Logger); err != nil {
return nil, err
}

var (
pusher consumer.ConsumeTracesFunc
stop component.ShutdownFunc
)
hostProvider, err := f.SourceProvider(set.TelemetrySettings, cfg.Hostname)
if err != nil {
return nil, fmt.Errorf("failed to build hostname provider: %w", err)
}

ctx, cancel := context.WithCancel(ctx)
var pushTracesFn consumer.ConsumeTracesFunc

ctx, cancel := context.WithCancel(ctx) // nolint:govet
// cancel() runs on shutdown
if cfg.OnlyMetadata {
pushTracesFn = func(_ context.Context, td ptrace.Traces) error {
// only sending metadata, use only attributes
// only host metadata needs to be sent, once.
pusher = func(_ context.Context, td ptrace.Traces) error {
f.onceMetadata.Do(func() {
attrs := pcommon.NewMap()
if td.ResourceSpans().Len() > 0 {
attrs = td.ResourceSpans().At(0).Resource().Attributes()
}
go metadata.Pusher(ctx, set, newMetadataConfigfromConfig(cfg), hostProvider, attrs)
})

return nil
}
stop = func(context.Context) error {
cancel()
return nil
}
} else {
exporter, tracesErr := newTracesExporter(ctx, set, cfg, &f.onceMetadata, hostProvider)
if tracesErr != nil {
tracex, err2 := newTracesExporter(ctx, set, cfg, &f.onceMetadata, hostProvider)
if err2 != nil {
cancel()
return nil, tracesErr
return nil, err2
}
pusher = tracex.consumeTraces
stop = func(context.Context) error {
cancel() // first cancel context
tracex.waitShutdown() // then wait for shutdown
return nil
}
pushTracesFn = exporter.pushTraceDataScrubbed
}

return exporterhelper.NewTracesExporter(
cfg,
set,
pushTracesFn,
pusher,
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0 * time.Second}),
// We don't do retries on traces because of deduping concerns on APM Events.
exporterhelper.WithRetry(exporterhelper.RetrySettings{Enabled: false}),
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithShutdown(func(context.Context) error {
cancel()
return nil
}),
exporterhelper.WithShutdown(stop),
)
}
12 changes: 11 additions & 1 deletion exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ func TestLoadConfig(t *testing.T) {
TCPAddr: confignet.TCPAddr{
Endpoint: "https://trace.agent.datadoghq.eu",
},
IgnoreResources: []string{},
SpanNameRemappings: map[string]string{
"old_name1": "new_name1",
"old_name2": "new_name2",
},
SpanNameAsResourceName: true,
IgnoreResources: []string{},
}, apiConfig.Traces)
assert.True(t, apiConfig.SendMetadata)
assert.False(t, apiConfig.OnlyMetadata)
Expand Down Expand Up @@ -243,6 +248,7 @@ func TestLoadConfigEnvVariables(t *testing.T) {
t.Setenv("DD_TAGS", "envexample:tag envexample2:tag")
t.Setenv("DD_URL", "https://api.datadoghq.com")
t.Setenv("DD_APM_URL", "https://trace.agent.datadoghq.com")
t.Setenv("DD_APM_MAX_TPS", "15")

factories, err := componenttest.NopFactories()
assert.NoError(t, err)
Expand Down Expand Up @@ -296,6 +302,10 @@ func TestLoadConfigEnvVariables(t *testing.T) {
TCPAddr: confignet.TCPAddr{
Endpoint: "https://trace.agent.datadoghq.test",
},
SpanNameRemappings: map[string]string{
"old_name3": "new_name3",
"old_name4": "new_name4",
},
IgnoreResources: []string{},
}, apiConfig.Traces)
assert.Equal(t,
Expand Down
Loading